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

How to set up nginx and php servers under Ubuntu

王林
Release: 2023-05-22 21:10:27
forward
950 people have browsed it

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

sudo apt-get install nginx
Copy after login

 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
Copy after login

 Install php -cgi module

sudo apt-get install php5-cgi
Copy after login

 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
Copy after login

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
Copy after login

 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
Copy after login

 Start nginx

sudo /etc/init.d/nginx start
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template