How to set up nginx+php server application under Linux system

WBOY
Release: 2023-05-20 19:55:04
forward
1167 people have browsed it

It is similar to installing other software. The installation process is basically fool-proof

Install nginx, execute the following command, and it will be completed quickly

sudo apt-get install nginx

Default installation location of 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 the 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 the cgi.fix_pathinfo data in the php.ini file must be modified to 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+php server application under Linux system. 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