,2018-2-28 10周1次课 PHP5PHP7的安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了,2018-2-28 10周1次课 PHP5PHP7的安装相关的知识,希望对你有一定的参考价值。
11.10、11.11、1.12 安装PHP5
[[email protected] ~]# cd /usr/local/src [[email protected] src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2 (过程省略) [[email protected] php-5.6.30]# tar jxvf php-5.6.30.tar.bz2 [[email protected] src]# cd php-5.6.30/ [[email protected] src]# ./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 (过程省略)
--prefix
指定安装目录
--with-apxs2
apache的工具,能让不用人工干涉,自动把扩展模块放置到apache的module里,并在配置文件里加上load modules,httpd-M能把模块加载
--with-config-file-path
指定配置文件所在路径,php.ini
--with-mysql
--with-pdo-mysql
--with-mysqli
指定mysql的路径,三种不同mysql的驱动
(老版本用--with-mysql,新版本用--with-mysqli,作用是一样的)
--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的模块(直接复制使用)
[[email protected] php-5.6.30]# make
(过程省略)
[[email protected] php-5.6.30]# make install
(过程省略)
[[email protected] php-5.6.30]# ls /usr/local/php/bin/ pear peardev pecl phar phar.phar php php-cgi php-config phpize
二进制文件,/usr/local/php/bin/php
[[email protected] php-5.6.30]# /usr/local/php/bin/php -m(apache -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]
[[email protected] php-5.6.30]# /usr/local/apache2.4/bin/httpd -M
(php是作为httpd的扩展模块的形式存在的)
·模块文件:libphp5.so
[[email protected] php-5.6.30]# ll /usr/local/apache2.4/modules/libphp5.so -rwxr-xr-x. 1 root root 37752768 2月 28 23:19 /usr/local/apache2.4/modules/libphp5.so
·配置文件:
[[email protected] php-5.6.30]# vi /usr/local/apache2.4/conf/httpd.conf
配置文件httpd.conf中,可以看到php5模块,不用则注释掉,随用随取
[[email protected] php-5.6.30]# /usr/local/php/bin/php -i
可以查看配置参数、configuration file的路径等
[[email protected] php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini
·安装常见错误:
1,解决php编译报错configure: error: xml2-config not found. Please check your libxml2 installation
yum install -y libxml2-devel
2,解决php编译报错configure: error: Cannot find OpenSSL's <evp.h>
yum install -y openssl-devel
3,解决php编译报错configure: error: Please reinstall the BZip2 distribution
yum install -y bzip2-devel
4,解决php编译报错configure: error: jpeglib.h not found.
yum install -y libjpeg-devel
5,解决php编译报错configure: error: png.h not found.
yum install -y libpng-devel
6,解决php编译报错configure: error: freetype-config not found.
yum install -y freetype-devel
7,解决php编译报错configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install -y epel-release(先安装扩展源,mcrypt在扩展源中)
yum install -y libmcrypt-devel
11.13 安装PHP7
[[email protected] php-5.6.30]# cd /usr/local/src/ [[email protected] src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2 --2018-02-28 23:52:39-- http://cn2.php.net/distributions/php-7.1.6.tar.bz2 正在解析主机 cn2.php.net (cn2.php.net)... 123.125.23.171, 123.125.23.169, 123.125.23.168, ... 正在连接 cn2.php.net (cn2.php.net)|123.125.23.171|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:15732452 (15M) [application/octet-stream] 正在保存至: “php-7.1.6.tar.bz2” 100%[================================================================================================>] 15,732,452 9.45MB/s 用时 1.6s 2018-02-28 23:52:41 (9.45 MB/s) - 已保存 “php-7.1.6.tar.bz2” [15732452/15732452]) [[email protected] src]# tar jxvf php-7.1.6.tar.bz2 [[email protected] src]# cd php-7.1.6/ [[email protected] 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
(区别于PHP5:--prefix=/usr/local/php7,--with-config-file-path=/usr/local/php7/etc,没有--with-mysql)
(过程省略)
[[email protected] php-7.1.6]# make && make install
(过程省略)
·PHP7模块文件
[[email protected] php-7.1.6]# ll /usr/local/apache2.4/modules/libphp7.so -rwxr-xr-x. 1 root root 38369056 3月 1 00:05 /usr/local/apache2.4/modules/libphp7.so
·PHP7加载的模块:
[[email protected] php-7.1.6]# /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]
·apache加载了几个PHP:
[[email protected] php-7.1.6]# /usr/local/apache2.4/bin/apachectl -M
·选择使用的PHP:
(用哪个就留着,不用哪一个就注释掉)
以上是关于,2018-2-28 10周1次课 PHP5PHP7的安装的主要内容,如果未能解决你的问题,请参考以下文章