源码配置PHP7.4

一、php安装准备环境

系统:CentOS Linux release 7.7.1908 
PHP:php-7.4.6

二、安装PHP依赖包

    yum install gcc 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

三、官网下载7.4tar软件包

https://www.php.net/distributions/
源码配置PHP7.4

tar -xzf php-7.4.6.tar.gz
cd php-7.4.6
./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fpm --with-fpm-user=www  --with-fpm-group=www --enable-inline-optimization --disable-debug --disable-rpath --enable-shared  --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir  --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets  --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache.

源码配置PHP7.4
编译报错:No package 'oniguruma' found :
解决方法:

yum install http://rpms.remirepo.net/enterprise/7/remi/x86_64//oniguruma5-6.9.4-1.el7.remi.x86_64.rpm
yum install http://rpms.remirepo.net/enterprise/7/remi/x86_64//oniguruma5-devel-6.9.4-1.el7.remi.x86_64.rpm 

继续编译:

make
make install

编译完成之后,我们添加PHP命令到环境变量里

vim  /etc/profile

在文件末尾加入:

PATH=$PATH:/usr/local/php/bin
export PATH

要使改动立即生效执行

source /etc/profile

查看PHP 版本

php -v

配置php:

cp php.ini-production /etc/php.ini 
cp  /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf
cp /usr/src/php-7.4.6/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

chkconfig  --add   php-fpm
chkconfig php-fpm on

四、php-fpm.conf是php服务程序重要的配置文件之一,我们需要启用该配置文件中第25行左右的pid文件保存目录,然后分别将第148和149行的user与group参数分别修改为www账户和用户组名称:
源码配置PHP7.4

4、安装完成以后,启动服务

 systemctl enable php-fpm.service
 systemctl start php-fpm.service

猜你喜欢

转载自blog.51cto.com/11353391/2497307