Alibaba cloud centos7.6 detailed tutorial for installing php7.3 (super detailed)

The LNMP environment is being set up. The startup user used by nginx is nginx. The
detailed process:
[root@test2 ~]# tar -zxvf php-7.3.20.tar.gz -C /home/ops
[root@test2 ~]# cd /home /ops/php-7.3.20
installation support package:

[root@test2 /home/ops/php-7.3.20]#
yum install -y  libxml2-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libxslt-devel libzip-devel
./configure --prefix=/home/ops/php --with-fpm-user=nginx --with-fpm-group=nginx --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 --enable-fpm

Compile error, solve the problem:
configure: error: libxml2 not found. Please check your libxml2 installation.
solve: yum install -y libxml2-devel

configure: error: Please reinstall the BZip2 distribution
Solution: yum install -y bzip2-devel

checking for cURL 7.15.5 or greater... configure: error: cURL version 7.15.5 or later is required to compile php with cURL support
Solution: yum install -y curl-devel

configure: error: jpeglib.h not found.
解决:yum install -y libjpeg-devel

configure: error: png.h not found.
Solution: yum install -y libpng-devel

configure: error: freetype-config not foun
Solution: yum install -y freetype-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
Solution: yum install -y libxslt-devel

configure: error: Please reinstall the libzip distribution
Solution: yum install -y libzip-devel

checking for libzip... configure: error: system libzip must be upgraded to version >= 0.11
Solution: The version of libzip needs to be installed greater than 0.11
[root@test2 /home/ops/php-7.3.20]# yum -y remove libzip-devel
[root@test2 /home/ops/php-7.3.20]# cd…
[root@test2 /home/ops]# wget https://libzip.org/download/libzip-1.7.3.tar.gz
[root@test2 /home/ops]# tar -zxvf libzip-1.7.3.tar .gz

Install libzip-1.7.3 requires cmake, first install cmake

wget https://github.com/Kitware/CMake/releases/download/v3.18.1/cmake-3.18.1.tar.gz
tar -zxvf cmake-3.18.1.tar.gz
mv cmake-3.18.1 /home /ops/cmake
yum install gcc-c++
cd /home/ops/cmake
./bootstrap #After the execution, a bin directory will be generated in the current directory, and the cmake execution program
encountered the following error:
gmake: *** [cmStandardIncludes.o] Error 1
--------------------------------------------
Error when bootstrapping CMake:
Problem while running gmake
--------------------------------------------
Log of errors: /root/cmake-2.8.7/Bootstrap.cmk/cmake_bootstrap.log
if you can’t find out where it is The problem, then it may be that the machine memory is too small, causing the following error when compiling (execute twice ./bootstrap can be seen):
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report
Insert picture description here
The error shown above is because the user has insufficient permissions and requires sudo

After solving the error, continue to install cmake:
gmake
gmake install
/home/ops/cmake/bin/cmake --help #A lot of things appear, indicating that the installation was successful

After installing cmake, return to the libzip-1.7.3 directory, ready to continue installing libzip-1.7.3
[root@test2 /home/ops]# cd libzip-1.7.3
[root@test2 /home/ops/libzip-1.7.3 ]# mkdir build
[root@test2 /home/ops/libzip-1.7.3]# cd build
[root@test2 /home/ops/libzip-1.7.3/build]# cmake ..
[root@test2 /home/ops/ libzip-1.7.3/build]# make
[root@test2 /home/ops/libzip-1.7.3/build]# make install (If it is a normal user: sudo make install)

到此libzip-1.7.3就安装完毕了,重新configure php-7.3.20
[root@test2 /home/ops/libzip-1.7.3/build]# cd …/php-7.3.20
[root@test2 /home/ops/php-7.3.20]# ./configure --prefix=/home/ops/php --with-fpm-user=nginx --with-fpm-group=nginx --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 --enable-fpm

configure: error: off_t undefined; check your library configuration
Solution: add four lines as follows:
vim /etc/ld.so.conf #Open the file
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64

Reconfigure php-7.3.20
[root@test2 /home/ops/php-7.3.20]# ./configure --prefix=/home/hahaha/data/server/php --with-fpm-user=nginx- -with-fpm-group=nginx --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 --enable-fpm is
Insert picture description here
successful, then start to compile
make #here encountered a virtual memory problem, now the server memory is 1G, it can be solved by upgrading to 2G or more in the server background
virtual memory exhausted: Cannot allocate memory make: *** [ext/fileinfo/libmagic/apprentice.lo] Error
make install

Configure the establishment directory
[root@test2 /home/ops/php-7.3.20]# cp php.ini-production /home/ops/php/lib/php.ini
[root@test2 /home/ops/php-7.3. 20]# cp /home/ops/php/etc/php-fpm.conf.default /home/ops/php/etc/php-fpm.conf

[root@test2 /home/ops/php-7.3.20]# ln -s /home/ops/php/sbin/php-fpm /usr/local/bin/php-fpm
[root@test2 /home/ops/php-7.3.20]# cd /home/ops/php/etc/php-fpm.d
[root@test2 /home/ops/php/etc/php-fpm.d]# vim www.conf

[www]
listen = 127.0.0.1:9000
listen.mode = 0666

user = nginx
group = nginx

pm = dynamic
pm.max_children = 128
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 10000

rlimit_files = 1024

slowlog = log/$pool.log.slow

[root@test2 /home/ops/php/etc/php-fpm.d]# cd /home/ops/php-7.3.20/sapi/fpm/
[root@test2 /home/ops/php-7.3.20 /sapi/fpm/]# cp php-fpm.service /usr/lib/systemd/system/
[root@test2 /home/ops/php-7.3.20/sapi/fpm/]# systemctl start php-fpm
if available Tip:
Warning: php-fpm.service changed on disk. Run'systemctl daemon-reload' to reload units.
Run and restart php-fpm:
[root@test2 /home/ops/php-7.3.20/sapi/fpm/ ]# systemctl daemon-reload
[root@test2 /home/ops/php-7.3.20/sapi/fpm/]# systemctl start php-fpm
Check the status and confirm the startup status of php-fpm
[root@test2 /home/ops /php-7.3.20/sapi/fpm/]# systemctl status The
correct status of php-fpm should be as shown below: Finished
Insert picture description here
!

Guess you like

Origin blog.csdn.net/weixin_44901564/article/details/108167186