Table of Contents
Linux PHP5.3升级PHP5.5.33,php5.3php5.5.33
Home php教程 php手册 Linux PHP5.3升级PHP5.5.33,php5.3php5.5.33

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

Jun 13, 2016 am 08:43 AM
php5

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原创文章,如转载请注明出处。

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between php5 and php8 What is the difference between php5 and php8 Sep 25, 2023 pm 01:34 PM

The differences between php5 and php8 are in terms of performance, language structure, type system, error handling, asynchronous programming, standard library functions and security. Detailed introduction: 1. Performance improvement. Compared with PHP5, PHP8 has a huge improvement in performance. PHP8 introduces a JIT compiler, which can compile and optimize some high-frequency execution codes, thereby improving the running speed; 2. Improved language structure, PHP8 introduces some new language structures and functions. PHP8 supports named parameters, allowing developers to pass parameter names instead of parameter order, etc.

How to change port 80 in php5 How to change port 80 in php5 Jul 24, 2023 pm 04:57 PM

How to change port 80 in php5: 1. Edit the port number in the Apache server configuration file; 2. Edit the PHP configuration file to ensure that PHP works on the new port; 3. Restart the Apache server, and the PHP application will start running on the new port. run on the port.

What is the difference between php7 and php5 syntax What is the difference between php7 and php5 syntax Jul 10, 2023 pm 03:25 PM

The syntax differences between php7 and php5 are: 1. PHP7 introduces strict type declarations, while the type of PHP5 variables is implicit; 2. PHP7 introduces support for scalar type declarations, but PHP5 does not; 3. PHP7 introduces NULL Merge operator, while PHP5 checks whether a variable exists and is not null, you need to use a conditional statement; 4. PHP7 adds a new comparison operator "<=>", but PHP5 does not; 5. PHP7 introduces a new feature anonymous class , while PHP5 does not.

How to solve the problem that php5 is not listening on port 9000 How to solve the problem that php5 is not listening on port 9000 Jul 10, 2023 pm 04:01 PM

Solution steps for php5 not listening to port 9000: 1. Check the PHP-FPM configuration file; 2. Restart the PHP-FPM service; 3. Turn off the firewall or configure port forwarding; 4. Check whether other processes occupy port 9000.

How to change port 80 in php5 How to change port 80 in php5 Mar 21, 2023 pm 04:32 PM

​If you are a website administrator, you may encounter a situation where you need to change the PHP5 port from the default port 80. This process may be a little hurried, but as long as you follow the steps below, it will be easily completed.

How to solve the problem that php5 is not listening on port 9000 How to solve the problem that php5 is not listening on port 9000 Mar 21, 2023 pm 04:32 PM

When using PHP5, some users may encounter the situation that port 9000 cannot be listened to. At this time, we need to perform some configuration and troubleshooting work to solve this problem.

What are the differences between the version of php7 and 5? What are the differences between the version of php7 and 5? Sep 15, 2023 pm 04:11 PM

The differences between the version of php7 and 5 include performance improvements, scalar type declarations, return value type declarations, exception handling improvements, anonymous classes, syntax improvements, new operators, enhanced error handling and the removal of some old features. Detailed introduction: 1. Performance improvement. PHP7 introduces a new Zend engine, named Zend Engine 3.0, which brings significant performance improvement. The performance of PHP7 is approximately twice that of PHP5, mainly through improved memory management. , optimized function calls and exception handling, enhanced garbage collection, etc.

Discuss the syntax differences between PHP7 and PHP5 Discuss the syntax differences between PHP7 and PHP5 Mar 21, 2023 pm 07:10 PM

PHP is a widely used server-side programming language used to develop dynamic websites and applications. In recent years, the release of PHP7 has attracted some attention. PHP7 has many improvements and optimizations over previous versions (such as PHP5). In this article, we will explore the syntax differences between PHP7 and PHP5.

See all articles