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

11-08-2023

Similar to installing other software, the installation process is basically a fool.

Install nginx and execute the following command, which will be completed soon.

sudo apt-get install nginx

Default installation location of configuration file:

conf: /etc/nginx/nginx.confbin:/usr/sbin/nginxvhost: /etc/nginx/sites-enable/defaultcgi-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-cgiphp5-cgi: /usr/bin/php5-cgicgi config: /usr/bin/cgi/php.ini

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

Install spawn-fcgi

If the gcc compilation environment is not installed in the system, and you just need to install the build-essential toolkit before installing lighttpd, execute the following command:

sudo apt-get install build-essentialwget http://www.lighttpd.net/download/lighttpd-1.4.19.tar.gztar -xvf lighttpd-1.4.19.tar.gzcd lighttpd-1.4.19/ sudo apt-get install libpcre3-dev./configure –without-zlib –without-bzip2makesudo 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

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us