Linux20180525安装php5 7

5月25日任务

11.10/11.11/11.12 安装PHP5
11.13 安装PHP7
php中mysql,mysqli,mysqlnd,pdo到底是什么http://blog.csdn.net/u013785951/article/details/60876816
查看编译参数 http://ask.apelearn.com/question/1295



将php5安装在 aming1.

安装顺序是有一个安排的,先mysql 后php

image.png

  1. 到src目录,下载,解压。bz2文件的解压命令,tar -xvf

  2. cd php目录,然后执行configure命令来进行编译。 ./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 。前面主要是apache的模块安装,接下来是php

    执行编译的时候出现了一个错误。image.png

    就是openssl找不到,yum 找一下,实际上需要安装的是 yum install openssl openssl-devel。 继续编译。

    接下来又出现了一个错误,image.png,解决办法 yum install bzip2-devel

    接下里又出现了一个错误,是libpng缺失,用这个命令安装。 yum install libjpeg-devel

    不出意外的,又出现一个错误。image.png,yum install freetype-devel

    新的错误出现,image.png。因为这个包是属于epel扩展库的,所以如果需要使用必须提前安装epel扩展库的。然后 yum install libmcrypt-devel.

    image.png编译成功。

  3. 接下来是make,make install 。装的位置是/usr/local/php 

  4. 可以看到有一个.so文件,这个就是php和apache结合的文件。image.png

  5. 查看php下所加载的静态模块的命令。 bin/下 php -m image.png 。实际上php是httpd的一个模块存在的。

  6. 通过/usr/local/php/bin/php -i 可以查看php信息 image.png

  7. 拷贝配置文件到/php/etc下。image.png  cp /usr/local/src/php-5.6.32/php.ini-production /usr/local/php/etc/php.ini






CentOS7 装在aming1

image.png

注意在编译的时候没有 --with-mysql 

./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 


make


make install 


完成安装。但是要知道的事情是,一个apache只能一次调用一个php,所以要指定使用的是哪个php

image.png

可以看到,加载了几个php,5和7都加载了。

image.png


如何选择用哪个?到配置文件里进行修改。

vim /usr/local/apache2/conf/httpd.conf

会发现有两个php的模块,注释掉不需要的。

image.png

猜你喜欢

转载自blog.51cto.com/13691454/2120963