php-7.1.30.tar.bz2,2018-2-28 10周1次课 PHP5、PHP7的安装

11.10、11.11、1.12 安装PHP5

[root@localhost ~]# cd /usr/local/src

[root@localhost src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2

(过程省略)

[root@localhost php-5.6.30]# tar jxvf php-5.6.30.tar.bz2

[root@localhost src]# cd php-5.6.30/

[root@localhost 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

(过程省略)

74f81f166f253852d1d2710dedecd7a7.png

--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的模块(直接复制使用)

[root@localhost php-5.6.30]# make

(过程省略)

e99ae72e04ae97d7adffe94282657fbd.png[root@localhost php-5.6.30]# make install

(过程省略)

f9e9df1aea042bfdf5838a2f68414145.png

5eecf051975902ca37dd76093ee691de.png[root@localhost 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

[root@localhost php-5.6.30]# /usr/local/php/bin/php -m(类似于httpd -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]

[root@localhost php-5.6.30]# /usr/local/apache2.4/bin/httpd -M

f9e9df1aea042bfdf5838a2f68414145.png

39e4dfc6932abc7498850b61f1506fc9.png

(php是作为httpd的扩展模块的形式存在的)

·模块文件:libphp5.so[root@localhost 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

·配置文件:[root@localhost php-5.6.30]# vi /usr/local/apache2.4/conf/httpd.conf

f9e9df1aea042bfdf5838a2f68414145.png

b134bdbdcdace4eb6debe8228d0fe5d6.png

配置文件httpd.conf中,可以看到php5模块,不用则注释掉,随用随取

[root@localhost php-5.6.30]# /usr/local/php/bin/php -i

可以查看配置参数、configuration file的路径等

f9e9df1aea042bfdf5838a2f68414145.png

e4a414643cea6f8213fd12191156c239.png[root@localhost php-5.6.30]# cp php.ini-production  /usr/local/php/etc/php.ini

f9e9df1aea042bfdf5838a2f68414145.png

ef829a877d0e01124b87a628390521c2.png

·安装常见错误:

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

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

[root@localhost php-5.6.30]# cd /usr/local/src/

[root@localhost 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])

[root@localhost src]# tar jxvf php-7.1.6.tar.bz2

[root@localhost src]# cd php-7.1.6/

[root@localhost 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)

b6b843105512e49ae39d3cb728c6a6a4.png

(过程省略)

f9e9df1aea042bfdf5838a2f68414145.png[root@localhost php-7.1.6]# make && make install

(过程省略)

·PHP7模块文件[root@localhost 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加载的模块:[root@localhost 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:[root@localhost php-7.1.6]# /usr/local/apache2.4/bin/apachectl -M

f9e9df1aea042bfdf5838a2f68414145.png

e0fb995d54aaefb585e1810bc0c5f1da.png

·选择使用的PHP:

f9e9df1aea042bfdf5838a2f68414145.png

3b25f36abdb06c6ae8a68abd09aca7ca.png

(用哪个就留着,不用哪一个就注释掉)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值