11.10/11.11/11.12 安装PHP5 11.13 安装PHP7

本文详细介绍了如何从源码编译安装PHP5及解决过程中遇到的各种依赖问题,并提供了安装PHP7的步骤,包括配置参数说明及所需依赖库。

安装php5

一.下载:

wget  http://cn2.php.net/distributions/php-5.4.45.tar.bz2

二.解压

tar -jxvf php-5.4.45.tar.bz2         

三.配置编译参数:

[root@localhost src]# cd php-5.4.45
[root@localhost php-5.4.45]# ./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-config-file-path=/usr/local/php/etc  \
--with-mysql=/usr/local/mysql \
--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 \
--disable-ipv6

在这一步,遇到如下错误:
configure: error: xml2-config not found. Please check your libxml2 installation.

解决办法是:

yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel

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

解决办法是:
yum install -y openssl openssl-devel

错误:
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

解决办法:
yum install -y bzip2 bzip2-devel

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

解决办法:
yum install -y libpng libpng-devel

错误:
configure: error: freetype.h not found.

解决办法:
yum install -y freetype freetype-devel

错误:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决方法:

cd .. 退出当前目录
下载地三方源

wget  http://www.atomicorp.com/installers/atomic
sh ./atomic    \\运行脚本

然后在安装3个依赖包
yum install php-mcrypt libmcrypt libmcrypt-devel
错误:
configure: error: jpeglib.h not found.
解决方法:
yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel -y

或者安装一个yum扩展包yum install -y epel-release

在重新编译一下 。
二:编译
#make
#eshop $?
三:编译安装
#makeinstall
#eshop $?

四:拷贝PHP的配置文件:

#cp/usr/local/src/php-5.4.36/php.ini-production /usr/local/php/etc/php.ini

下面是 编译时的一些参数
--with-apxs2=/usr/local/apache2/bin/apxs 这个工具是自动帮助我们安装扩展模块的,它会生成一个动态模块在apache2/modules

--with-mysql=/usr/local/mysql php也是依赖mysql的,所以要先安装mysql。apache然后在安装PHP;mysql和apache可以颠倒。

小技巧 /usr/local/php/bin/php 是执行文件 和 /usr/local/apache2/bin/apachectl 一样
/usr/local/php/bin/php -m 查看php模块

这些是静态模块;动态模块需要我们自己去编译


安装php7

• cd /usr/local/src/
• wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
• tar zxf php-7.1.6.tar.bz2
安装一个扩展源:yum install -y epel-release.noarch
如果没有包,yum install -y bzip2-devel libjpeg-turbo-devel libpng-devel freetype-devel libtomcrypt-devel openssl-devel php-mcrypt libmcrypt libmcrypt-devel gcc libtool-ltdl-devel expat-devel pcre-devel libxml2-devel libcurl-devel perl-Data-Dumper libaio bzip2

• cd php-7.1.6
• ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/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 (--enable-pdo --enable-mysqlnd )这2个参数先暂时不加,需要研究
• make && make install
• ls /usr/local/apache2.4/modules/libphp7.so
• cp php.ini-production /usr/local/php7/etc/php.ini

转载于:https://my.oschina.net/u/3866516/blog/1921876

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值