php - 将 PHP 升级到 5.5.9

标签 php nginx centos upgrade fpm

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

我已经在网上阅读了许多关于此的文章,每篇文章似乎都有不同的方法,例如卸载当前版本的 PHP 并从头开始重新安装。

最佳答案

为了获得更现代的 PHP 版本,您需要使用替代 repo。有一些可供选择,传统上打包了更新版本的 LAMP 堆栈组件,比如 Remi,但对于我目前使用的 Centos7 vagrant,我选择了 webtatic .

您只需按照说明使用 yum 设置替代 repo。目前涉及:

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 的操作.

例如在我的虚拟机上,这就是我为 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 中进行测试。

更不用说这些是当今最先进开发的基础技术。

这是一个快速而简单的 Vagrantfile,用于您可以启动并运行的 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

关于php - 将 PHP 升级到 5.5.9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45788636/

相关文章:

php - PHP 中的重定向解析错误

php imap 检查邮件是否有附件

image - CentOS 上的文件扩展名区分大小写

unix - Ansible不使用cp命令复制目录

php - 我想将下载链接生成器添加到 "mini ajax file upload form"脚本中

php - 匹配逗号分隔值存储在数据库 php codeigniter

NGINX - 没有指定输入文件。 - php 快速/CGI

ruby-on-rails - 让 Nginx 转发到 EC2 上的 Thin

docker - Nginx 日志未显示

centos - JMeter 主从配置在 CentOS 中不起作用