Home  >  Article  >  Operation and Maintenance  >  How to set up nginx and php servers under Ubuntu

How to set up nginx and php servers under Ubuntu

王林
王林forward
2023-05-22 21:10:27876browse

 Install nginx, execute the following command, it will be completed soon

sudo apt-get install nginx

 The default installation location of the configuration file:

conf: /etc/nginx/nginx.conf
bin:/usr/sbin/nginx
vhost: /etc/nginx/sites-enable/default
cgi-params: /etc/nginx/fastcgi-params

 Install php -cgi module

sudo apt-get install php5-cgi

 Default installation location of configuration file:

php-cgi: /usr/bin/php-cgi
php5-cgi: /usr/bin/php5-cgi
cgi config: /usr/bin/cgi/php.ini

One thing to note here is that you must modify the cgi.fix_pathinfo of the php.ini file The data is 1, the default is 0 cgi.fix_pathinfo=1; In this way, php-cgi can use the script_filename variable normally.

 Install spawn-fcgi

If the system does not have the gcc compilation environment installed, you just need to install the build-essential tool package before installing lighttpd, execute the following command:

sudo apt-get install build-essential
wget http://www.lighttpd.net/download/lighttpd-1.4.19.tar.gz
tar -xvf lighttpd-1.4.19.tar.gz
cd lighttpd-1.4.19/
sudo apt-get install libpcre3-dev
./configure –without-zlib –without-bzip2
make
sudo cp src/spawn-fcgi /usr/local/bin/spawn-fcgi

 Start fast_cgi:

spawn-fcgi -a 127.0.0.1 -p 9000 -c 5 -u www-data -g www-data -f /usr/bin/php-cgi

 Start nginx

sudo /etc/init.d/nginx start

The above is the detailed content of How to set up nginx and php servers under Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete