PHP的源码安装与配置

本文详细介绍了如何在Redhat企业6.5版本上下载PHP源码包php-5.6.20.tar.bz2并进行编译安装。通过./configure配置参数,安装依赖,然后配置PHP的php-fpm.conf和php.ini文件,最后复制启动脚本到/etc/init.d目录,以实现PHP的启动。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

PHP的源码安装与配置

PHP源码安装包下载

PHP的源码安装包可以在PHP的官方网站http://www.php.net中下载,本次安装所使用的PHP安装包是php-5.6.20.tar.bz2。使用环境是redhat企业6.5版本。

PHP源码包的编译和安装

PHP的源码包可以根据以下步骤进行编译安装。

[root@server1 ~]# tar jxf php-5.6.20.tar.bz2
[root@server1 ~]# cd php-5.6.20
[root@server1 php-5.6.20]# ./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt  --with-mhash
[root@server1 php-5.6.20]# make
[root@server1 php-5.6.20]# make install

./configure中的参数可以在./configure –help中查看,根据实际情况的不同需要加入不同的参数。
在./configure编译步骤中,需要安装依赖包。

[root@server1 php-5.6.20]# yum install -y libxml2-devel
[root@server1 php-5.6.20]# yum install -y curl-devel
[root@server1 php-5.6.20]# yum install -y gmp-devel
[root@server1 php-5.6.20]# yum install -y net-snmp-devel
# 除此之外还有安装包 libmcrypt-devel、 libmcrypt 、gd-devel安装包系统没有自带,需要网站上下载。

PHP的配置

  • PHP的配置文件
    PHP的配置文件是/usr/local/lnmp/php/etc目录下的php-fpm.conf文件和php.ini文件,这两个文件本身是不存在的,需要复制其他文件。
[root@server1 php]# cp /root/php-5.6.20/php.ini-production /usr/local/lnmp/php/etc/php.ini
[root@server1 php]# vim /usr/local/lnmp/php/etc/php.ini

date.timezone = Asia/Shanghai

[root@server1 php]# cp /usr/local/lnmp/php/etc/php-fpm.conf.default /usr/local/lnmp/php/etc/php-fpm.conf
[root@server1 php]# vim /usr/local/lnmp/php/etc/php-fpm.conf

pid = run/php-fpm.pid
  • 复制启动脚本
    将启动脚本复制到/etc/init.d目录下,并给予可执行权限。
[root@server1 php]# cp /root/php-5.6.20/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@server1 php]# chmod +x /etc/init.d/php-fpm
[root@server1 php]# chkconfig --add php-fpm

PHP启动

至此PHP的源码安装及配置就已经完成,可以启动PHP了,如果需要其他配置,也可以自己修改。

这里写图片描述

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值