Home > Article > Backend Development > Linux PHP5.3 upgrade to PHP5.5.33, php5.3php5.5.33_PHP tutorial
Due to using laravel5.1, php needs to be upgraded to 5.5 or above. The specific environment is Aliyun Cent OS 7.0. Since Alibaba's yum source lastest is only 5.4, laravel5.1 requires php5.5, and several online yum sources have been added, which causes various problems, so I can only compile and install them.
First of all, there are many such articles on the Internet. Everyone’s purpose of upgrading and the components to be upgraded are not exactly the same. The best documentation is the official installation document. If the installation on the official PHP website fails, search for related issues. What I finally relied on was the document Apache 2.x on Unix systems on the official website.
1. Download
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>
2. Compile and install
#这一步出错了#############################<br />./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql<br />#这一步出错率#############################
I had a problem with the --with-apxs2=/usr/local/apache2/bin/apxs step. Even if I remove this parameter, the installation will not work. This parameter compiles libphp5.so and uses it in httpd.conf. Find No results found for / -name apxs2. I searched for a long time and found that there was a problem with my apache. I don’t know why there was no such problem in 5.3 (I don’t care).
<span>yum</span> <span>install</span> httpd-devel
Although apxs2 is still not available, apxs can be found:
<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
The next few steps will be done step by step, which is quite time-consuming:
<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>
If you get similar results, the installation is successful:
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/
3. Configuration
Copy php.ini
#This location must not be wrong. I did not specify the location of php.ini when compiling .configure. The default location is here.
#If you skip this step, there will be no problems later, but you will need to use php in the future. ini, such as installing extensions, etc., it will be invalid if you modify /etc/php.ini (your original one).
cp php.ini-development /usr/local/lib/php.ini
#Here I suggest changing the original php.ini, so that it will not affect future find
#Your original one is not It must be here, I suggest you find it
mv /etc/php.ini /etc/php.ini.back
Modify 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
Restart apache:
service httpd restart
Test it:
php -v
Create a new phpinfo.php and visit:
<?<span>php </span><span>echo</span> <span>phpinfo</span>();
Perfect result:
You may need to install some dependencies, such as gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap. Leave these to yum.
dreamingodd original article, please indicate the source if reprinted.