CentOS 7 arranged nginx php-fpm detailed tutorial

Step Nginx CentOS 7 arranged as follows:

First update yum, yum is not installed self-installation

yum update

 

1. Install Nginx

yum install nginx 

 

Nginx open and set the boot

systemctl start nginx
systemctl enable nginx

 

After completion, will enter localhost following page, installation is successful, the page will be the two information, a profile of the path, the path is a directory www

 

 

2. Install the latest version of PHP, PHP-FPM

Note that PHP and PHP-FPM version must be consistent

yum install php php-fpm php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml php-pdo
php-pgsql php-pecl-redis php-soap

 

After successful installation, run the following command to view the php version

php -v

 

After the default php-fpm installation is successful, there will be a document php-fpm.pid under / var / run / php-fpm

 

3. Configure nginx php parse

1) modify the configuration file nginx

vim /etv/nginx/nginx.conf

Insert the following code in the server:

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

###Save user landing page to cookie: srcid for PHP files
##add_header Set-Cookie $srcid;
}

 

2) modifying the configuration file php-fpm

vim /etc/php-fpm.d/www.conf

Locate the following three lines of code and amended as follows

user = nginx 
group = nginx
listen = /var/run/php-fpm/php-fpm.sock

listen.owner = nignx listen.group = nginx listen.mode = 0660

 

If this step is not configured, the browser will open the php file error

“The page you are looking for is temporarily unavailable. Please try again later”

 

3) Modify php.ini

vim /etc/php.ini

 

Cgi.fix_pathinfo find and edit 0

cgi.fix_pathinfo=0

 

After the above configuration, the restart nginx, php-fpm 

systemctl restart php-fpm nginx

 

Test whether the configuration is successful

vim /usr/share/nginx/html/test.php
<?php
  // test script for CentOS/RHEL 7+PHP 7.2+Nginx 
  phpinfo();
?>

 

Open lcoalhost / test.php in your browser

 

 

 

Information Reference:

https://serverfault.com/questions/607370/getting-the-page-you-are-looking-for-is-temporarily-unavailable-please-try-aga

https://www.cyberciti.biz/faq/how-to-install-php-7-2-on-centos-7-rhel-7/

Guess you like

Origin www.cnblogs.com/ryanzheng/p/11263261.html