Upgrade php5.2 to php5.4 in Centos (compilation and installation). php5.2php5.4 _ PHP Tutorial

Source: Internet
Author: User
Tags apc zts
Upgrade php5.2 to php5.4 in Centos (compilation and installation) and php5.2php5.4. Upgrade php5.2 to php5.4 in Centos (compilation and installation). although php5.2php5.4 is the latest php version, it is more reliable to upgrade php to php5.4 first for various considerations. Upgrade php5.2 to php5.4 in Centos (compilation and installation), and php5.2php5.4

Upgrade

Although php is the latest version of php5.5, it is more reliable to upgrade php to php5.4 first for various considerations.
The original php uses php5.2.10 and has been running 4 ~ 5 years later, it is time to upgrade.

5.4 The latest stable version is 5.4.21 (14 Nov 2013 released 5.4.22 ...)
The code is as follows:
Wget http://cn2.php.net/get/php-5.4.21.tar.gz/from/this/mirror
Tar zxf php-5.4.21.tar.gz
Cd php-5.4.21

Modify the source code. if the program code is UTF-8, skip this step.

If your program uses GBK by default and many use htmlspecialchars in the program, we recommend that you modify the source code directly because 5.4 is UTF-8 by default. All output using htmlspecialchars will be empty.
The code is as follows:
Ext/standard/html. c
Line 372
/* Default is now UTF-8 */
If (charset_hint = NULL)
Return cs_utf_8;
--->
/* Default is now UTF-8 */
If (charset_hint = NULL)
Return cs_8859_1;

Resolves the problem of htmlspecialchars default UTF-8.
The code is as follows:
. /Configure -- prefix =/usr/local/php5.4 -- with-zlib -- enable-bcmath -- with-curl -- with-curlwrappers -- enable-mbregex -- enable-mbstring -- with-gd -- enable-gd-native-ttf -- with-openssl -- with-mhash -- enable-sockets -- with-xmlrpc -- enable-zip -- enable-soap -- without-pear -- with-mysql -- with-mysqli -- with-pdo-mysql -- enable-ftp -- with-jpeg-dir -- with-freetype-dir -- with-png-dir -- enable-fpm -- with-fpm- user = www -- with-fpm-group = www

Simplified installation parameters:
The code is as follows:
./Configure -- prefix =/usr/local/php5.4 -- enable-fpm -- with-mysql
Make ZEND_EXTRA_LIBS = '-liconv'
Make install

-----------------------
Move the two default files to the correct place. check whether php. ini-development or php. ini-production is correct.
The code is as follows:
Cd/usr/local/php5.4/etc/
Cp php-fpm.conf.default php-fpm.conf
Cp/www/soft/php-5.4.21/php. ini-development/usr/local/php5.4/lib/php. ini

------------------------------
Php-fpm.conf in
Listen. allowed_clients = before 127.0.0.1; remove
---------------------

Php. ini
The code is as follows:
Short_open_tag = Off

Change
The code is as follows:
Short_open_tag = On

The code is as follows:
; Date. timezone =

Change
The code is as follows:
Date. timezone = "Asia/Shanghai"

The code is as follows:
Error_reporting = E_ALL

Change
The code is as follows:
Error_reporting = E_ALL &~ E_NOTICE

Add to startup service list
The code is as follows:
Cp-f/www/soft/php-5.4.21/sapi/fpm/init. d. php-fpm/etc/init. d/php-fpm
Chmod 755/etc/init. d/php-fpm
Chkconfig -- add php-fpm
Chkconfig php-fpm on

Start php-fpm:
The code is as follows:
Service php-fpm start

Php upgrade complete!
------------------------------------------------------
Zend Opcache is an Optmizer of PHP provided in the form of extensions. it also performs a lot of compilation optimization and has no compatibility issues, according to the maintainer Laruence. compared with APC, it is faster than 7%. however, it does not provide apc_store user data Cache. To use apc user cache, you can use APCU or Laruence Yac together.
The code is as follows:
Wget http://pecl.php.net/get/ZendOpcache
Tar zxf ZendOpcache
Cd zendopcache-7.0.2/
/Usr/local/php5.4/bin/phpize
./Configure -- with-php-config =/usr/local/php5.4/bin/php-config
Make
Make install
Installing shared extensions:/usr/local/php5.4/lib/php/extensions/no-debug-non-zts-20100525/

Php. ini is directly added to the bottom.
The code is as follows:
Zend_extension =/usr/local/php5.4/lib/php/extensions/no-debug-non-zts-20100525/opcache. so
Opcache. memory_consumption = 128
Opcache. interned_strings_buffer = 8
Opcache. max_accelerated_files = 4000
Opcache. revalidate_freq = 60
Opcache. fast_shutdown = 1
Opcache. enable_cli = 1
Opcache. save_comments = 0
Opcache. enable_file_override = 1
Service php-fpm reload

Here, phpinfo () contains with Zend OPcache v7.0.2 and many related parameters.


In this case, PHP 5.4 is upgraded.
--------------------------------

Possible errors:

An error occurred while starting php-fpm.
The code is as follows:
Starting php-fpm/etc/init. d/php-fpm: line 53: 12483 Segmentation fault $ php_fpm_BIN -- daemonize $ php_opts
Failed

If APC and Zend opcache are installed at the same time, conflicts may occur. if Zend opcache is installed, APC does not need to be installed.

Compile (compile and install), php5.2php5.4 upgrade the latest php version, although it is php5.5, but for various considerations, it is more reliable to upgrade to php5.4 first. Original...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.