Upgrade online server php5.3.8 to php5.6.3

Source: Internet
Author: User
Upgrade online server php5.3.8 to php5.6.3 server type CentOS 6.5

Because the project needs to use new features such as php5.4 and above, the current server still uses php5.3.8, so the upgrade is required.


First, connect to the server, first disable the php-fpm service, and then rename/usr/local/php to prevent rollback if the new version fails to be updated.


mv /usr/local/php  /usr/local/php5.3.8

Download the latest php5.6.3 and decompress it.


wget  http://www.php.net/distributions/php-5.6.3.tar.gztar -zxvf  php-5.6.3.tar.gz

Because it is an upgrade, I have installed many php dependency packages and attached my configure configuration parameters first.

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-fpm-user=www --with-fpm-group=www  --enable-fpm --enable-opcache --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --disable-fileinfo   --with-iconv-dir=/usr/local  --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml   --disable-rpath --enable-bcmath --enable-shmop --enable-exif --enable-sysvsem --enable-inline-optimization --with-curl   --enable-mbregex --enable-mbstring  --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash  --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-gettext --enable-zip --enable-soap --disable-ipv6  --disable-debug

Note that opcache can be switched to opcode to improve php performance.

Also -- disable-debug -- disable-ipv6 disable debug ipv6 can improve performance


The first make error occurred.

ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor':/home/king/php-5.2.13/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open'collect2: ld returned 1 exit statusmake: *** [sapi/cli/php] Error 1


Online Solutions

At? If an error message such as "undefined reference to libiconv_open" occurs when PHP is in the system, it indicates "./configure 」? Do a good job of changing the environment value. The error occurs when "-o sapi/cli/php" is created? To the iconv function library parameter to be linked. Solution: edit Makefile about 77 rows: EXTRA_LIBS = ..... -added-liconv to the end of lcrypt, for example: EXTRA_LIBS = ..... -lcrypt-liconv: make it again.

Then, make passed successfully.


Make clean # clear the obj file generated in the previous compilation. make ZEND_EXTRA_LIBS = '-liconv' make install

The specific parameters of php. ini under configuration optimization can be easily understood by Baidu.

sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' /usr/local/php/etc/php.inised -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' /usr/local/php/etc/php.inised -i 's@^short_open_tag = Off@short_open_tag = On@' /usr/local/php/etc/php.inised -i 's@^expose_php = On@expose_php = Off@' /usr/local/php/etc/php.inised -i 's@^request_order.*@request_order = "CGP"@' /usr/local/php/etc/php.inised -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' /usr/local/php/etc/php.inised -i 's@^post_max_size.*@post_max_size = 50M@' /usr/local/php/etc/php.inised -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' /usr/local/php/etc/php.inised -i 's@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' /usr/local/php/etc/php.inised -i 's@^max_execution_time.*@max_execution_time = 5@' /usr/local/php/etc/php.inised -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' /usr/local/php/etc/php.inised -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' /usr/local/php/etc/php.inised -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' /usr/local/php/etc/php.ini

I installed the opcache module. set it here.

sed -i 's@^\[opcache\]@[opcache]\nzend_extension=opcache.so@' $php_install_dir/etc/php.inised -i 's@^;opcache.enable=.*@opcache.enable=1@' $php_install_dir/etc/php.inised -i "s@^;opcache.memory_consumption.*@opcache.memory_consumption=128" $php_install_dir/etc/php.inised -i 's@^;opcache.interned_strings_buffer.*@opcache.interned_strings_buffer=8@' $php_install_dir/etc/php.inised -i 's@^;opcache.max_accelerated_files.*@opcache.max_accelerated_files=4000@' $php_install_dir/etc/php.inised -i 's@^;opcache.revalidate_freq.*@opcache.revalidate_freq=60@' $php_install_dir/etc/php.inised -i 's@^;opcache.save_comments.*@opcache.save_comments=0@' $php_install_dir/etc/php.inised -i 's@^;opcache.fast_shutdown.*@opcache.fast_shutdown=1@' $php_install_dir/etc/php.inised -i 's@^;opcache.enable_cli.*@opcache.enable_cli=1@' $php_install_dir/etc/php.inised -i 's@^;opcache.optimization_level.*@;opcache.optimization_level=0@' $php_install_dir/etc/php.ini

Generate the php-fpm file

vim /usr/local/php/etc/php-fpm.conf[global]pid = /usr/local/php/var/run/php-fpm.piderror_log = /usr/local/php/var/log/php-fpm.loglog_level = notice[www]listen = /tmp/php-cgi.socklisten.backlog = -1listen.allowed_clients = 127.0.0.1listen.owner = wwwlisten.group = wwwlisten.mode = 0666user = wwwgroup = wwwpm = dynamicpm.max_children = 10pm.start_servers = 2pm.min_spare_servers = 1pm.max_spare_servers = 6request_terminate_timeout = 100request_slowlog_timeout = 0slowlog = var/log/slow.log

Add to system service

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpmchkconfig --add php-fpm chkconfig php-fpm on

Started.

 service  php-fpm start   


Last post a phpinfo image





OK. You have successfully upgraded from php5.3.8 to php5.6.3.

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.