PHP-RPM Installation Guide (Useful for hands-on testing)

Keywords: PHP cmake yum MySQL

Note: This tutorial may have a lot of detours, but it is sure that the installation was successful. One problem is that the initial installation of the compiled instructions seems to be wrong, but it was corrected later, but this tutorial has encountered more than 10 problems and solved them, which has some reference and (django) It starts with being in a vir... virtual environment, not affected.(Reminder: Installing this may also be building Django + mysql + uwsgi + nginx, then Baidu gets a lot of PHP-FPM or PHP-FPM related installations. Please carefully compare your error information with that of the person who proposed this solution. Error information is queried in the log.)
Install php-fpm
(newly bought Aliyun does not have php-fpm by default)

Download php

1 wget https://www.php.net/distributions/php-7.3.8.tar.gz

- Unzip installation

1 tar -xvf php-7.3.8.tar.gz
2 
3  ./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear
* Then there may be errors

 

Solutions:

1 yum install libxml2-devel

- Check for success

1 find / -name "xml2-config"

Then proceed indefinitely with the decompressed installation steps and look for errors until all the problems are solved. Maybe I encountered something that you haven't, or maybe, the following error solutions are only worth learning from.(You don't know if it's suitable or not)

Solution: Re-install curl

1 yum -y install curl-devel

- Solutions

yum -y install libzip-devel

 

 

Solution: This is because the system's built-in libzip version is low, so uninstall the system's built-in libzip first
yum  -y remove libzip-devel

Download and compile the installation on the official website

 

(There is also a need to install something here, due to the different installation methods and versions for 1.5 and above)

 

yum -y install cmake

Then cut back to the local directory (version may be updated)

wget https://libzip.org/download/libzip-1.5.2.tar.xz

Unzip installation

1 tar xvf libzip-1.5.2.tar.xz
2 
3 cd libzip-1.5.2
4 
5 mkdir build
6 
7 cd build
8 
9 cmake ..
At this point, you may find that the cmake version is low

 

You need to update the cmake version (epsilon=(_'*))
cd /usr/local

First, remove cmake

yum remove cmake

https://cmake.org/download/

 

 

 

Download the latest version of cmake (find your own official copy link)
wget https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2.tar.gz

Unzip

tar -xvf cmake-3.15.2.tar.gz

Enter the cmake3.15.2 folder to install

1 cd cmake-3.15.2
2 
3 ./configure
4 
5 make
6 
7 make install

After successful installation,

Add the cmake environment variable below, edit the / etc/profile.d/cmake.sh file, and write the following:
export CMAKE_HOME=/usr/local/cmake-3.15.2
export PATH=$PATH:$CMAKE_HOME/bin

Save and exit, execute the command to make the cmake environment file take effect

source /etc/profile
At this point, if you look at the cmake version again, it will be 3.15.2
(django) [root@h1 cmake-3.15.2]# cmake --version
cmake version 3.15.2

* Re-install libzip

1 cd /usr/local/libzip-1.5.2
2 
3 cd build
4 
5 cmake ..
6 
7 make && make install

- Installation complete

* Re-run the php installation test
cd /usr/local/php-7.3.8

 ./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear

   

) Problem may occur again (close to each other)

Solutions
1 vim /etc/ld.so.conf 
2 #Add the following lines
3 /usr/local/lib64
4 /usr/local/lib
5 /usr/lib
6 /usr/lib64 
7 #Save Exit
8 :wq
9 ldconfig -v # Make it effective

 

warning:configure:WARNING:unrecognizedoptions:--with-mysql occurs after PHP compilation except that MySQL module is not supported in php7 version

/ configure --help Check the correct syntax of configure, recompile php to support mysql, use --with-pdo-mysql instead

The correct compiled statement for php7 is:
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-mcrypt --with-libmbfl --enable-ftp --with-gd --enable-gd-jis-conv --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm

 

 

Solutions:
1 rpm -qa | grep libjpeg 
2 yum -y install libjpeg-devel
3 yum list installed | grep libjpeg
4 Compile again

 

Solution:
yum install -y libicu-devel

 

Solutions
Check if the following is installed or not:
Check:
1 yum list openldap
2 yum list openldap-devel

Installation:

1 yum install openldap
2 yum install openldap-devel

  configure: error: Cannot find ldap libraries in /usr/lib

Solutions

cp -frp /usr/lib64/libldap* /usr/lib/

 

 

At this point, the compilation instructions replaced with version 7.3 were found
./configure --enable-fpm --prefix=/alidata/server/php7.3 --with-config-file-path=/alidata/server/php7.3/etc  --with-curl  --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 --enable-zip --with-zlib-dir=DIR --with-pcre-dir --with-libzip=DIR --with-openssl --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-xml --enable-zip

 

- Solutions
yum -y install libxslt libxslt-devel

 

! Finally successful!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (A total of 12 problems occurred)
; and then move on to the topic
Compile
make

 

make install 

 

 

* Notice here that you can see
Add PHP to environment variable should be /alidata/server/php7.3/bin/
Configure environment variables (add PHP commands to environment variables)
vim /etc/profile

Add at the end

1 PATH=$PATH:/alidata/server/php7.3/bin/
2  
3 export PATH
For changes to take effect immediately
. /etc/profile or source /etc/profile

View environment variables

echo $PATH
View php version
(django) [root@h1 php-7.3.8]# php -v
PHP 7.3.8 (cli) (built: Aug  9 2019 21:27:07) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
(django) [root@h1 php-7.3.8]# 

Configure startup php-fpm

 1 Installing shared extensions:     /alidata/server/php7.3/lib/php/extensions/no-debug-non-zts-20180731/
 2 Installing PHP CLI binary:        /alidata/server/php7.3/bin/
 3 Installing PHP CLI man page:      /alidata/server/php7.3/php/man/man1/
 4 Installing PHP FPM binary:        /alidata/server/php7.3/sbin/
 5 Installing PHP FPM defconfig:     /alidata/server/php7.3/etc/
 6 Installing PHP FPM man page:      /alidata/server/php7.3/php/man/man8/
 7 Installing PHP FPM status page:   /alidata/server/php7.3/php/php/fpm/
 8 Installing phpdbg binary:         /alidata/server/php7.3/bin/
 9 Installing phpdbg man page:       /alidata/server/php7.3/php/man/man1/
10 Installing PHP CGI binary:        /alidata/server/php7.3/bin/
11 Installing PHP CGI man page:      /alidata/server/php7.3/php/man/man1/
12 Installing build environment:     /alidata/server/php7.3/lib/php/build/
13 Installing header files:          /alidata/server/php7.3/include/php/
14 Installing helper programs:       /alidata/server/php7.3/bin/
15   program: phpize
16   program: php-config
17 Installing man pages:             /alidata/server/php7.3/php/man/man1/
18   page: phpize.1
19   page: php-config.1

As you can see from the installation information in the diagram above, php-fpm is

cd /alidata/server/php7.3/etc

 

Then?

cp php-fpm.conf.default php-fpm.conf

Start php-fpm

/alidata/server/php7.3/sbin/php-fpm
Then there may be problems

 

Solution
(django) [root@h1 etc]# cd /alidata/server/php7.3/etc/php-fpm.d/

(django) [root@h1 php-fpm.d]# cp www.conf.default www.conf


(django) [root@h1 php-fpm.d]# /alidata/server/php7.3/sbin/php-fpm -t

 [09-Aug-2019 21:45:42] NOTICE: configuration file /alidata/server/php7.3/etc/php-fpm.conf test is successful

And it started successfully

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Posted by UKlee on Sun, 18 Aug 2019 09:44:28 -0700