1.首先安装依赖
yum -y install curl-devel libpng libpng-devel libjpeg-devel libcurl libcurl-devel openssl openssl-devel bzip2 libxml2 libxml2-devel freetype-devel gnutls-devel guntls nettle-devel bzip2-devel
2.在编译php时可能会出现libzip版本过低:configure: error: Please reinstall the libzip distributio 或 configure: error: system libzip must be upgraded to version >= 0.11。
解决方法:
curl -O https://libzip.org/download/libzip-1.5.1.tar.gz
tar -zxvf libzip-1.5.1.tar.gz
cd libzip-1.5.1
mkdir build
cd build
cmake .. (#注意:cmake后面有两个小数点)
(上一步可能会出现错误,说是cmake版本低,安装cmake3就好)
【yum install cmake3 然后cmake3 ..】)
make && make install
3.上一步完成后可能还会报错error: off_t undefined; check your library configuration
解决方法:
vim /etc/ld.so.conf
#添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
#保存退出
:wq
ldconfig -v # 使之生效
4.编译安装PHP
wget https://www.php.net/distributions/php-7.3.19.tar.gz
如果链接失效:去官网查看可用的源码包:https://www.php.net/downloads.php
tar -zxvf php-7.3.19.tar.gz
cd php-7.3.19
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --enable-sockets --enable-pdo --enable-fpm --enable-cli --enable-mbstring --enable-pcntl --enable-soap --enable-opcache --enable-fileinfo --disable-rpath --with-mysqli --with-pdo-mysql --with-iconv-dir --with-openssl --with-fpm-user=www --with-fpm-group=www --with-curl --with-mhash --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-zip --with-zlib --enable-simplexml --with-libxml-dir --enable-json --with-apxs2=/usr/local/apache/bin/apxs
注意:加载--with-apx2=$PATH 用来加载libphp7.so模块
make && make install
(重新编译时,需要使用命令make clean)
5.配置环境变量
vim /etc/profile
最后一行添加
export PATH=$PATH:/usr/local/php/bin
然后重新加载
source /etc/profile
6.结合Apache支持PHP环境
在http.conf文件中添加
LoadModule php7_module modules/libphp7.so
<IfModule dir_module>
DirectoryIndex index.html index.php #(只需加入index.php)
</IfModule>
#最后一行添加
<IfModule mod_php7.c>
AddType application/x-httpd-php .php
</IfModule>

2169

被折叠的 条评论
为什么被折叠?



