php5 安装,安装 PHP5

1ef47776e2fc00d047d2aed36c633748.png

安装方法大同小异,首先下载5.6的安装包,使用到的命令如下:

cd /usr/local/src/

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

tar -zxvf php-5.6.36.tar.gz

cd php-5.6.36/

./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

7742b0a04ecd4f70c34b85f7979a64f7.png

安装包 php-5.6.36.tar.gz 下载完毕,然后进行解压,输入命令 tar -zxvf php-5.6.36.tar.gz,回车,内容较多,不截图。然后进行编译,见下图,

a499482b54c3f6a599e59801f60494a4.png

回车,内容较多,截取最后一屏,见下图,

97e19b571f50e8a2ca082223eddf518c.png

出现报错,configure: error: xml2-config not found. Please check your libxml2 installation. 显示需要安装 libxml2,具体操作见下图,

d23c2d2e7bacc5f89cb6be032f599131.png

74eae08864b145bfc161ac078156aca5.png

安装完成之后,继续输入刚才的命令 ./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 ,回车,

3232810312fb67b52ab6f762d886cbca.png

又出现报错,configure: error: Cannot find OpenSSL's ,显示需要安装 openssl-devel,输入命令 yum install -y openssl-devel,回车。内容较多,不截图了。安装完成之后,继续执行命令 ./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 ,回车,

ea128c8b4f438c42e08480f5fe5c950e.png

又出现报错,configure: error: Please reinstall the BZip2 distribution,显示需要安装 bzip2-devel 这个包,输入命令 yum install -y bzip2-devel,回车,

36e18ea687d6562003f68ac395f2e40e.png

安装完成之后,再次执行命令,见下图,

915fb48e9141a48f9aed8b59489b9778.png

又出现报错,configure: error: jpeglib.h not found. 显示需要安装 libjpeg-devel 这个包,输入命令 yum install -y libjpeg-devel,回车,

59881e92465e23876bbb99eb26948de4.png

安装完成之后,再次执行命令,见下图,

ca88b8b9e58dfa4ed53f2f158584c251.png

又出现报错,configure: error: png.h not found. 显示需要安装 libpng-devel 这个包,输入命令 yum install -y libpng-devel,回车,

52fb263b89a366019271bea6eda0653a.png

安装完成之后,再次执行命令,见下图,

05a3f1c7d30aa613941c554638ccda4b.png

又出现报错,configure: error: freetype-config not found. 显示需要安装 freetype-devel 这个包,输入命令 yum install -y freetype-devel,回车,

4273e53bbebc7a95c7ebea22f200caa8.png

68f74d32f7e22c318088c7ecd70f0ad8.png

安装完成之后,再次执行命令,见下图,

76711d13895070620d28d1f1d2f17fb9.png

又出现报错,configure: error: mcrypt.h not found. Please reinstall libmcrypt. 显示需要安装 libmcrypt-devel 这个包,安装这个包之前,需要先安装一个扩展源,输入命令 yum install -y epel-release,回车,显示已安装,接着输入命令 yum install -y libmcrypt-devel,回车,

9b2575ab555dd70abae211a8cb3ed479.png

11412c6485be59b0e2ec84796c5c54b1.png

安装完成之后,再次执行命令,见下图,

ed75d3d5d028a6ee30d75af90a3f467c.png

可以看到,这次就成功了,没有出现报错。使用命令 echo $? 查看,是对的。接着使用 make 命令,见下图,

13514b9a6e6c988ed00cb483ea5cbdce.png

make 这个命令需要执行的时间比较长,没有出现错误,就执行命令 make install ,回车,

2e91ca19e04991acd1982570304b167c.png

72e9a3a826afceb41a920bd65e1223dc.png

接着来看一下 PHP 的目录,见下图,

ea86270129299dd592ae83f98f64b01f.png

核心的二进制文件在目录 /usr/local/php/bin/ 下面,里面的 php 文件大小是36M,很大。再查看文件 /usr/local/apache2.4/modules/libphp5.so 的大小也是36M,这个就是我们想要的扩展模块。接着来查看一下php所加载的模块有哪些,见下图,

3ef171d2a25b7eba22401801d1547e23.png

查看所加载的模块的命令,全部都是静态的,也能够扩展模块安装。

2925f5400acf4a3fac448396a8f6a9ad.png

回车,进入文件httpd.conf,可以看到很多#注释的模块,

c9a3da0744bf09be0c4e2a6ed806b89a.png

这边比较方便的地方是,想启用模块,就把前面的#去掉并保存。想停掉模块,就在前面加上#保存。输入 :q!,回车强行退出。

接着可以输入命令 /usr/local/php/bin/php -i |less,回车查看,

bd6fad1acc4d03e0d57e45aec906ef2f.png

可以看到一些 php 的信息。

因为目录 /usr/local/php/etc 下面没有 php.ini 文件,所以需要在php源码包的根目录下拷贝,见下图,

e72d7a714d2ba9dc661c40039893b6dc.png

回车,

c207be559d6f4c76fd96433b1586a57b.png

这时候就能看到,/usr/local/php/etc/php.ini 加载上去了,可以对前面没有加载的图片,显示的是 none 。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值