centOS安装php最新版本

查看 centos 版本:

[root@iZ23d ~]# cat /etc/centos-release  
CentOS Linux release 7.2.1511 (Core)
 

 

1、删除之前的 php 版本:   

 

 

[root@iZ23d ~]#  yum remove php* php-common    
Loaded plugins: langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
No Match for argument: php-5.4.16
No Match for argument: php-5.4.16.tar.gz
No Match for argument: php-7.0.1RC1
No Match for argument: php-7.0.1RC1.tar.gz
No Match for argument: phpMyAdmin-4.4.0.tar.gz
No Match for argument: php-common
No Packages marked for removal   

 

 

 
2、 rpm 安装 Php7 相应的 yum源:   
 
[root@iZ23d ~]#  rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm     
Retrieving https://mirr or.webtatic. com/yum/el7/ webtatic-rel ease.rpm
warning: /var/tmp/rpm-tmp.LhJKKR: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing...                          ################################# [100%]
        package webtatic-release-7-3.noarch is already installed
 

3、  直接yum安装php7
 
[root@iZ23d ~]#  yum install php70w    
Loaded plugins: langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Resolving Dependencies
--> Running transaction check
。。。  【省略】
Warning: RPMDB altered outside of yum.
  Installing : php70w-common-7.0.0-1.w7.x86_64                              1/3
  Installing : php70w-cli-7.0.0-1.w7.x86_64                                 2/3
  Installing : php70w-7.0.0-1.w7.x86_64                                     3/3
  Verifying  : php70w-7.0.0-1.w7.x86_64                                     1/3
  Verifying  : php70w-common-7.0.0-1.w7.x86_64                              2/3
  Verifying  : php70w-cli-7.0.0-1.w7.x86_64                                 3/3
 
Installed:
   php70w.x86_64 0:7.0.0-1.w7
 
Dependency Installed:
   php70w-cli.x86_64 0:7.0.0-1.w7        php70w-common.x86_64 0:7.0.0-1.w7
 
Complete!
 


4、 检查 php 版本
[root@iZ23d ~]#  php -v  
PHP 7.0.0 (cli) (built: Dec  2 2015 20:42:32) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
[root@iZ23d2e6hoqZ ~]#
 
以上显示安装成功!
 
5、重启 Apache,查看 phpinfo :
 
[root@iZ23d ~]# systemctl restart httpd.service

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Centos7上安装PHP最新版,有两种方法可供选择。第一种方法是通过yum进行简单安装,第二种方法是进行编译安装。 简单安装PHP最新版的方法如下: 1. 首先,确保你的Centos7系统已经安装了Apache2(也称为httpd)。如果还没有安装,可以使用以下命令进行安装: ``` yum install httpd ``` 2. 安装PHP7的最新版本。使用以下命令进行安装: ``` yum install php ``` 3. 安装完成后,重新启动Apache2服务以使PHP生效: ``` service httpd restart ``` 编译安装PHP最新版的方法如下: 1. 首先,确保你的Centos7系统已经安装了gcc和gcc-c++编译器。如果还没有安装,可以使用以下命令进行安装: ``` yum install gcc gcc-c++ ``` 2. 下载PHP最新版的源代码包。你可以从PHP官方网站上下载最新版本的源代码。 3. 解压下载的源代码包,并进入解压后的目录。 4. 使用以下命令进行配置: ``` ./configure ``` 5. 执行以下命令进行编译和安装: ``` make make install ``` 6. 安装完成后,修改Apache2的配置文件,将PHP模块加载到Apache2中。 7. 重新启动Apache2服务以使PHP生效。 这两种方法都可以让你在Centos7上安装最新版的PHP。简单安装方法更为方便快捷,而编译安装方法可以提供更多的自定义选项和灵活性。根据你的需求和技术水平,选择适合你的方法进行安装即可。<span class="em">1</span><span class="em">2</span><span class="em">3</span>

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值