How to install / setup /upgrade PHP 5.5.x on Ubuntu 12.04 LTS
原文:http://www.dev-metal.com/how-to-setup-latest-version-of-php-5-5-on-ubuntu-12-04-lts/
最近遇到了要在ubuntu 12.04 上升级php版本的问题,下面是升级php到最新的版本的方法:
Please note: This works fine. But this package will also upgrade your apache to version 2.4 which has different config files than apache 2.2 and even deletes stuff, like /etc/apache2/sites-available/default when upgrading. This may result in a loss of your apache settings (vhost, mod_rewrite stuff etc.). Be aware of that ! This shit cost me a full weekend. This affects only upgrades, not fresh installs for sure.Update: This is a known bug (more here), I’ll keep this post updated…
How to install
There’s an excellent and (usually) hassle-free method to install the latest version of PHP5 (which is 5.5.3 when i’m writing this) with 3 simple bash commands:
1. Add this package-repository to your system. If Ubuntu says that you need to download a key first, then follow the instructions given in the notice.
sudo add-apt-repository ppa:ondrej/php5
If you get an error message now, then please do an update first and install the python-software-properties, that need to be necessary to add a package repository:
sudo apt-get update sudo apt-get install python-software-properties
2. Update
sudo apt-get update
3. Install PHP
sudo apt-get install php5
Check the installed version of PHP via
php5 -v
Please note: The ondrej/php5 repository (which is used here) provides the very latest version of PHP. Usually the new version of PHP is available a few days after it was been officially released. This is really cool and a big step forward as Ubuntu, Debian, CentOS etc. provide only very old versions by default.
[wp_ad_camp_2]
To UPDATE from PHP 5.3 / 5.4 to PHP 5.5:
It’s also possible to update from any PHP version to the latest one with exactly the commands above. But, after doing
sudo apt-get install php5
you’ll have to restart the server with
sudo /etc/init.d/apache2 restart
or
sudo service apache2 restart
By the way, I’ve also written a tutorial on “How to setup latest version of PHP 5.5 on Debian Wheezy 7.0/7.1/7.2 (and how to fix the GPG key error)“, which is different from this here.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
嘿嘿,照上面的更新之后可能会遇到问题,nginx 502 bad gateway错误,我就遇到了,下面的stack overflow上面的回答,完美解决!!
120down voteaccepted
|
If anyone finds this page by encountering the same problem I had, I found the answer here:http://www.howtoforge.com/installing-nginx-with-php5-and-php-fpm-and-mysql-support-lemp-on-ubuntu-12.04-lts For those of you who can't be bothered to click and work it out for themselves... ;) The Condition: Ubuntu or Debian server with NGINX and PHP 5.3 works fine but upgrading PHP to 5.4 gives 502 Bad Gateway errors. Looking for services running on port 9000 (typically running The fix: Open
and replace the fastcgi_pass variable in your vhost with the location you just noted. So this sample symfony2 configuration (taken from here: http://wiki.nginx.org/Symfony):
becomes this:
Then restart nginx:
Note: replace Hope this saves someone a little bit of time :) Edit Of course, you could change the Edit2 If you're still experiencing 502 error see this answer: nginx error connect to php5-fpm.sock failed (13: Permission denied) |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现