文档章节

CentOS 安装PHP5和PHP7

野雪球
 野雪球
发布于 11/14 03:06
字数 1030
阅读 22
收藏 0

安装PHP5

  • 下载解压二进制包
[root@test-a src]# cd /usr/local/src/
[root@test-a src]# wget  http://cn2.php.net/distributions/php-5.6.32.tar.bz2
[root@test-a src]# tar jxvf php-5.6.32.tar.bz2
  • 编译安装PHP
./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

#报错:
...
configure: error: Cannot find OpenSSL's <evp.h>

# 安装openssl
[root@test-a php-5.6.32]# yum install openssl-devel -y
...
Total size: 14 M
Total download size: 151 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
libselinux-utils-2.5-12.el7.x8 FAILED
http://mirrors.163.com/centos/7/os/x86_64/Packages/libselinux-utils-2.5-12.el7.x86_64.rpm: [Errno 14] HTTP Error 416 - Requested Range Not Satisfiable
Trying other mirror.

Error downloading packages:
  libselinux-utils-2.5-12.el7.x86_64: [Errno 256] No more mirrors to try.

# 安装过程报错,需要安装deltarpm
[root@test-a php-5.6.32]# yum install deltarpm
...
Downloading packages:
No Presto metadata available for base
libselinux-utils-2.5-12.el7.x8 FAILED
http://mirrors.163.com/centos/7/os/x86_64/Packages/libselinux-utils-2.5-12.el7.x86_64.rpm: [Errno 14] HTTP Error 416 - Requested Range Not Satisfiable
Trying other mirror.


Error downloading packages:
  libselinux-utils-2.5-12.el7.x86_64: [Errno 256] No more mirrors to try.
# 还是报错,由于之前用的Base源是163的,换回默认的Base源再试就OK了... :(
# 继续初始化配置过程,报错
...
checking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution 
[root@test-a php-5.6.32]# yum -y install bzip2-devel
# 继续报错
...
checking for stdarg.h... (cached) yes
checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
# 继续报错
[root@test-a php-5.6.32]# yum install -y libmcrypt-devel

#继续报错
...
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
configure: error: Cannot find libmysqlclient_r under /usr/local/mysql.
Note that the MySQL client library is not bundled anymore!
# PHP默认是去/usr/local/mysql/lib/mysql/搜索,没有找到报错,复制或者做个软连接就行.
[root@test-a php-5.6.32]# cp /usr/local/mysql/lib/libmysqlclient.so /usr/local/mysql/lib/mysql/libmysqlclient_r.so

# 再次安装,苍了个天,看见Thank you...啦 成功!
...
Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands


# 编译
[root@test-a php-5.6.32]# make
...
Build complete.
Don't forget to run 'make test'.

# 安装
[root@test-a php-5.6.32]# make install
  • 查看php的模块(都是静态的)
[root@test-a php-5.6.32]#  /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]

# 拷贝配置文件
[root@test-a php-5.6.32]# cp php.ini-production /usr/local/php/etc/php.ini

# 查看php信息
[root@test-a php-5.6.32]#  /usr/local/php/bin/php -i

安装PHP7

  • 下载安装包解压
[root@test-a src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
[root@test-a src]# tar jxvf php-7.1.6.tar.bz2
  • 配置初始化
[root@test-a src]# cd php-7.1.6/
[root@test-a 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
# 出错
....
checking for mysql_set_server_option in -lmysqlclient_r... no
configure: error: wrong mysql library version or lib not found. Check config.log for more information.
# 由于php已经带了这个模块,所以编译时不指定mysqli的路径,继续
[root@test-a 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 --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

#出错
...
checking for mysql_commit in -lmysqlclient_r... (cached) no
configure: error: PDO_MYSQL configure failed, MySQL 4.1 needed. Please check config.log for more information.

#编译时不指定pdo的路径,继续
root@test-a 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 --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

...
Thank you for using PHP.

config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

  • 编译安装
[root@test-a php-7.1.6]# make
[root@test-a php-7.1.6]# make install
[root@test-a php-7.1.6]# ls /usr/local/apache2.4/modules/libphp*
/usr/local/apache2.4/modules/libphp5.so  /usr/local/apache2.4/modules/libphp7.so

© 著作权归作者所有

共有 人打赏支持
野雪球
粉丝 7
博文 61
码字总数 69702
作品 0
贵阳
私信 提问
CentOS下php5与php7共存

CentOS下php5与php7共存 Lok2017-11-068 阅读 PHPLinux 先安装php7 安装过程略,路径在/usr/local/php 安装php5 安装phpredis 修改php.ini文件 点赞 PHPLinux 作者:Lok just another techni...

Lok
2017/11/06
0
0
阿里云 apache+mysql+php+cron+memcached

Apache安装 安装mysql5.5 安装php 5.5 安装php7.09(CENTOS 6.5) 安装php7.09(CENTOS 7.2) php5 升级到 php7 安装cron计划任务 安装memcached 修改httpd.conf配置文件...

colin_86
2015/12/15
96
0
2018.06.10 周日--《PHP7--PHP的一次重大变革》

一、写在开头 PHP7是PHP编程语言全新的一个版本,主要在性能方面获得了极大的提升。官方的文档显示,PHP7可以达到PHP5.x版本两倍的性能。同时还对PHP的语法做了梳理,提供了很多其他语言流行...

微信公众号_程序员的文娱情怀
06/10
0
0
蝉知建站系统PHP7性能测评

2015年底PHP7正式面世了,这是PHP语言发展史的一个重要里程碑,它带来了显著的性能提升和新特性,并对之前版本的一些特性进行了改进。今天我在虚拟机中分别搭建了相同环境LAMP,PHP版本分别是...

it1000001001
2017/03/06
189
0
docker安装mysql5.6

docker安装mysql5.6 Lok2017-11-104 阅读 dockerDockerMySQL数据库Linux 下载镜像 启动mysql 查看进程 连接测试 用有mysql客户端的登录测试 点赞 dockerDockerMySQL数据库Linux 作者:Lok j...

Lok
2017/11/10
0
0

没有更多内容

加载失败,请刷新页面

加载更多

为什么只有你每次提交代码,log里面会出现merge

http://www.cnblogs.com/Sinte-Beuve/p/9195018.html

踏破铁鞋无觅处
4分钟前
0
0
如何学习大数据:spark发布程序

一、对于spark程序只是用于默认的spark包的情况 直接点击pcakage 将程序进行在linux当中进行发布 客户端模式:测试 spark-submit --class com.keduox.App \ --master yarn \ --deploy-mode ...

架构师springboot
4分钟前
0
0
oracle job(定时任务)

创建 定时任务 job declare job number;BEGIN DBMS_JOB.SUBMIT( JOB => job, -- job任务的唯一标识(自动生成) WHAT => 'INSERT into TEXTL (id) VALUES(TEXT......

骑羊放狼灬
8分钟前
0
0
Spring声明式事务在抛出异常时不回滚(RollBack)

Spring声明式事务默认只在RuntimeException时Rollback(回滚),不当的try catch会导致事务不回滚。 spring事务默认运行时异常回滚,RuntimeException 配置时添加异常回滚 rollback-for="Th...

叶落花开
9分钟前
0
0
赋能时空云计算 阿里云数据库时空引擎Ganos上线

随着移动互联网、位置感知技术、对地观测技术的快速发展,时空信息已从传统GIS行业渗透到大众应用及各行各业。从静态POI(兴趣点)到APP位置信息,从导航电子地图到车辆行驶轨迹,从卫星影像...

阿里云云栖社区
11分钟前
0
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部