11.10~11.12 安装PHP5
- PHP官网www.php.net,当前主流版本为5.6/7.1
- cd /usr/local/src/
- wget http://cn2.php.net/distributions/php-5.6.30.tar.gz #下载PHP5.6
- tar zxvf 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。 #指定PHP所需的各模块,编译时会有报错,需要安装对应的包再重编译,比如libxml2-devel、openssl-devel、bzip2-devel、libjpeg--turbo-devel、libpng-devel、freetype-devel、libmcrypt-devel(安装该包之前需要安装epel-release,因libmcrypt扩展包在epel扩展源里)
- make
- make install
- cp php.ini-production /usr/local/php/etc/php.ini #适合在生产环境的配置文件,php.ini-development为适合在开发环境下的配置文件
- /usr/local/php/bin/php -i |less #查看php的一些相关信息,查看显示没有加载配置文件,需要上一步将配置文件拷贝到指定文件夹 /usr/local/php/etc/下
- /usr/local/php/bin/php -m #查看php所加载的模块
- cd /usr/local/src/
- wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
- tar jxvf php-7.1.6.tar.bz2 #解压bz类型的文件,使用“-j”选项
- cd php-7.1.6
- ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/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 #标黑字体指定配置文件路径
- make
- make install
- ls /usr/local/apache2.4/modules/libphp7.so
- cp php.ini-production /usr/local/php7/etc/php.ini
- /usr/local/php7/bin/php -m #查看php所加载的模块
- /usr/local/apache2.4/bin/apachectl -M #查看Apache加载的模块,可以看到有PHP5和PHP7两个模块:php5_modules和php7_modules, 可以编辑配置文件:/usr/local/apache2.4/conf/http.conf将不启用的模块注释掉