1- install the necessary packages
$ sudo apt-get install nginx php5-fpm
2- create site1 configuration for php5-fpm location at /etc/php5/fpm/pool.d/site1.conf with the following content
[site1]
listen = /var/lib/php5-fpm/site1.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
user = www-data
group = www-data
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 5
pm.max_requests = 0
chdir = /
php_admin_value[open_basedir] = /var/www/site1/web:/var/www/site1/private:/var/www/site1/tmp
php_admin_value[session.save_path] = /var/www/site1/tmp
php_admin_value[upload_tmp_dir] = /var/www/site1/tmp
4- create nginx vhost file for site1 at location /etc/nginx/sites-enabled/site1.conf with the following content
server {
listen *:80;
server_name 123test.domain www.123test.domain;
root /var/www/site1/web;
index index.html index.htm index.php index.cgi index.pl index.xhtml;
error_log /var/log/httpd/123test.domain/error.log;
access_log /var/log/httpd/123test.domain/access.log combined;
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \.php$ {
try_files /6707658166984386d1d2957b56a8b4d5.htm @php;
}
location @php {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/site1.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
}
5- create all the directory
$ mkdir /var/www/site1 -p
$ mkdir /var/www/site1/web
$ mkdir /var/www/site1/private
$ mkdir /var/www/site1/tmp
$ mkdir /var/lib/php5-fpm
$ mkdir -p /var/log/httpd/123test.domain/
$ echo "<?php phpinfo(); ?>" > /var/www/site1/web/index.php
6- restart nginx and php5-fpm restart
$ sudo /etc/init.d/nginx restart
$ sudo /etc/init.d/php5-fpm restart
if you can not restart php5-fpm with command above, just kill it and start it again
- screenshot of access the virtual host.
No comments:
Post a Comment