分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

,2018-2-28 10周1次课 PHP5、PHP7的安装

发布时间:2023-09-06 01:44责任编辑:白小东关键词:PHP
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(过程省略)

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

(过程省略)

[root@localhost php-5.6.30]# make install

(过程省略)

[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(apache -M)[PHP Modules]bz2CorectypedatedomeregexiffileinfofiltergdhashiconvjsonlibxmlmbstringmcryptmysqlmysqliopensslpcrePDOpdo_mysqlpdo_sqlitePharposixReflectionsessionSimpleXMLsoapsocketsSPLsqlite3standardtokenizerxmlxmlreaderxmlwriterzlib[Zend Modules]


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

(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

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


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

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

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


[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.6s2018-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)

(过程省略)

[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]bz2CorectypedatedomeregexiffileinfofiltergdhashiconvjsonlibxmlmbstringmcryptmysqlmysqliopensslpcrePDOpdo_mysqlpdo_sqlitePharposixReflectionsessionSimpleXMLsoapsocketsSPLsqlite3standardtokenizerxmlxmlreaderxmlwriterzlib[Zend Modules]


·apache加载了几个PHP:

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


·选择使用的PHP:

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







,2018-2-28 10周1次课 PHP5、PHP7的安装

原文地址:http://blog.51cto.com/11530642/2074116

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved