一、PHP的安装

1、下载PHP包

2、解压包  :  tar -jxvf php-5.6.30.tar.bz2 

3、编译配置参数,此处编译参数较多,指定了我们需要的功能模块。

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-pat
h=/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

4、遇到报错1如下:根据错误发现缺少libxml2库

yum install -y yum libxml2-devel,解决该问题后再次重新编译

5、遇到报错2如下:缺少openssl库


安装 yum install -y opensll-devel ,继续编译

6、遇到报错3如下:缺少 Bzip2

安装  yum install -y bzip2-devel

7、遇到报错4如下:

安装 yum install -y libjpeg-devel

8、遇到报错5如下:

安装 yum install -y libpng-devel

9、遇到报错6如下:

安装 yum install -y freetype-devel

10、遇到报错7如下:

 安装 yum install -y libmcrypt-devel  ,需要先安装 yum install -y epel-release,Centos默认源没有libmcrypt-devel,需要借助epel yum扩展源。

11、make 

12、make install

13、查看php加载的模块

/usr/local/php/bin/php -m

14、可以看到在httpd配置文件中生成 php模块  /usr/local/apache2/conf/httpd.conf

15、复制配置文件

cp php.ini-production /usr/local/etc/php.ini

二、安装PHP7

1、下载php7

2、解压  tar -jxvf php-7.1.6.tar.bz2 

3、编译安装

./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-pat
h=/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

5、在httpd模块中可以看到加载了两个php模块 

/usr/local/apache2/bin/apachectl -M

6、在  /usr/local/apache2/conf/httpd.conf 中选择想要使用的php模块,将不用的注释掉就可以了。

 

posted on 2018-02-28 22:26  天梭  阅读(93)  评论(0编辑  收藏  举报