LAMP架构——PHP-7.1.6源码编译安装

说明

一个apache服务器内可以同时安装php5和php7,但是只能运行其中一个,另外一个需要注释掉apache配置文件内对应的LoadModule


1,下载并安装

[root@dl-001 src]#  wget http://cn2.php.net/distributions/php-7.1.6.tar.gz
[root@dl-001 src]#  tar -zxvf php-7.1.6.tar.gz
[root@dl-001 src]#  cd php-7.1.6

2,初始化

[root@dl-001 php-7.1.6]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif 

说明:php7内已经移除了–with-mysql参数

错误1
configure: error: xml2-config not found. Please check your libxml2 installation.

说明:缺少xml2库。

解决办法:
[root@dl-001 php-5.6.30]# yum list |grep libxml2        //查找相关的库安装包
[root@dl-001 php-5.6.30]# yum install -y libxml2-devel  //安装库文件

错误2
configure: error: Cannot find OpenSSL's <evp.h>

说明:缺少OpenSSL’s。

解决办法
[root@dl-001 php-5.6.30]# yum install -y openssl-devel

错误3
configure: error: Please reinstall the BZip2 distribution

说明:重新安装BZip2。

解决办法
[root@dl-001 php-5.6.30]# yum install -y bzip2-devel

错误4
configure: error: jpeglib.h not found.

说明:缺少jpeg库。

解决办法
[root@dl-001 php-5.6.30]# yum install -y libjpeg-devel

错误5
configure: error: png.h not found.

说明:缺少png库。

解决办法
[root@dl-001 php-5.6.30]# yum install -y libpng-devel

错误6
configure: error: freetype-config not found.

说明:缺少freetype库。

解决办法
[root@dl-001 php-5.6.30]# yum install -y freetype-devel

错误7
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

说明:缺少mcrypt库。

解决办法
[root@dl-001 php-5.6.30]# yum install epel-release
[root@dl-001 php-5.6.30]# yum install -y libmcrypt-devel

3,编译安装

[root@dl-001 php-7.1.6]# make           //编译
[root@dl-001 php-7.1.6]#  make install          //安装

PHP说明:

查看apache生成php7模块
[root@dl-001 src]# ls /usr/local/apache2.4/modules/libphp7.so

查看php7所加载的模块
[root@dl-001 src]#  /usr/local/php7/bin/php -m

apache服务器可以存在2种版本的php,通过在apache的配置文件中注释掉相应的行来关闭某个版本的php模块
[root@dl-001 src]#  vim /usr/local/apache2.4/conf/httpd.conf

在LoadModule行前加#注释

编译 ./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --bindir=/usr/local/php/bin --sbindir=/usr/local/php/sbin --includedir=/usr/local/php/include --libdir=/usr/local/php/lib/php --mandir=/usr/local/php/php/man --with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr /i nclude --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=www --with-fpm-group=www --without-gdbm --with-mcrypt=/usr/local/apps/libmcrypt --disable-fileinfo 报错:1, **configure: error: system libzip must be upgraded to version >=**0.11。 使用Yum最新版只到0.10,不足以达到要求。 一、先删除libzip yum remove libzip -y SSH执行以上命令,先删除libzip 和 libzip-devel 二、下载安装并手动编译 wget https://nih.at/libzip/libzip-1.2.0.tar.gz tar -zxvf libzip-1.2.0.tar.gz cd libzip-1.2.0 ./configure make && make install 三、(可忽略)另外最新版本请参考官网:https://nih.at/libzip/ 1.5.0的libzip需要cmake wget https://libzip.org/download/libzip-1.5.0.tar.gz tar -zxvf libzip-* cd libzip* mkdir build && cd build && cmake .. && make && make install 报错2: error: off_t undefined; check your library configuration 根据报错信息分析 configure: error: off_t undefined; check your library configuration 未定义的类型 off_t。 off_t 类型是在 头文件 unistd.h中定义的,在32位系统 编程成 long int ,64位系统则编译成 long long int ,这里题主的系统应该是 64位的吧,在进行编译的时候 是默认查找64位的动态链接库,但是默认情况下 centos 的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,这个时候需要将 /usr/local/lib64 /usr/lib64 这些针对64位的库文件路径加进去。 采用下面的方法。 添加搜索路径到配置文件 echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值