deploying nginx with minimal system resources
DESCRIPTION
TRANSCRIPT
Deploying balanced Nginx web server with
minimal system resources National Technical University of Ukraine 'Kyiv Polytechnic Institute'
Faculty of Informatics and Computer Technology
Department of Automated Production Management Systems
Max Ukhanov
Scientific Advisor Ph.D. Sciences,
associate professor Tetyana Kovalyuk
Problem statement
• Using information technologies for communication
between students and teachers, help with remote
education system. One of variants of this system it’s
Web Portal. Web Portal could be hosted on some
Web-server. And this server should be fast and
economical.
• So what is the solution?
Web-server Nginx!
Compile with minimum modules
<Insert Picture Here>
THINK about what modules you are needed!
Don’t use: mail, mail_ssl_module, http_perl_module,
http_flv_module, http_dav_module
Use: http_gzip_static_module, http_stub_status_module
KISS concept in /etc/nginx/nginx.conf
user www-data; worker_processes 1; # = cpus quantity.
worker_rlimit_nofile 65535; # Maximum file descriptorthat can be opened by worker.
timer_resolution 100ms; # The directive allows to decrease number gettimeofday() syscalls.
events { worker_connections 65535; # worker_processes * worker_connections = maxclients use epoll; #the effective method, used on Linux 2.6+ }
KISS concept in /etc/nginx/nginx.conf
(part 2) http {
sendfile on; # Enable sendfile(). Makes
sphinx use less memory.
tcp_nopush on;
tcp_nodelay on; # it’s on by default.
keepalive_timeout 65; # default is 75.
types_hash_max_size 2048; # it’s ok
client_max_body_size 100m;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging Settings
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
<Insert Picture Here> Virtual Host configuring
server { listen 80; server_name _; access_log /var/log/nginx/localhost.access.log root /usr/share/nginx/www; index index.html; } include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
PHP
• Install php5-cgi php5-cli spawn-fcgi modules
• vim /usr/local/bin/php-fastcgi
/usr/bin/spawn-fcgi -s /home/example/web/php- fcgi.socket -M 0770 -u example -g example -f
/usr/bin/php5-cgi
• vim /etc/init.d/php-fastcgi
adding PHP_SCRIPT=/usr/local/bin/php-fastcgi
PHP + Nginx vim etc/nginx/php_host_params
access_log /var/log/nginx/$user.access.log; root /home/$user/web/e/$host; index index.php index.html; location ~ \.php$ { fastcgi_pass unix:/home/$user/web/php-fcgi.socket; fastcgi_param SCRIPT_FILENAME $document_root $fastcgi_script_name; include fastcgi_params; }
Troubles with pictures and not
standart file extensions
• types { • application/xml xml;
• image/gif gif;
• image/jpeg jpg;
• image/png png;
• image/bmp bmp;
• image/x-icon ico;
• text/css css;
• text/html html;
• text/plain bob;
• text/plain txt;
}
Conclusions
• Creating fast and productive web-server
system, will help students and teacher in
PRODUCTIVE work with web-portal and
remote education systems.