ubuntu12.10以后,默认的deb安装库上面的php版本已经是5.4了,公司的项目使用5.4的时候,还是会出现很多问题,所以不得不降级安装5.3

顺便说一句,我原来的环境是nginx + php5.4 + mysql 的,现在只是把php5.4降级到php5.3,其它的不修复。

新建一个叫做down_to_php53.sh,然后复制下面代码进去

#!/bin/bash
#
# Original for 5.3 by Ruben Barkow (rubo77) http://www.entikey.z11.de/
# release PHP5. to 5.3 by Emil Terziev ( foxy ) Bulgaria # Originally Posted by Bachstelze http://ubuntuforums.org/showthread.php?p=9080474#post9080474
# OK, here's how to do the Apt magic to get PHP packages from the precise repositories: echo "Am I root? "
if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then
echo " NO! Error: You must be root to run this script.
Enter
sudo su
"
exit
fi
echo " OK"; #install aptitude before, if you don`t have it:
apt-get update
apt-get install aptitude
# or if you prefer apt-get use:
# alias aptitude='apt-get' # finish all apt-problems:
aptitude update
aptitude -f install
#apt-get -f install # remove all your existing PHP packages. You can list them with dpkg -l| grep php
PHPLIST=$(for i in $(dpkg -l | grep php|awk '{ print $2 }' ); do echo $i; done)
echo these pachets will be removed: $PHPLIST
# you need not to purge, if you have upgraded from precise:
aptitude remove $PHPLIST
# on a fresh install, you need purge:
# aptitude remove --purge $PHPLIST #Create a file each in /etc/apt/preferences.d like this (call it for example /etc/apt/preferences.d/php5_2);
#
#Package: php5
#Pin: release a=precise
#Pin-Priority:
#
#The big problem is that wildcards don't work, so you will need one such stanza for each PHP package you want to pull from precise: echo ''>/etc/apt/preferences.d/php5_3
for i in $PHPLIST ; do echo "Package: $i
Pin: release a=precise
Pin-Priority:
">>/etc/apt/preferences.d/php5_3; done echo "# needed sources vor php5.3:
deb http://bg.archive.ubuntu.com/ubuntu/ precise main restricted
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise main restricted deb http://bg.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-updates main restricted deb http://bg.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise universe
deb http://bg.archive.ubuntu.com/ubuntu/ precise-updates universe
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-updates universe deb http://bg.archive.ubuntu.com/ubuntu/ precise multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://bg.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ natty-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse deb-src http://archive.canonical.com/ubuntu natty partner deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main deb http://bg.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://bg.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse deb http://archive.canonical.com/ubuntu precise partner
deb-src http://archive.canonical.com/ubuntu precise partner " >> /etc/apt/sources.list.d/precise.list aptitude update #apache2ctl restart echo install new from precise:
aptitude -t precise install $PHPLIST # at the end retry the modul libapache2-mod-php5 in case it didn't work the first time:
#aptitude -t precise install libapache2-mod-php5 #apache2ctl restart

然后执行

chmod +x down_to_php53.sh
sudo ./down_to_php53.sh

执行完之后,重启php5-fpm和ngnix

sudo /etc/init.d/php5-fpm restart
sudo /etc/init.d/nginx restart

这时,访问 http://127.0.0.1/,会出现502错误,查看ngnix日志,有如下问题

// :: [crit] #: * connect() to unix:/var/run/php5-fpm.sock failed (: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /phpinfo.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "127.0.0.1"
// :: [error] #: * rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1"

这是因为原来在nginx,我是这样配置的

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

使用socket来连接,所以降级之后,还要修改一下新的配置文件

vim /etc/php5/fpm/pool.d/www.conf

找到

listen = 127.0.0.1:

加入

listen = /var/run/php5-fpm.sock

就可以了

Have fun with Ubuntu!

