Linux学习-手动编译安装php5.4.45

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

安装过程中出现的问题:
问题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
    安装过程
  1. 下载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
  1. 编译安装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
  1. 修改httpd配置文件,让httpd服务器可以解析php文件
#/etc/httpd/httpd.conf
  AddType application/x-h
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值