11.10/11.11/11.12 安装PHP5
php官网 www.php.net
当前主流版本为5.6/7.1
安装过程
1.#cd /usr/local/src
2.下载源码包并解包
#wget http://mirrors.sohu.com/php/php-5.6.36.tar.gz
#tar xzvf php-5.6.36.tar.gz
3.进入源码包目录进行配置
# cd php-5.6.36
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/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
这里说一下 apxs是apache的工具,能自动帮我们把扩展模块放到apache的module目录里,并且在配置文件里加上一行loadmodule到配置文件中
出现错误,一般是缺少库文件,通常是-devel结尾的包,这里缺少xml2库,yum安装
# yum install -y libxml2-devel.x86_64
再次配置,又出现错误,缺少evp库
# yum install -y kdevplatform-devel.x86_64
再次配置,又出现错误
# yum install -y bzip2-devel.x86_64
继续配置,err
#yum install -y libjpeg-turbo-devel.x86_64
继续配置,err
# yum install -y libpng-devel.x86_64
继续配置,err
# yum install -y libmcrypt-devel.x86_64
继续配置,成功
3.make && make install
4.复制配置文件
# cp php.ini-production /usr/local/php/etc/php.ini
production是指生产环境,development是指开发环境
查看php的配置信息
# /usr/local/php/bin/php -i| less
查看加载的模块
# /usr/local/php/bin/php -m
php不需要启动,php作为apache的模块存在
# /usr/local/apache2/bin/httpd -M
php5模块位置/usr/local/apache2/modules/libphp5.so
apache的配置文件
# vim /usr/local/apache2/conf/httpd.conf
模块随用随取,去掉#,取消注释即可
11.13 安装PHP7
1.
#cd /usr/local/src
2.
#wget http://mirrors.sohu.com/php/php-7.1.18.tar.gz
# tar xzvf php-7.1.18.tar.gz
3.
#cd php-7.1.18
#./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php7/etc --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
4.make && make install