In this post, I will show step to run a simple site in nginx server, use FPM.
Install all packet with apt-get:
1 |
sudo apt-get install nginx mysql-server php5-fpm php5-mysql |
Create example.com file in /etc/nginx/site-available/
1 2 |
cd /etc/nginx/site-available vi example.com |
Add the content below to “example.com” file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/example.com/www; index index.php index.html index.htm; server_name example.com gzip on; access_log /usr/share/nginx/example.com/nginx-access.log combined; error_log /usr/share/nginx/example.com/nginx-error.log warn; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } |
And enable the site you created
1 2 3 4 5 6 |
cd /etc/nginx/site-enabled ln -s /etc/nginx/site-available/example.com example.com cd /usr/share/nginx mkdir -p example.com/www cd example.com/www echo "<?php phpinfo() ?>" > index.php |
Now for the test