***********安装php*******************
1,包:php-5.4.26.tar.bz2 xcache-3.0.3.tar.bz2 phpMyAdmin-4.0.5-all-languages.zip
依赖包安装(X Software Development )
yum groupinstall "Desktop Platform Development" -y
2,如果想让编译的PHP支持mcrypt,还需要安装
yum -y install libmcrypt-2.5.7.e15.i386.rpm
yum -y install libmcrypt-devel-2.5.7-5.e15.i386.rpm
安装epel YUM源
rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum -y install libmcrypt-devel
3,解压安装php
./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
如果为了Apache支持works或event这两个MPM,编译时需要使用--enable-maintainer-zts
如果使用PHP5.3以上的版本,为了链接mysql数据库,可以指定mysqlnd,
这样在本机就不需要安装mysql或者mysql开发包了,mysqlnd从php5.3开始可以使用,
可以编译时绑定他(而不是和具体的mysql客户端库绑定形成依赖),
但从php5.4开始它就是默认设备了
见招拆招:
configure: error: Cannot find OpenSSL‘s <evp.h>
安装openssl-devel,bzip2-devel
如果php和mysql不在一台服务器:
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysqli=mysqlnd
4,配置
cp php.ini-production /etc/php.ini
vi /etc/httpd24/httpd.conf
检查有没有LoadModule php5_module modules/libphp5.so
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
后加两行:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
修改一行,加 index.php
DirectoryIndex index.php index.html #次序很关键
重新载入httpd
rpm包安装的话会在/etc/httpd/conf.d/下生成php.conf,编译的话不会生成的,需要自己写
5,验证
<?php
phpinfo();
?>