• 欢迎访问sadsu网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站。
  • 最新版Git主题已支持说说碎语功能,可像添加文章一样直接添加说说,新建说说页面即可,最后重新保存固定连接,
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏sadsu吧

Upgrade VestaCP to PHP 7 (CentOS)

VPS应用程序 admin 4年前 (2016-09-27) 41次浏览 0个评论

PHP7性能大幅提升,为了更好的运行wordpress,我的网站也升级到了7,下面是当时的参考文档,步骤很简单。

php7

How to install PHP 7 (stable) on VestaCP server running on CentOS 7 with some test results of how VestaCP + PHP 7 can perform together serving WordPress site. For your information, PHP 7 has just been released and many rumors say it can perform multiple times faster than previous stable PHP version and also as fast as HHVM. This is the most anticipated PHP version ever bringing many new features, enhancements, and improved performance.

Until the time I write this post, VestaCP is by default using PHP 5.4.x installed and running with web server (either Apache or Nginx). I’m not  really sure why its developer still pack PHP 5.4 within VestaCP installation but as far as I know PHP 5.4 is the most popular stable version after 5.3 that many scripts, web apps and CMS are supported (can still run well with the PHP environment).

As per PHP 7, there are still not enough information of how many CMS / scripts except WordPress and OwnCloud those are already PHP 7 compatible. So if you are planning to build a WordPress site with VestaCP, you can try this tutorial and feel the awesomeness of PHP 7. But I must also remind you that since VestaCP doesn’t include PHP 7 by default yet, so I recommend you to not using VestaCP + PHP 7 on production websites unless you are a sysadmin Ninja. However, with default Vesta setup (Nginx as proxy + Apache + PHP), this method still can work properly so it is safe if you’ll just want to host personal blog or few blogs inside one server.

上面的一堆话主要是介绍php7多牛逼,爱看看不看跳过,一点问题都没有

安装前需要一些什么

  1. 需要SSH权限,以及SSH客户端 or Putty and basic knowledge about how to use it.
  2. 基本的指令会使用 Basic knowledge about common Unix command to SSH to your server.
  3. 一台VPS最好有1G以上的内存,2G的更好.
  4. 确信你的VestaCP 服务器已安装并运行在centos系统下。.
  5. 有30分钟空余时间(完全不需要,10分钟就搞定了)。
  6. 一杯饮料(哈哈).

Confused on choosing which VPS provider to install VestaCP? Read my recommended VPS providers or top low end cloud server providers. Quick recommendation: Digital Ocean, Atlantic.net or Ramnode.

如何安装  How to Install

p.s: Please click any image you wish to see its larger version.

Step 1 – Install VestaCP on your vps, cloud or dedicated server. You can follow the step by step tutorial posted previously. Despite this tutorial done on CentOS 7, but the steps are pretty much similar.  安装VestaCp到你的服务器上,这里尝试的是centos7,我的服务器是centos6的,也没问题。

Step 2 – Once installed, still in Putty, you can do initial check of what PHP version is installed: 安装完毕后查看一下安装的版本,如果是7就别升了,哈哈。

 # php -V
PHP 5.4.45 (cli) (built: Jul 22 2016 19:13:31)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

it should look like this (PHP 5.4.45):

Step 3 – Now we need to install remi repo or at least make it updated. PHP 7 is considered new and is not available via Yum at base CentOS repo.现在需要下载最新版的remi 与epel。

我的版本是centos6,所以指令是:

 

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm

 

centos7的指令如下:

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm

 

cnetos5我就不说了,应该现在用的人越来越少了。
 下载文件的地址原文链接: How to enable Remi repository on CentOS 7, 6 and 5 还在使用5的可以去看。

Step 4 – Now issue this command to update and enable it 现在update一下系统

yum --enablerepo=remi update remi-release

Step 5 – Now delete current PHP installation but make sure you stopped Apache first: 停止httpd以及删除原来的php版本

备份一下依赖于php的roundmail,虽然phpMyAdmin没有影响,我还是备份了

cd /etc/httpd/conf.d/
mv roundcubemail.conf roundcubemail.conf.bak
mv phpMyAdmin.conf phpMyAdmin.conf.bak
cd /etc/
mv phpMyAdmin/ phpMyAdminbak/
mv roundcubemail/ roundcubemailbak/
cd /usr/share/
mv phpMyAdmin/ phpMyAdminbak/
mv roundcubemail/ roundcubemailbak/
ll
service httpd stop
yum -y remove php

Step 6 – Finally, issue this command to install PHP 7.0 with all necessary modules: 现在开始安装php7.o,貌似命令有点长啊

yum --enablerepo=remi-php70 install php70-php php70-php-pear php70-php-bcmath php70-php-pecl-jsond-devel php70-php-mysqlnd php70-php-gd php70-php-common php70-php-fpm php70-php-intl php70-php-cli php70-php php70-php-xml php70-php-opcache php70-php-pecl-apcu php70-php-pecl-jsond php70-php-pdo php70-php-gmp php70-php-process php70-php-pecl-imagick php70-php-devel php70-php-mbstring php70-php-pecl-zip php70-php-snmp -y

安装完之后恢复一下备份文件

cd /etc/httpd/conf.d/
mv roundcubemail.conf.bak roundcubemail.conf
mv phpMyAdmin.conf.bak phpMyAdmin.conf
cd /etc/
mv  phpMyAdminbak/ phpMyAdmin/
mv  roundcubemailbak/ roundcubemail/
cd /usr/share/
mv  phpMyAdminbak/ phpMyAdmin/
mv  roundcubemailbak/ roundcubemail/
ll

 

 

 Step 7 – Next, at this point, you can simply stop the old PHP-fpm service and start the newly installed PHP70-fpm 将php-fpm改为php70-php-fpm
service php-fpm stop
service php70-php-fpm start
原文是这样写的,但是貌似我的php卸载后php-fpm也找不到了
# service php-fpm stop
php-fpm: unrecognized service

Step 8 – Finally you can delete the old php symblink and create a new one: 更改php的软连接

rm /usr/bin/php
ln -s /usr/bin/php70 /usr/bin/php
     Also do not forget to restart Apache service / httpd: 重新启动httpd
service httpd restart
 Step 9 – Now you can check which version of PHP Vestacp is running:再次查看php版本
php -v

# php -v
PHP 7.0.11 (cli) (built: Sep 14 2016 07:27:30) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.11, Copyright (c) 1999-2016, by Zend Technologies

大功告成!

ps:原文中未加入zip模块,我的owncloud安装后报错,所以需要增加php70-php-pecl-zip安装,已加在安装文件指令中了。


极客公园 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Upgrade VestaCP to PHP 7 (CentOS)
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址