LAMP环境搭建与配置(三)

六 安装PHP5

PHP官网www.php.net

当前主流版本为5.6/7.1

1)下载cd /usr/local/src/

wget http://cn2.php.net/distributions/php-5.6.32.tar.gz

2)解压tar zxf php-5.6.32.tar.gz

3)编译cd php-5.6.32

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --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

 

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

解决:yum install –y libxml2-devel

继续编译报错2:configure: error: Cannot find OpenSSL's <evp.h>

解决:yum install –y openssl-devel

继续编译有报错3:checking for BZip2 in default path... not found

configure: error: Please reinstall the BZip2 distribution

解决:yum install -y bzip2-devel

继续编译报错4:If configure fails try --with-vpx-dir=<DIR>

checking for jpeg_read_header in -ljpeg... yes

configure: error: png.h not found.

解决:yum install –y libpng-devel

继续编译又出错5:If configure fails try --with-xpm-dir=<DIR>

configure: error: freetype-config not found.

解决:yum install -y freetype-devel

继续编译又出错6:configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决:yum install -y libtomcrypt-devel

如果之前没有安装epel,现在要安装yum install -y epel-release

centos默认yum源没有libtomcrypt-devel这个包,所以稚嫩个借助epel yum扩展源。

继续编译成功。

4)安装

#make && make install

5)查看安装后的文件

/usr/local/php/bin/php –m下的模块都是静态的。

php和Apache结合起来是通过libphp.so文件实现的。

/usr/local/apache2.4/bin/httpd –M查看Apache的模块,发现下面有了php5_module (shared)

命令/usr/local/php/bin/php -i |less可以查看PHP的一些信息

cp php.ini-production /usr/local/php/etc/php.ini

php.ini-production是生产环境,php.ini-development是开发环境,拷贝生产环境就可以了。

自动加载了。

七 安装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

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

make

make install

ls /usr/local/apache2.4/modules/libphp7.so

/usr/local/apache2.4/bin/apachectl –M

vim /usr/local/apache2.4/conf/httpd.conf

不用哪个可以注释掉

cp php.ini-production /usr/local/php7/etc/php.ini

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值