php 7.4.13 编译安装

说明

php将要安装的目录:/alidata/server/php74

apache 的apxs 目录:/alidata/server/httpd/bin/apxs

下载PHP

wget https://www.php.net/distributions/php-7.4.13.tar.gz

解压

tar -zxf php-7.4.13.tar.gz

进入解压后的目录

cd php-7.4.13

生成makefile文件
./configure --prefix=/alidata/server/php74 \
--with-config-file-path=/alidata/server/php74/etc  \
--with-apxs2=/alidata/server/httpd/bin/apxs \
--enable-mbstring \
--with-openssl \
--enable-ftp \
--enable-gd \
--with-freetype \
--with-jpeg \
--with-webp \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pear \
--enable-sockets \
--enable-libxml \
--with-xmlrpc \
--with-zip \
--enable-fpm \
--enable-xml \
--enable-sockets \
--enable-gd \
--with-iconv \
--enable-soap \
--enable-pcntl \
--enable-cli \
--enable-static \
--with-mcrypt  \
--with-curl 
编译

make ZEND_EXTRA_LIBS='-liconv' 或 make ZEND_EXTRA_LIBS='-liconv' -j2

-j2 看你服务器cpu有几个核心 查看命令 cat /proc/cpuinfo | grep processor | wc -l
安装

make install

复制php.ini

cp ./php.ini-production /alidata/server/php74/etc/php.ini

修正 php.ini

sed -i 's#; extension_dir = "./"#extension_dir = "/alidata/server/php/lib/php/extensions/no-debug-non-zts-2019090/2/"#' /alidata/server/php74/etc/php.ini
sed -i 's/post_max_size = 8M/post_max_size = 64M/g' /alidata/server/php74/etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 64M/g' /alidata/server/php74/etc/php.ini
sed -i 's/;date.timezone =/date.timezone = PRC/g' /alidata/server/php74/etc/php.ini
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/g' /alidata/server/php74/etc/php.ini
sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /alidata/server/php74/etc/php.ini

重启apache

systemctl restart httpd

额外

安装GD (其他扩展也并不多类似)

切换到指定目录

cd php-7.4.13/ext/gd

用phpize工具生成configure文件

bash ../../scripts/phpize

生成makefile文件

./configure --with-php-config=/alidata/server/php74/bin/php-config

编译&安装

make && make install

nstalling shared extensions: /alidata/server/php74/lib/php/extensions/no-debug-non-zts-20190902/
Installing header files: /alidata/server/php74/include/php/

在php.ini 添加 extension = /alidata/server/php74/lib/php/extensions/no-debug-non-zts-20190902/

zip 有可能找不到 libzip

#卸载老版本的libzip
yum remove libzip
#下载安装libzip-1.2.0 wget https://hqidi.com/big/libzip-1.2.0.tar.gz
wget https://libzip.org/download/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install
最后修改:2021 年 03 月 02 日 02 : 57 PM
如果觉得我的文章对你有用,请随意赞赏