centos7安装PHP


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>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值