12

我基本上是一个PHP开发人员。我目前在本地机器上使用Ubuntu Linux 12.04 LTS 。

我正在使用以下PHP版本来开发我的PHP项目:

php -v //command run at terminal to know the `PHP` version installed

PHP 5.3.10-1ubuntu3.13 with Suhosin-Patch (cli) (built: Jul  7 2014 18:54:55) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

现在几天前,开发团队发布了最新的稳定PHP版本 ( PHP 5.6.0) 。PHP

我的问题是,由于我在PHP本地计算机上使用的版本太旧,而且所有PHP低于5.4官方不受支持或宣布停产的版本,我应该去PHP 5.6.0吗?

如果你的回答是肯定的,请解释一下我该怎么做?迁移后我在项目中编写的代码会正常工作吗?我需要做哪些改变?

如果您的回答是否定的,请详细解释一下为什么?

在问这个问题之前,我已经浏览了谷歌PHP文档。在那里我找到了以下版本迁移的迁移说明:

   **5.3.x->5.4.x
   5.4.x->5.5.x
   5.5.x->5.6.x**

不知道如何从迁移PHP 5.3.10PHP 5.6.0.

那么有人可以在这方面帮助我吗?

如果您需要有关我的问题的任何进一步信息,请告诉我。

4

2 回答 2

8

TL;DR PHP 5.3.x will still get security upgrades by Ubuntu but upgrade to 14.04.1 for a newer version

You could download and build/install the source for PHP 5.6 from the website, but don't, since it means you risk losing stability with your system because other packages on your system won't be designed for this version and you'll have to upgrade it manually every time a new version comes out, risking stability if those upgrades are security-related since you won't get them upgraded quickly like you would using a package manager.

Instead, I suggest you upgrade your distribution to Ubuntu 14.04.1, which contains PHP 5.5.9; a lot newer than 5.3.10. Of course, 5.3.x will still receive security updates until Ubuntu 12.04 reaches EOL but if you want the latest features you should dist-upgrade. You can do this graphically in the Ubuntu software updater or run apt-get dist-upgrade as root (e.g with sudo) in the TTY if you're using the server version. Update: use sudo do-release-upgrade instead.

Edit: Just to clarify, apt-get is the package manager. If you usually use graphical tools to install and update packages (ubuntu software center, synaptic, etc.), here are some simple commands. # indicates that it must be ran as root (e.g. sudo apt-get install <package>), $ indicates you don't need sudo. Replace things in with the thing you want to use (e.g. apt-get install chromium-browser)

# apt-get update updates the repositories
# apt-get upgrade upgrades the to the newer packages (run the above first!)
# apt-get upgrade <package> is like above, but only upgrades a single package (not that useful unless you have a specific reason)
# apt-get install <package> installs a package
# apt-get remove <package> removes a package
# apt-get autoremove automatically removes packages that were installed by dependencies and no longer needed
$ apt-cache search <query> searches for the query you gave
$ apt-cache show <package> shows info for a package
# yes "" | apt-get install <package> installs a package answering the default answer to everything (you can use yes with lots of commands)
# apt-get dist-upgrade upgrades everything (and removes some packages) when it might usually be held back.

于 2014-08-30T07:00:07.103 回答
5

升级到 Ubuntu 14.04.1 以获得 PHP 5.5.9 作为一个包,并从 Ubuntu 升级中受益。无论如何,我不会在生产环境中使用 5.6.0。

这个 PHP 页面,您可以获得有关从 5.3 迁移到 5.4 以及从 5.4 迁移到 5.5 的信息。

除了提到的更改和新功能外,PHP 团队还致力于 5.3 和 5.5.9 之间的内存管理和优化。仅这些改进就推动了迁移。

迁移建议

  • APC:PHP 现在嵌入 OPCache 作为 APC 的替代品。如果您使用 APC 变量,则可以获得一些关于OPCache的信息 - 在我的情况下,通过新模块(名称更改)使用旧 APC php5-apcu(注意“u”)是最好的选择。

  • 这些模块安装在不同的目录中。如果你打算保持你php.iniextension_dir可能需要调整

  • 此外,/etc/php5dir 在结构方面要求更高:在该 dir 下方是mods-available(à la nginx ),其中包含模块 ini 文件的列表。然后 in cli, fpm, apache2... dirs 是一个目录,它具有指向该主模块 ini 文件conf.d的符号链接;mods-available如果您打算将该模块用于该 PHP 配置(例如,mysqli可能不需要cli),则仅添加一个链接。

  • JSON:php5-json必须安装模块 ( apt-get install php5-json) 才能获得 PHP JSON 函数 ( json_encode, decode...)

  • 请注意,似乎在某个地方(例如 in )链接到/etc/php5/MODE/php.iniphp.ini时出现问题(例如,在 Ubuntu 中)-在 Ubuntu 更新期间,错误阻止了安装-我只是复制了 php.ini,因为它们是在我的情况下,所有模式都相同。clifpm

除此之外,迁移进展顺利。

于 2014-08-31T08:52:53.030 回答