Lnmp compiled installation of nginx related php--text

Source: Internet
Author: User

LNMP compilation and installation of Nginx associated php--text 1, preface

Prior to the introduction of the Nginx,php,mysql installation process, but Nginx and PHP Association is not involved, resulting in the Web page does not work properly PHP function, all this part describes how to associate Nginx and PHP, so that the *.php file can be accessed normally in the browser.

2. Preparation steps

2.1. Modify the PHP-FPM configuration file

Cp/usr/local/php7/etc/php-fpm.conf.default/usr/local/php7/etc/php-fpm.conf
Cp/usr/local/php7/etc/php-fpm.d/www.conf.default/usr/local/php7/etc/php-fpm.d/www.conf


2.2. Edit the PHP-FPM configuration file

vi/usr/local/php7/etc/php-fpm.d/www.conf (Open listen.allowed_clients = 127.0.0.1)

vi/usr/local/php7/etc/php-fpm.conf (Open pid = run/php-fpm.pid)

2.3, Drive PHP-FPM

/usr/local/php7/sbin/php-fpm

2.4. View PHP-FPM Running Status

PS Aux|grep php-fpm

Here the basic configuration of the PHP-FPM is complete, then continue to configure Nginx

3, Nginx Configuration modification

3.1. Configure Nginx

Vim/usr/local/nginx/conf/nginx.conf

Add under Server

Location/{
Root/var/nginx/www; (Web root directory)
Index index.html index.htm index.php; (add index.php)
}
Location ~ \.php {
Root/var/nginx/www; (Web root directory)
Fastcgi_pass 127.0.0.1:9000;
fastcgi_index/index.php;
Include/usr/local/nginx/conf/fastcgi_params;
Fastcgi_split_path_info ^ (. +\.php) (/.+) $;
Fastcgi_param path_info $fastcgi _path_info;
Fastcgi_param path_translated $document _root$fastcgi_path_info;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
}

3.2. Restart Nginx

How to omit it without opening

/usr/local/nginx/sbin/nginx (Start Nginx)

Otherwise

/usr/local/nginx/sbin/nginx-s Reload (restart Nginx)

3.3. View Nginx Status

PS Aux|grep Nginx

3.4, test site is normal access

Slightly

4, set the Nginx start-up

4.1. Set the Nginx self-starter script

Vi/etc/init.d/nginx

4.2. Modify File Permissions

chmod A+x/etc/init.d/nginx

4.3. Join Chkconfig Management List

Chkconfig--add/etc/init.d/nginx

4.4. Set/etc/init.d/nginx self-starter
Chkconfig Nginx on

Script content Please refer to: https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/

5. Set PHP-FPM to start

PHP-FPM's self-starter script in the downloaded PHP installation package

5.1. Copy the php-fpm script

CP//ROOT/PHP/PHP-7.1.7/SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM

5.2. Modify PHP-FPM Permissions

chmod a+x/etc/init.d/php-fpm

5.3. Join Chkfconfig Service

Chkconfig--ADD/ETC/INIT.D/PHP-FPM

5.4. Set PHP-FPM self-starter

Chkconfig PHP-FPM on

5.5. Copy Php-ini (not required, can be omitted)

PHP installation package provides two php.ini configurations

The php.ini-development corresponds to the php.ini-dist and is suitable for development testing, such as a local test environment.
Php.ini-production corresponds to the php.ini-recommended has a high security settings, suitable for the server on-line operation when the product.

Top two two Select one

CP Php.ini-development/usr/local/php7/lib/php.ini

Here PHP-FPM's configuration is complete.

6. Reboot to check the status of PHP-FPM and Nginx to test whether the website can be accessed normally

Slightly

Lnmp compiled installation of nginx related php--text

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.