Centos7.4 install nginx and php-fpm

Centos7.4 install nginx and php-fpm:

1. Install nginx:
yum install -y nginx

systemctl restart nginx

 

2. Configure php-fpm

The project directory is under /root/html, you need to change the default directory of nginx

 

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    root /var/www/html;
    #Modify all directories corresponding to root to /var/www/html


    location ~ \.php$ {
        root           /root/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  /root/html/$fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

 

Reload nginx configuration:

nginx -s reaload

 

3. Install php-fpm:
use yum search all php-fpm to install the version you need

yum install -y php-fpm

This is the PHP5 version. To install a higher version of php-fpm, you need to follow the steps below:

1). Install epel-release
through the command:
yum -y install epel-release

2). Install PHP7
terminal and run the following command again:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic. com/yum/el7/webtatic-release.rpm

3). yum查看
yum search php70w-fpm      #PHP7.0
yum search php71w-fpm      #PHP7.1

4). Install the yum source of PHP 7.0 and 7.1, and then execute:

Install php 7.0 and extensions
yum install php70w php70w-fpm php70w-cli php70w-common php70w-devel php70w-gd php70w-pdo php70w-mysql php70w-mbstring php70w-bcmath php71w-xml

Install php 7.1 and extensions
yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath php71w-xml php71w-pdo.

5). Start the service
systemctl start php-fpm

6). Start the service

systemctl enable php-fpm

 

4. Write a PHP script phpinfo.php and put it in the server web root directory:

<?php
   phpinfo();

 Type in the browser: ip/

http://192.168.1.108/phpinfo.php


 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325348400&siteId=291194637
Recommended