By default, nginx cannot parse PHP. to parse PHP, You need to modify the nginx configuration file. Open nginx. conf and find location to modify as follows: location=rootvarwww1_indexindex.phpindex.htmlindex.htm;} Find location ~. Php $, modify as follows: location ~. Php $ {rootvarwww;
By default, nginx cannot parse PHP. to parse PHP, You need to modify the nginx configuration file. Open nginx. conf and find location/modify as follows: location/{root/var/www; index. php index.html index.htm;} Find location ~ . Php $, modify as follows: location ~ . Php $ {root/var/www;
By default, nginx cannot parse PHP. to parse PHP, You need to modify the nginx configuration file.
Open nginx. conf,
Locate location/and modify it as follows:
Location /{
Root/var/www;
Index. php index.html index.htm;
}
Locate location ~ . Php $, modified as follows:
Location ~ . Php $ {
Root/var/www;
Fastcgi_pass 127.0.0.1: 9001;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/var/www $ fastcgi_script_name;
Include fastcgi_params;
}
Root: Set the root directory of the PHP script
Fastcgi_pass: port for processing PHP scripts. Listen to port 9001 here.
Fastcgi_index: Index File
Fastcgi_param: php script path
After setting up, you also need to configure the php-fpm.conf, go to the etc folder under your php installation directory, rename the php-fpm.conf.default to the php-fpm.conf, double-click to open, modify listen to 9001.
Start the terminal and run cd to enter the sbin folder in the php installation directory. /php-fpm command to start fpm, if the startup error, open the php-fpm.conf, remove the following statement before watching, and then restart php-fpm
Pm. start_servers = 20
Pm. min_spare_servers = 5
Pm. max_spare_servers = 35
Pm. max_requests = 500
Configure nginx and php-fpm to start automatically at startup:
Open/etc/rc. local and add
Ulimit-SHn 65535
/Var/web/php/sbin/php-fpm
/Var/web/nginx/sbin/nginx
Save the file and restart it.
Change/var/web/php and/var/web/nginx to your own php/nginx installation directory.
Create index. php In the var/www directory and write the code:
Phpinfo ();
?>
Access: http: // localhost. The php configuration page is displayed!
PS: Start nginx manually, open the terminal, run cd to enter the nginx sbin directory, and run the./nginx command to start nginx