CentOS编译安装PHP

下载 wget https://www.php.net/distributions/php-7.4.6.tar.gz

解压缩包 tar zxf php-7.4.6.tar.gz

进入源码目录 cd php-7.4.6

编译安装 ./configure --prefix=/usr/local/php --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-fpm --with-fpm-user=nobody --with-fpm-group=nobody --with-openssl --with-zlib --with-curl --enable-mbstring --with-mysqli --with-jpeg --with-webp --with-freetype --enable-gd --with-iconv-dir --enable-exif --with-zip && make && make install

安装过程中可能出现的报错以及解决办法

configure: error: in `/root/php-7.4.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

解决办法 yum install gcc

configure: error: Package requirements (libxml-2.0 >= 2.7.6) were not met:
Package 'libxml-2.0', required by 'virtual:world', not found

解决办法 yum install libxml2-devel

configure: error: Package requirements (openssl >= 1.0.1) were not met:
Package 'openssl', required by 'virtual:world', not found

解决办法 yum install openssl-devel

configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
Package 'sqlite3', required by 'virtual:world', not found

解决办法 yum install sqlite-devel

configure: error: Package requirements (libcurl >= 7.15.5) were not met:
Package 'libcurl', required by 'virtual:world', not found

解决办法 yum install curl-devel

configure: error: Package requirements (libpng) were not met:
Package 'libpng', required by 'virtual:world', not found

解决办法 yum install libpng-devel

configure: error: Package requirements (libwebp) were not met:
Package 'libwebp', required by 'virtual:world', not found

解决办法 yum install libwebp-devel

configure: error: Package requirements (libjpeg) were not met:
Package 'libjpeg', required by 'virtual:world', not found

解决办法 yum install libjpeg-devel

configure: error: Package requirements (freetype2) were not met:
Package 'freetype2', required by 'virtual:world', not found

解决办法 yum install freetype-devel

configure: error: Package requirements (oniguruma) were not met:
Package 'oniguruma', required by 'virtual:world', not found

解决办法

yum install oniguruma
wget http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-1.el8.x86_64.rpm
rpm -ivh oniguruma-devel-6.8.2-1.el8.x86_64.rpm

configure: error: Package requirements (libzip >= 0.11) were not met:
Package 'libzip', required by 'virtual:world', not found

解决办法 yum install libzip-devel

cc: fatal error: Killed signal terminated program cc1
compilation terminated.
make: *** [Makefile:690: ext/date/lib/parse_date.lo] Error 1

解决办法

1.增加服务器内存;
2.使用虚拟内存(SWAP分区):
fallocate -l 1024M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap sw 0 0" >> /etc/fstab

发表评论

电子邮件地址不会被公开。 必填项已用*标注