Home > php教程 > php手册 > body text

Linux PHP5.3升级PHP5.5.33,php5.3php5.5.33

WBOY
Release: 2016-06-13 08:43:03
Original
1180 people have browsed it

Linux PHP5.3升级PHP5.5.33,php5.3php5.5.33

由于要使用了laravel5.1,php要升级到5.5以上。具体环境是Aliyun Cent OS 7.0。由于阿里的yum源lastest只有5.4,laravel5.1必须php5.5,加了几个网上的yum源,各种各样的问题,所以只能麻烦的编译安装了。

首先网上这类的文章非常多,每个人的升级目的,要升级的组件都不完全一样。最好的说明文档还是官方安装文档,如果php官网的安装失败,再去搜索相关问题。我最终靠的是官网上Apache 2.x on Unix systems这篇文档。

1.下载

http://php.net/downloads.php

<span>1</span> <span>wget</span> http:<span>//</span><span>cn2.php.net/get/php-5.5.33.tar.gz/from/this/mirror</span>
<span>2</span> <span>#下载完改一下名字
</span><span>3</span> <span>mv</span> mirror php-<span>5.5</span>.<span>33</span>.<span>tar</span><span>.gz
</span><span>4</span> <span>tar</span> -zxf php-<span>5.5</span>.<span>33</span>.<span>tar</span>.gz php-<span>5.5</span>.<span>33</span>
<span>5</span> cd php-<span>5.5</span>.<span>33</span>
Copy after login

2.编译安装

#这一步出错了#############################<br />./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql<br />#这一步出错率#############################
Copy after login

我在--with-apxs2=/usr/local/apache2/bin/apxs这一步出了问题,去掉这个参数即使安装也是不行,这个参数编译出libphp5.so并用在httpd.conf中,find / -name apxs2搜不到结果。我找了很久,发现是我的apache有问题,不知道为什么5.3的时候没有这个问题(不管了)。

<span>yum</span> <span>install</span> httpd-devel
Copy after login

虽然apxs2还是没有,但能找到apxs了:

<span>1</span> <span>find</span> / -<span>name apxs2
</span><span>2</span> <span>find</span> / -<span>name apxs
</span><span>3</span> /usr/bin/apxs
Copy after login

接下来几步一点点来,比较耗时:

<span>1</span> ./configure --with-apxs2=/usr/bin/apxs --with-<span>mysql
</span><span>2</span> <span>make</span>
<span>3</span> <span>make</span> <span>install<br /><br /><span>#之后发现单独编译pdo_mysql扩展有问题,换了这句重新编译</span><br /><span>#./configure --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=/usr/bin/apxs</span><br /></span>
Copy after login

得到类似结果为安装成功:

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-<span>20121212</span>/<span>
...
...
...
Wrote PEAR system config </span><span>file</span> at: /usr/local/etc/<span>pear.conf
You may want to add: </span>/usr/local/lib/<span>php to your php.ini include_path
</span>/usr/local/src/php-<span>5.5</span>.<span>33</span>/build/shtool <span>install</span> -c ext/phar/phar.phar /usr/local/<span>bin
</span><span>ln</span> -s -f phar.phar /usr/local/bin/<span>phar
Installing PDO headers:          </span>/usr/local/include/php/ext/pdo/
Copy after login

3.配置

复制php.ini

#这个位置一定不能错,编译.configure的时候我没有制定php.ini的位置,默认就是这里,
#如果跳过这一步,后面不会出问题,但是你将来该php.ini,比如安装扩展什么的,去修改/etc/php.ini(你原来的)的话都是无效的。
cp php.ini-development /usr/local/lib/php.ini
#这里我建议把原来的php.ini改掉,这样不会影响以后的find
#你的原来不一定是这里,建议find一下
mv /etc/php.ini /etc/php.ini.back

修改httpd.conf

<span>find</span> / -<span>name httpd.conf
</span><span>vi</span> /etc/httpd/conf/<span>httpd.conf
#加入这两句(310行左右)
AddType application</span>/x-httpd-<span>php .php .php3 .phtml .inc
AddType application</span>/x-httpd-php-<span>source .phps
#可能是升级的原因,这一句我本来就有,没有要加(50行左右)
LoadModule php5_module </span>/usr/lib64/httpd/modules/libphp5.so
Copy after login

重启apache:

service httpd restart
Copy after login

测试一下:

php -v
Copy after login

新建一个phpinfo.php访问一下:

<?<span>php
</span><span>echo</span> <span>phpinfo</span>();
Copy after login

结果完美:

 

可以需要安装一些依赖,如gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap,这些就交给yum吧。

 

dreamingodd原创文章,如转载请注明出处。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!