Nginx Installation and Configuration

From Biowikifarm Metawiki
Revision as of 18:04, 13 June 2012 by Gregor Hagedorn (Talk | contribs) (Created page with "Based on * http://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian * http://www.webhostingtalk.com/showthread.php?t=1025286 = for debian 6 sudo nano...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Based on

sudo nano /etc/apt/sources.list

add lines:

# necessary only for php-fpm, the php version for nginx:
deb http://packages.dotdeb.org stable all

Add the GnuPG key to your distribution:

wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | sudo apt-key add -
rm dotdeb.gpg

Install:

sudo apt-get update
sudo apt-get install php5 php5-fpm php-pear php5-common php5-mcrypt php5-mysql php5-cli php5-gd
sudo apt-get install nginx

change php-fpm configuration with:

sudo nano /etc/php5/fpm/php5-fpm.conf

setting:

pm.max_children = 25
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.max_requests = 1500
request_terminate_timeout = 450s

change nginx configuration with:

sudo nano /etc/nginx/nginx.conf
client_max_body_size 20M;
client_body_buffer_size 128k;

edit the default vhost symlink:

cd /etc/nginx/sites-enabled
nano /etc/nginx/sites-available/default
server {
               listen 80;
               server_name website.com www.website.com;
               access_log /var/log/nginx/website.access_log;
               error_log /var/log/nginx/website.error_log;
               root /var/www/www.website.com;
               index index.php index.htm index.html;
               location ~ .php$ {
                 fastcgi_pass   127.0.0.1:9000;
                 fastcgi_index  index.php;
                 fastcgi_param  SCRIPT_FILENAME /var/www/www.website.com$fastcgi_script_name;
                 include fastcgi_params;
               }
      }


(To create symlinks for further vhost files like "www.example.com" under sites-enabled:

ln -s /etc/nginx/sites-available/www.example.com /etc/nginx/sites-enabled/www.example.com

)


For ssl on port 443, copy and paste the entire vhost code into the bottom of the vhost file, change 'listen' to 443 and point to the ssl certs:

ssl on;
ssl_certificate /path/to/certificate/www.website.com.crt;
ssl_certificate_key /path/to/certificate_key/www.website.com.key;


Restart php5-fpm and nginx:

sudo /etc/init.d/php5-fpm restart
sudo /etc/init.d/nginx restart