Centos source package to install PHP

Install PHP from source package under Centos

1. Download the source code package from the
PHP official website http://php.net/downloads.php

wget  https://www.php.net/distributions/php-7.4.7.tar.bz2

2. Installation dependencies

yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel sqlite-devel php-mysqli

2.1 Install libmcrypt

cd /usr/local/src  
# 下载libmcrypt
wget https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install

ln -s   /usr/local/bin/libmcrypt_config   /usr/bin/libmcrypt_config
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

2.2 Install mhash

cd /usr/local/src
# 下载mhash(安装mcrypt需要此软件包)
wget https://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
tar -zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make && make install

2.3 Install mcrypt

cd /usr/local/src
# 下载mcrypt
wget https://nchc.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
./configure
make
make install

3. Install PHP

tar -zxvf php-7.4.7.tar.bz2
cd php-7.4.7
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql-sock=/tmp/mysql.sock --with-apxs2=/usr/local/apache2/bin/apxs  --enable-mysqlnd --with-mysqli
make && make install

cd /usr/local/sbin
ln -s /usr/local/php/bin/php php
ln -s /usr/local/php/bin/php /usr/local/bin/php

Insert picture description here

After the installation is complete, you need to modify the php.ini-production of the decompressed installation package to php.ini and move it to /usr/local/php/etc

4. Install the mysqli extension

# 找到php-7.4.7 ext目录下的mysqli
# 输入 
/usr/local/php/bin/phpize

# 在mysqli文件夹下执行 
./configure --with-php-config=/usr/local/php/bin/php-config --with-mysqli=/usr/bin/mysql_config   

make 
make install

al/php/bin/php-config --with-mysqli=/usr/bin/mysql_config

make
make install

Guess you like

Origin blog.csdn.net/ichen820/article/details/114696117