Home>Article>Backend Development> How to configure nginx and php-fpm

How to configure nginx and php-fpm

醉折花枝作酒筹
醉折花枝作酒筹 forward
2021-07-13 09:18:07 2852browse

In php7, the most indispensable ones are nginx and php-fpm. Today I will show you how to configure nginx and php-fpm. You can refer to it if you need it.

How to configure nginx and php-fpm

0: Turn off the firewall first!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

1: Compile and install php nginx No introduction;

2: After installing php, not only must you put the php.ini in the source package to the corresponding location (mine is in /usr/local/php/ lib/, do not specify the location for compilation and installation, just put it here, pay attention), and also put php-fpm in the source package under /usr/local/bin;

Source code compilation

./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip

2.2 Place php-fpm under /usr/local/bin, and then run

3: Add A user group groupadd www-data

Add a user to this group useradd -g www-data (group name) www-data (user name)

4: Put the php.ini file below cgi.fix_pathinfo is changed to 0

5: The configuration file of php-fpm.conf is installed in the /usr/local/php/etc directory by default;

Copy: cp /usr/lcoal/php/etc/php-fpm.conf .default /usr/local/php/etc/php-fpm.conf

##6; Edit php-fpm.conf

A: Change php-fpm to background running mode

B: Change the www- data (group) www-data (user) is added to this configuration file. However, this configuration file may not exist. Then look down

C: It is introduced here Another configuration file, in the /usr/local/php/etc/php-fpm.d folder,

execute: cp /usr/local/php/etc/php-fpm.d/www. conf.default /usr/local/php/etc/php-fpm.d/www.conf

D: vim www.conf, change user and group to just Created www-data

7: Edit nginx.conf

vim /usr/local/nginx/config/nginx.conf

Change to this: For specific tutorials, search online

8: Write a phpinfo.php file in the root directory and test

!!!!!! !!!!!!!!!!!!Turn off the firewall!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!! !!!All configuration files must be restarted after changing them!!!!!!!!!!

centos7 close the firewall

//Temporarily close systemctl stop firewalld

//Disable starting systemctl disable firewalld at boot

9: Restart the configuration file as follows

To add php nginx mysql to the service, please refer to the following

https://blog.csdn.net /ijijni/article/details/78513521

#Recommended learning:

php video tutorial

10: Visit page phpinfo page

The above is the detailed content of How to configure nginx and php-fpm. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete