centos 安装php5.6

1.首先添加依赖应用
yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel

这一步是为了支持一些PHP运行的东西,还有以下编译需要的

2.安装加密扩展库
cd /usr/local/src/
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install

3.到PHP压缩包存放的目录下

tar zxvf PHP-5.6.8.tar.gz #解压
cd PHP-5.6.8 #进入文件

运行

[root@VPS PHP-5.6.8]# ./configure --prefix=/usr/local/PHP --with-apxs2=/usr/local/apache/bin/apxs --with-MysqL=/usr/local/MysqL --with-MysqL-sock --with-MysqLi=/usr/local/MysqL/bin/MysqL_config --enable-fpm --with-ncurses --enable-soap --with-libxml-dir --with-XMLrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --disable-mbregex --disable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-pdo-MysqL --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-MysqLnd-compression-support --with-pear

这一步不能有错误,警告可能会有,是说某些包不能识别之类的,一般没有很大问题(根据自己需要的进行删减 这段--with-apxs2=/usr/local/apache/bin/apxs要有,apache关联有用)

执行

make

显示

Build complete.
Don't forget to run 'make test'.

说明成功

编译PHP5.6 make 时出现错误

make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

解决办法

这是由于内存小于1G所导致.

在./configure加上选项:

--disable-fileinfo

disable fileinfo support 禁用 fileinfo

make install

最后就是配置apache让它支持PHP


修改apache的配置文件httpd.conf

vi /usr/local/apache/conf/httpd.conf

然后在文本最后面添加

LoadModule PHP5_module modules/libPHP5.so

AddType application/x-httpd-PHP .PHP

(注意,在apache安装目录下,modules下有libPHP5.so,这是PHP安装时添加进去的,如果没有,PHP,你需要重装下

生成libPHP5.so文件的是./configure中的这段代码--with-apxs2=/usr/local/apache/bin/apxs,路径要和你安装的路径对应

)
接下来复制PHP启动文件
cp PHP-5.6/PHP.ini-development /usr/local/PHP/lib/PHP.ini

保存,重新启动

service httpd start

如果没有报错则说明启动成功 测试PHP是否安装成功 写一个简单的PHP页面 <?PHP PHPinfo(); ?>

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native