20180525

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

1. 安装PHP5

1.1 编译安装

cd /usr/local/src/ 
wget http://cn2.php.net/distributions/php-5.6.32.tar.gz
tar zxf php-5.6.32.tar.gz
cd php-5.6.32
./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
make && make install

--prefix: 指定安装目录
--with-apxs2: Apache工具, 自动安装扩展模块的
--with-config-file-path: 指定配置文件php.ini的路径
--with-mysql: 指定mysql路径
--with-mysql
--with-pdo-mysql
--with-mysqli 以上3个是mysql的驱动/库, 用于mysql与php通信
其他的: 指定php需要的模块

1.2 错误解决

一般先安装一遍库
yum install -y libxml2-devel openssl-devel bzip2-devel libjpeg-devel libpng-devel freetype-devel libcurl-devel autoconf

yum install -y epel-release 安装扩展源
yum install -y libmcrypt-devel
如没有包, 尝试重新安装扩展源yum reinstall -y epel-release

1.3 查看加载的模块

/usr/local/php/bin/php -m (静态模块)
php是http的一个扩展模块, 无需启动

1.4 拷贝配置文件到/usr/local/php/etc/目录下

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

1.5 查看参数

/usr/local/php/bin/php -i |less

2. 安装PHP7

2.1 编译安装

安装参数跟php5有点不同, 其他差不多

cd /usr/local/src/ 
wget http://cn2.php.net/distributions/php-7.2.0.tar.bz2
tar jxf php-7.2.0.tar.bz2
cd php-7.2.0
./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
/usr/local/php7/bin/php -m

Apache配置文件http.conf中, php5和php7注释掉一个, 否则会冲突
vim /usr/local/apache2.4/conf/httpd.conf
搜libphp5.so或libphp7.so

拷贝配置文件

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

未经允许不得转载:外贸SOHO笔记 » 20180525

赞 (0) 打赏

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下作者~

支付宝扫一扫打赏

微信扫一扫打赏