linux 安装php5.4,linux编译安装php5.4

下载

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

解压

tar zxvf php-5.4.44.tar.gz

提前安装一些依赖包

yum install -y libjpeg-devle libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel epel-release libmcrypt

yum install -y libmcrypt-devel

配置编译参数:

cd php-5.4.44

./configure \

--prefix=/u01/php \

--with-apxs2=/u01/apache2/bin/apxs \

--with-config-file-path=/u01/php/etc \

--with-mysql=/u01/mysql \

--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 \

--disable-ipv6

可能出现的错误及解决办法

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

解决办法是:

yum install -y libxml2-devel

还有错误:

configure: error: Cannot find OpenSSL's

解决办法是:

yum install -y openssl openssl-devel

错误:

checking for BZip2 in default path... not found

configure: error: Please reinstall the BZip2 distribution

解决办法:

yum install -y bzip2 bzip2-devel

错误:

configure: error: png.h not found.

解决办法:

yum install -y libpng libpng-devel

错误:

configure: error: freetype.h not found.

解决办法:

yum install -y freetype freetype-devel

错误:

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决办法:

yum install -y epel-release

yum install -y libmcrypt-devel

因为 centos6 默认的 yum 源没有 libmcrypt-devel 这个包,只能借助 epel 的 yum 源。

make&&make install

拷贝 php 配置文件:

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

修改 apache 配置文件

vi /usr/local/apache2/conf/httpd.conf

找到:

Options FollowSymLinks

AllowOverride None

Order deny,allow

Deny from all

改为:

Options FollowSymLinks

AllowOverride None

Order deny,allow

Allow from all

说明:如果不修改这个地方,我们访问网站会禁止访问,显示 403。

然后找到:

AddType application/x-gzip .gz .tgz

在该行下面添加:

AddType application/x-httpd-php .php

说明,要想支持 php 脚本解析,必须要加上对应的类型。

再找到:

DirectoryIndex index.html

将该行改为:

DirectoryIndex index.html index.htm index.php

说明: 增加针对 php 的索引,如果一个站点默认页为 index.php,那么就得加上这个

index.php 的支持。

再找到:

#ServerName www.example.com:80

修改为:

ServerName localhost:80

如果不去掉#,则启动 apache 时,会有警告信息“httpd: Could not reliably determine the

server's fully qualified domain name, using localhost.localdomain for ServerName”,看起来像是

错误,其实没有影响。

查看配置文件是否有问题:

/usr/local/apache2/bin/apachectl -t

如果显示 Syntax OK,说明配置没问题了。然后启动服务:

/usr/local/apache2/bin/apachectl start

检查 apache 是否正常启动的命令是:

ps aux |grep httpd

看有没有进程列表。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值