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
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'.
说明成功
【
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
解决办法
这是由于内存小于1G所导致.
在./configure加上选项:
--disable-fileinfo
Disable fileinfo support 禁用 fileinfo
】
make install
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