deploying nginx with minimal system resources

13
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

Upload: max-ukhanov

Post on 08-Sep-2014

2.393 views

Category:

Sports


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Deploying nginx with minimal system resources

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

Page 2: Deploying nginx with minimal system resources

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!

Page 3: Deploying nginx with minimal system resources

Compile with minimum modules

Page 4: Deploying nginx with minimal system resources

<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

Page 5: Deploying nginx with minimal system resources

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+ }

Page 6: Deploying nginx with minimal system resources

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;

Page 7: Deploying nginx with minimal system resources

<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/*; }

Page 8: Deploying nginx with minimal system resources

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

Page 9: Deploying nginx with minimal system resources

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; }

Page 10: Deploying nginx with minimal system resources

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;

}

Page 11: Deploying nginx with minimal system resources

Conclusions

• Creating fast and productive web-server

system, will help students and teacher in

PRODUCTIVE work with web-portal and

remote education systems.

Page 12: Deploying nginx with minimal system resources
Page 13: Deploying nginx with minimal system resources

<Insert Picture Here>

Contacts

[email protected]

@ukhanoff

http://ua.linkedin.com/in/ukhanoff