将PHP升级到5.5.9

时间:2017-08-21 02:35:45

标签: php nginx centos upgrade fpm

我想在我的服务器Grav上安装一个开源项目,但它需要PHP 5.5.9。我目前在NGINX上运行的CentOS 7服务器上安装了PHP 5.4.16。实际上,它是PHP-FPM。所以我的问题是实现这一目标的最简单,最简洁的方法是什么?

我在网上看过很多关于此的文章,每个人似乎都有不同的方法,例如卸载当前版本的PHP并从头开始重新安装。

1 个答案:

答案 0 :(得分:0)

为了获得更现代的PHP版本,您需要使用备用仓库。有一些可供选择,传统上包装了较新版本的LAMP堆栈组件,如Remi,但对于我目前正在使用的Centos7流浪者,我选择webtatic

您应该按照说明使用yum设置备用仓库。目前涉及:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装完成yum search php后,您就可以找到PHP版本5.5,5.6,7.0和7.1供选择。

而不是yum install php,你会做yum install php56w之类的事情。

例如在我的VM上,这就是我对php的所有内容:

[vagrant@localhost:~]$ rpm -qa | grep php
php56w-5.6.31-1.w7.x86_64
php56w-process-5.6.31-1.w7.x86_64
php56w-opcache-5.6.31-1.w7.x86_64
php56w-xml-5.6.31-1.w7.x86_64
php56w-pear-1.10.4-1.w7.noarch
php56w-common-5.6.31-1.w7.x86_64
php56w-cli-5.6.31-1.w7.x86_64
php56w-mbstring-5.6.31-1.w7.x86_64
php56w-pdo-5.6.31-1.w7.x86_64
php56w-mysqlnd-5.6.31-1.w7.x86_64
php56w-fpm-5.6.31-1.w7.x86_64
php56w-gd-5.6.31-1.w7.x86_64

你需要卸载当前的php版本,所以这是一个涉及的操作,你想做一个干运行,并确信你知道你正在做什么。

至于对Vagrant / Virtualbox / Docker等不会破坏的信心,没有理由不首先在VM中测试它。

更不用说这些是最近发展现状的基础技术。

这里有一个快速简单的Vagrant文​​件,可以安装并运行一个vanilla Centos7盒子(假设你安装了Vagrant并正常工作)。

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "centos/7"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 8080, host: 8080
  # config.vm.network "forwarded_port", guest: 80, host: 80
  # config.vm.network "forwarded_port", guest: 3306, host: 3306

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  config.vm.network "private_network", ip: "192.168.20.20"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  config.vm.synced_folder "./data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
  # such as FTP and Heroku are also available. See the documentation at
  # https://docs.vagrantup.com/v2/push/atlas.html for more information.
  # config.push.define "atlas" do |push|
  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
  # end

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end