Introduction to centos + nginx + php configuration

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.