- php版本: 7.4.4
- yum install:
yum 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 libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
- 解压:
tar zxvf php-7.4.4.tar.gz
https://www.php.net/distributions/php-7.4.4.tar.gz
cd php-7.4.4/
./configure --with-libdir=lib64 --prefix=/usr/local/php --with-mysql --with-mysqli --with-pdo-mysql --enable-inline-optimization --enable-fpm --with-freetype-dir --with-gd --with-zlib --with-png-dir --with-jpeg-dir --enable-mbstring --with-iconv --enable-sockets --with-curl --with-mcrypt --with-openssl --enable-pcntl --enable-soap --with-libxml-dir --with-config-file-path=/usr/local/php/etc --enable-fd-setsize=131072
此过程可能报错:- error:
configure: error: Package requirements (sqlite3 > 3.7.4) were not met: Package 'sqlite3', required by 'virtual:world', not found
- 解决:
yum install sqlite-devel
- 解决:
- error:
configure: error: Package requirements (oniguruma) were not met: Package 'oniguruma', required by 'virtual:world', not found
- 原因:在centos8中需要 oniguruma
- 解决:
- 下载 oniguruma-6.9.4.tar.gz
wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
tar -zxvf oniguruma-6.9.4.tar.gz
cd oniguruma-6.9.4/
yum -y install autoconf automake libtool
./autogen.sh
./configure --prefix=/usr --libdir=/lib64 //64位的系统一定要标识 --libdir=/lib64 否则还是不行
make
make install
- error:
make
make install
- 设置环境变量: 在
/etc/profile
文件增加:export PATH=/usr/local/php/bin/:$PATH export PATH=/usr/local/php/sbin/:$PATH
- 文件立即生效:
source /etc/profile
- 文件立即生效:
- 从源码中复制
php.ini
文件php.ini.product
文件到/usr/local/php/etc/php.ini
cp php.ini.product /usr/local/php/etc/php.ini
- 测试php是否安装成功:
php -v