安装过程中出现的问题:
问题1
configure: error: Please reinstall the BZip2 distribution
解决方法:
[root@lotus php-5.4.45]# yum install -y bzip2-devel
问题2
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决方法:
https://sourceforge.net/projects/mcrypt/下载libmcrypt
编译安装libmcrypt即可
在web服务器中,PHP的三种运行方式:
- CGI
- 模块
- FastCGI
安装过程
- 下载php5.4.45,并解压
[root@lotus ~]# wget https://www.php.net/distributions/php-5.4.45.tar.gz
[root@lotus ~]# tar xf php-5.4.45.tar.gz
[root@lotus ~]# cd php-5.4.45
- 编译安装php
参数介绍:
–prefix:安装目录
–with-mysql:mysql的安装目录
–with-openssl:支持openssl
–with-mysqli:mysql与php的交互接口
–enable-mbstring:支持多语言
–with-freetype-dir:支持freetye
–with-jpeg-dir:支持jpeg
–with-png-dir:支持png
–with-zlib:支持压缩,让文件先压缩再传送
–with-libxml-dir:支持xml,并指定xml的目录
–enable-xml:
–enable-sockets:支持套接字
–with-apxs2:让php编译成apache模块
–with-mcrypt:支持加密
–with-config-file-path:php配置文件存放目录
–with-config-file-scan:配置文件扫描
–with-bz2:支持bz2压缩
–enable-maintainer-zts:支持apache的worker或event两个MPM,如使用prefork,则此项不用
–enable-fpm:启用FastCGI,与enable-maintainer-zts互斥
[root@lotus php-5.4.45]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts
[root@lotus php-5.4.45]# make && make install
#安装完成后,拷贝配置文件至/etc/php.ini
[root@lotus php-5.4.45]# cp php.ini-production /etc/php.ini
- 修改httpd配置文件,让httpd服务器可以解析php文件
#/etc/httpd/httpd.conf
AddType application/x-h

本文详细记录了PHP安装过程中遇到的两个问题:BZip2和libmcrypt缺失,以及如何通过yum和源码编译解决。还介绍了PHP的CGI、模块和FastCGI运行方式,包括编译参数、配置Apache和压力测试步骤。
最低0.47元/天 解锁文章
1912

被折叠的 条评论
为什么被折叠?



