PHP官网www.php.net
当前主流版本为5.6/7.1
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
tar zxf php-5.6.30.tar.gz
cd php-5.6.30
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --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
--prefix= 指定安装目录 --with-apxs2=Apache的工具,不需要人工的干涉,自动的把扩展模块放到modules模块里,并且在配置文件里加一行loadmoduls,能够httpd -M的时候把模块加载出来。所以要先安装Apache,要指定这个工具地址
make && make install
cp php.ini-production /usr/local/php/etc/php.ini //配置文件路径/usr/local/php/etc因为这下面是空的(开发环境可使用php.ini-development)
/usr/local/php/bin/php -i|less //查看php相关信息
Loaded Configuration File => /usr/local/php/etc/php.ini
ls /usr/local/php/bin/ //php核心二进制文件
pear peardev pecl phar phar.phar php php-cgi php-config phpize
du -sh /usr/local/apache2.4/modules/libphp5.so //php扩展模块。Apache需要
37M /usr/local/apache2.4/modules/libphp5.so
/usr/local/php/bin/php -m //查看加载的模块有哪些(显示静态文件,也可动态扩展模块安装)
[root@lsx-001 php-5.5.38]# du -sh /usr/local/php
77M /usr/local/php
[root@lsx-001 php-5.5.38]# du -sh /usr/local/apache2/modules/libphp5.so
35M /usr/local/apache2/modules/libphp5.so Apache结合php依赖libphp5
[root@lsx-001 php-5.5.38]# /usr/local/php/bin/php –m 查看加载的模块(静态的)
[PHP Modules]
bz2
Core
ctype
date
Apache配置文件
[root@lsx-001 php-5.5.38]# vi /usr/local/apache2/conf/httpd.conf
错误:
1.error: xml2-config not found. Please check your libxml2 installation.
解决办法:
yum list|grep libxml2
yum install -y libxml2-devel.x86_64
2.error: Cannot find OpenSSL's <evp.h>
yum list|grep OpenSSL -i
yum install -y openssl-devel.x86_64
3.error: Please reinstall the BZip2 distribution
yum install -y bzip2-devel.x86_64
4.error: jpeglib.h not found.
yum install -y libjpeg-turbo-devel.x86_64
5.error: png.h not found.
yum install -y libpng-devel.x86_64
6.error: freetype-config not found.
yum install -y freetype-devel.x86_64
7.error: mcrypt.h not found. Please reinstall libmcrypt.
yum install -y epel-release
yum install -y libmcrypt-devel
本文转自 虾米的春天 51CTO博客,原文链接:http://blog.51cto.com/lsxme/2051885,如需转载请自行联系原作者