php5,7安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php5,7安装相关的知识,希望对你有一定的参考价值。
安装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
- tar zxf php-6.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
apxs2这个工具可以自动加载apache的扩展模块,指定mysql的驱动,后面的参数是指定php所需要的模块
configure: error: xml2-config not found. Please check your libxml2 installation. [[email protected] php-5.6.30]# yum install -y libxml2-devel configure: error: Cannot find OpenSSL‘s <evp.h> [[email protected] php-5.6.30]# yum install -y openssl-devel configure: error: Please reinstall the BZip2 distribution [[email protected] php-5.6.30]# yum install -y bzip2-devel configure: error: jpeglib.h not found. [[email protected] php-5.6.30]# yum install -y libjpeg-devel configure: error: png.h not found. [[email protected] php-5.6.30]# yum install -y libpng-devel configure: error: freetype-config not found. [[email protected] php-5.6.30]# yum install -y freetype-devel configure: error: mcrypt.h not found. Please reinstall libmcrypt. [[email protected] php-5.6.30]# yum install -y libmcrypt-devel
- make && make install
- cp php.ini-production /usr/local/php/etc/php.ini//复制配置文件
[[email protected] php-5.6.30]# ls /usr/local/php/ bin etc include lib php [[email protected] php-5.6.30]# du -sh /usr/local/php/bin/php 36M /usr/local/php/bin/php //主文件 [[email protected] php-5.6.30]# du -sh /usr/local/apache2.4/modules/libphp5.so 37M /usr/local/apache2.4/modules/libphp5.so //php主模块 [[email protected] php-5.6.30]# /usr/local/php/bin/php -m //加载的模块,静态的 [PHP Modules] bz2 Core ctype date dom ereg exif fileinfo filter gd hash iconv json libxml mbstring mcrypt mysql mysqli openssl pcre PDO pdo_mysql pdo_sqlite Phar posix Reflection session SimpleXML soap sockets SPL sqlite3 standard tokenizer xml xmlreader xmlwriter zlib [Zend Modules]
- php是作为apache的扩展模块存在的
- 查看php的安装信息
[[email protected] php-5.6.30]# /usr/local/php/bin/php -i |less
安装PHP7
- cd /usr/local/src/
- wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
- tar jxf php-7.1.6.tar.bz2
- 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 //复制配置文件
- php5和7可以同时安装,但是apache调用的时候只能调用一个,在/usr/local/apache2.4/conf/httpd.conf里面修改,不用的直接注释
[[email protected] ~]# vim /usr/local/apache2.4/conf/httpd.conf #LoadModule rewrite_module modules/mod_rewrite.so LoadModule php5_module modules/libphp5.so #LoadModule php7_module modules/libphp7.so
扩展
以上是关于php5,7安装的主要内容,如果未能解决你的问题,请参考以下文章