Linux install and enable PHP-FPM

First, take the -- enable FPM parameter with you at compile time:

[root@localhost local]# yum -y install libxml2 libxml2-devel gd gd-devel 
[root@localhost local]# wget http://cn2.php.net/distributions/php-7.2.0.tar.gz
[root@localhost local]# tar -zxvf php-7.2.0.tar.gz 
[root@localhost local]# cd  php-7.2.0
[root@localhost php-7.2.0]# ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-gd \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-mysqlnd-compression-support \
--enable-mbstring \
--enable-zip \
--enable-fpm 
[root@localhost php-7.2.0]# make && make install

If it has been installed, you can view the previous compilation parameters in the following ways:

/usr/bin/php -i | grep Configure
# perhaps
cd /lamp/php-7.2.0 & cat config.nice

To create a profile:

[root@localhost php-7.2.0]# cp php.ini-production /usr/local/php/etc/php.ini
[root@localhost php-7.2.0]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@localhost php-7.2.0]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

Configure system services and environment variables:

[root@localhost php-7.2.0]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-7.2.0]# chmod +x /etc/init.d/php-fpm
[root@localhost php-7.2.0]# ln -s /etc/init.d/php-fpm /usr/bin/

[root@localhost ~]# vim /etc/profile
export PATH=/usr/local/php/bin:$PATH     #Last face add
[root@localhost ~]# source /etc/profile
[root@localhost ~]# php -v

Edit profile:

# vim php-fpm.conf
pid = /usr/local/php/var/run/php-fpm.pid
user = www
group = www

Create users and user groups:

groupadd www
useradd -g www www

Start with command:

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

View in progress:

ps -ef | grep php-fpm

View port:

netstat -tnl | grep 9000

Configure boot:

# vi /etc/rc.local  join
/usr/local/php/sbin/php-fpm

Close FPM:

kill -INT `cat /usr/local/php/var/run/php-fpm.pid`

Restart FPM:

kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`

Signal description:

INT/TERM forced termination
 QUIT smooth termination
 USR1 reopens the log file
 USR2 smoothly reloads all master s and worker s

Tags: PHP PDO vim yum

Posted on Mon, 18 May 2020 10:06:10 -0400 by zako234