[Ubuntu] ubuntu13.04 从php5.4降级到php5.3的更多相关文章

  1. [Ubuntu] Ubuntu13.04, the desktop freezed after login

    My os version is Ubuntu13.04, today, after started and logined, my desktop freezed. But i can still ...

  2. [Ubuntu] Ubuntu14.04 64bit 编译安装nginx1.7+php5.4+mysql5.6

    我的操作系统是Ubuntu14.04,其它linux系统的操作流程类似. 主要安装的软件是nginx1.7+php5.4+mysql5.6 1. 创建必要目录 sudo mkdir ~/setup s ...

  3. Ubuntu 18.04 将gcc版本降级为5.5版本

    Remark: Polynomial algebra 程序由于版本问题只能在gcc 5.0 版本运行, 而ubuntu更新会将gcc 更新到7.0版本,出现冲突(报错:如下) collect2: er ...

  4. [ubuntu] ubuntu13.04安装rabbitcvs管理svn

    加入源 sudo add-apt-repository ppa:rabbitvcs/ppa 更新 sudo apt-get update 安装软件 sudo apt-get install rabbi ...

  5. Ubuntu 16.04 环境下配置apache2.4 + php5.6

    相信用惯了Windows的朋友一开始接触Linux是很崩溃的,因为很多东西都是通过命令行来完成的,包括安装绝大多数的开发工具以及环境,那么在Ubuntu下其实可以直接通过apt-get指令来安装apa ...

  6. Ubuntu 16.04系统下安装PHP5.6*

    Ubuntu 16.04系统默认php7,并没有php5*的包,所以需要自己安装: 方法: 1.删除所有的php包列出安装的php包,dpkg -l | grep php| awk '{print $ ...

  7. 【转】How to build and install PHP 5.6.9 from source on Ubuntu 14.04 VPS

    原文 https://vpsineu.com/blog/how-to-build-and-install-php-5-6-9-from-source-on-ubuntu-14-04-vps/ In t ...

  8. Ubuntu 12.04 安装 Apache2+PHP5+MySQL

    LAMP是Linux web服务器组合套装的缩写,分别是Apache+MySQL+PHP.此教程教大家如何在Ubuntu 12.04 LTS server 上安装Apache2服务器,包括PHP5(m ...

  9. Ubuntu 16.04 LTS 降级安装GCC 4.8

    转载自https://www.linuxidc.com/Linux/2017-03/142299.htm Ubuntu 16.04 LTS 降级安装GCC 4.8 [日期:2017-03-28] 来源 ...

随机推荐

  1. iOS视图控制对象生命周期

    iOS视图控制对象生命周期-init.viewDidLoad.viewWillAppear.viewDidAppear.viewWillDisappear.viewDidDisappear的区别及用途 ...

  2. svn out of date

    out of date说明这个文件过期了,也就是已经有过一次提交的版本,当前提交的版本号小于当前的版本. 解决办法:先将文件update一下,然后再提交.

  3. mac共享文件给win7用户

    我的mac上有项目文件和配置好的php及其框架环境,需要让win7用户可以访问并且可以修改文件.前提是两个人在一个网段哦~ 1.首先将我的ip地址及域名放到win7用户的hosts下 . 地址是C:\ ...

  4. Quartz的配置文件quartz.properties详解

    配置 quartz.properties 文件 文件 quartz.properties 定义了 Quartz 应用运行时行为,还包含了许多能控制 Quartz 运转的属性.这个文件应该放在class ...

  5. 我的工具箱之Opera浏览器

    下载地址:http://pan.baidu.com/s/1gdVQA11 刚出来时挺火的,后来有点渐趋式微了.

  6. C#中派生类调用基类构造函数用法分析

    这里的默认构造函数是指在没有编写构造函数的情况下系统默认的无参构造函数 1.当基类中没有自己编写构造函数时,派生类默认的调用基类的默认构造函数例如: ? 1 2 3 4 5 6 7 8 9 10 11 ...

  7. LeetCode Course Schedule II

    原题链接在这里:https://leetcode.com/problems/course-schedule-ii/ 题目: There are a total of n courses you hav ...

  8. LeetCode Best Time to Buy and Sell Stock IV

    原题链接在这里:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/ 题目: Say you have an array ...

  9. php常用转义字符‘ “ {} $ \n

    php 单引号和双引号的区别: 双引号串中的内容可以被解释而且替换,而单引号串中的内容总被认为是普通字符. <?php $a = 'abc'; echo "<br>&quo ...

  10. Linux和Windows路由配置

    Linux和Windows路由配置 一.配置路由 1-       原则上一台主机只能有一条缺省路由.如果一台主机上有多个网段的话,请配置能够上网的那个网段的网关为缺省路由 Linux配置缺省路由: ...