PHP installation, add PHP fom to the service startup item in RedHat 6


The new version of php-7.3.27 already contains the PHP FPM module. It is no longer like php-5.2 to patch PHP FPM. Generally speaking, there are more pits than before, and the process is more complicated. This time, the running environment is rehat6.5. In addition to installing PHP in detail, configuration PHP is added to the service startup item.

1. Download the installation package Official download PHP source package

2. Configure the installation environment

The software libraries required by the installation environment are directly installed on the CD,

a) The general library, the software library required by the installation environment, is directly installed on the CD,

yum install -y gcc gcc-c++ \
freetype-devel bzip2-devel \
curl-devel autoconf libxml2-devel \
libjpeg-devel libpng-devel \
libxslt-devel \
openssl openssl-devel

b) Zlib library, libzip is not available in RedHat 6.5, so it needs to be installed separately. (another interesting thing is that there is libzip package on the CD of CentOS 7, but version 0.10.1-8. To ensure normal compilation, we still use a new version.)

tar xzf zlib-1.2.11.tar.gz
cd zlib-1.2.11
make && make install
yum remove -y libzip
tar xzf libzip-1.2.0.tar.gz
cd libzip-1.2.0
make && make install  

c) Lib64. The libzip installed above is not enough. You need to add the library path at the end of the file

vim /etc/
Add at the end of the file:
Save and exit.
ldconfig -v
ln -s /usr/lib64/ /usr/lib/

3. Install PHP

a) Creating PHP related users

[[email protected] ~]# groupadd -r www
[[email protected] ~]# useradd -g www -s /sbin/nologin -r -M www

b) Compiling and installing modules

[[email protected] ~]# tar xzf php-7.3.27.tar.gz 
[[email protected] ~]# cd php-7.3.27
[[email protected] php-7.3.27]#./configure --prefix=/usr/local/php \--with-config-file-path=/usr/local/php/etc--with-fpm-user=www \
--with-fpm-group=www \
--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-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-xml \
--enable-zip \


After the command is executed, if “thank you for using PHP.” is displayed, it means that all kinds of pits have been filled, and you can enter the compilation and installation phase. If an error is reported in the middle of the process, you have to carefully follow the prompts to see which link has a problem.

c) Compile and install

Before compiling and installing, execute this command:

cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

Then old make, this process about 10 minutes, wait patiently

make && make install

d) Add PHP to the system

1) Edit VIM ~ /. Bash_ Profile (valid for current login user)

2) Edit / etc / profile and add the following two lines at the end (effective for all system users)

export PATH[[email protected] ~]# source /etc/profile[[email protected] ~]# echo $PATH

e) Create PHP initial configuration file (under source code package path)

[[email protected] php-7.3.27]# cp php.ini-development /usr/local/php/lib/php.ini

f) Add PHP FPM to service startup

[[email protected] ~]# cp /root/php-7.3.27/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[[email protected] ~]# chmod 755 /etc/init.d/php-fpm
[[email protected] ~]# chkconfig --add /etc/init.d/php-fpm
[ [email protected]  ~]# chkconfig php-fpm on [ [email protected] ~]#Service PHP FPM start # start PHP FPM

At this time, you will find the startup error

This is the lack of PHP FPM configuration file. We only found php-fpm.conf.default in the directory of prompt. Just copy and paste a copy.

[ [email protected] Php-7.3.27] # CP / usr / local / PHP / etc / php-fpm.conf.default / usr / local / PHP / etc / php-fpm.conf # at this time, you will find that there are still errors when you restart. At this time, www.conf is not found under the last include index
[[email protected] php-7.3.27]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

At this point, it’s time to start PHP discovery.

[[email protected] ~]# service php-fpm start
Starting php-fpm  done