Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
147
rated 0 times [  147] [ 0]  / answers: 1 / hits: 397470  / 2 Years ago, tue, july 19, 2022, 9:11:16

What is the easiest way to enable PHP on nginx on Ubuntu 12.04?



Best solution is the one that request minimal work, ideally just a package installation :)


More From » php

 Answers
2

The following method will get you started fast on Ubuntu 12.04:



Install the dependences:



sudo apt-get install php5-common php5-cli php5-fpm



Install nginx:



sudo apt-get install nginx



Start nginx:



sudo service nginx start



Test that it's working (should see "Welcome to nginx!")



sudo service nginx stop



In your nginx site configuration (/etc/nginx/sites-available/default), modify the line in the server {} section



index index.html index.htm to index index.php index.html index.htm.



Uncomment the lines in the server {} section starting with



listen for ipv4 / ipv6 both.



Scroll down to where it says location ~ .php { and uncomment lines so it looks like this:



location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}


sudo service php5-fpm restart
sudo service nginx restart



Your default web root is located at /usr/share/nginx/www (per the config file). (See root /usr/share/nginx/www;



(Note: For Ubuntu 12.10 or newer, you will need to replace the fastcgi_pass 127.0.0.1:9000; line with this to make it work: fastcgi_pass unix:/var/run/php5-fpm.sock;)


[#38578] Thursday, July 21, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tatoethin

Total Points: 377
Total Questions: 110
Total Answers: 98

Location: Saudi Arabia
Member since Sat, Aug 20, 2022
2 Years ago
;