Linux Compilation Upgrade PHP detailed method _php Tutorial

Source: Internet
Author: User
Tags ldap zts
Server environment: centos–5.4
PHP Upgrade: 5.4.14-5.5.0
Upgrade experience: Relatively smooth, but there is a point to note: Eaccelerator can not be compatible with php5.5.0, fortunately, PHP 5.5.0 by default provides Zend Opcache, So have been accustomed to eaccelerator friends if you want to upgrade to php5.5.0, may be temporarily and Eaccelerator said bye bye.
1, installation php5.5.0
Download PHP installation package: Http://www.php.net/get/php-5.5.0.tar.gz/from/a/mirror
Copy CodeThe code is as follows:
# Unzip the installation package
Tar zxvf php-5.5.0.tar.gz

# Enter Directory
CD php-5.5.0

# Compile and install
./configure \
--prefix=/usr/local/webserver/php-d/php-5.5.0 \
--WITH-CONFIG-FILE-PATH=/USR/LOCAL/WEBSERVER/PHP-D/PHP-5.5.0/ETC \
--WITH-CONFIG-FILE-SCAN-DIR=/USR/LOCAL/WEBSERVER/PHP-D/PHP-5.5.0/ETC/PHP.D \
--with-curl=/usr/local/lib \
--WITH-FREETYPE-DIR=/USR/LIB64 \
--WITH-GD \
--with-gettext \
--with-iconv-dir=/usr/local/lib \
--WITH-JPEG-DIR=/USR/LIB64 \
--with-kerberos \
--WITH-LDAP \
--WITH-LDAP-SASL \
--WITH-LIBDIR=LIB64 \
--WITH-LIBXML-DIR=/USR/LIB64 \
--with-mcrypt \
--with-mhash \
--with-mysql \
--WITH-MYSQLI \
--WITH-OPENSSL \
--WITH-PCRE-REGEX=/USR \
--with-pdo-mysql=shared \
--with-pdo-sqlite=shared \
--with-pear=/usr/local/lib/php \
--WITH-PNG-DIR=/USR/LIB64 \
--WITH-XMLRPC \
--with-xsl \
--with-zlib \
--ENABLE-FPM \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--ENABLE-GD-NATIVE-TTF \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--ENABLE-PCNTL \
--ENABLE-SHMOP \
--ENABLE-SOAP \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip \
--disable-rpath

Make zend_extra_libs= ' Liconv '
Make install
CP Php.ini-production/usr/local/webserver/php-d/php-5.5.0/etc/php.ini

Here are a few places to explain:
When installing, add, remove additional builds, and modify the corresponding directory path as you see fit
When installing, don't forget to match opcache:–enable-opcache.
Php-5.3.10 compiled with the –enable-safe-mode option, but php-5.4.0 has removed the option, which can be compiled at compile time./configure–help | grep "Safe-mode" to see, there is no information output, indicating that it is not supported!
The same places are: ' –enable-discard-path ', ' –enable-fastcgi ', ' –enable-force-cgi-redirect ', ' –with-curlwrappers '
2. Compile and install the php5.5.0 extension module:
Installing Imagick
Install this module need server support ImageMagick, here and upgrade PHP unrelated, this part omitted, need to search by yourself
Download Address: Http://pecl.php.net/package/imagick
Copy CodeThe code is as follows:
Tar xvzf imagick-3.1.0rc2.tgz
CD IMAGICK-3.1.0RC2
/usr/local/webserver/php-d/php-5.5.0/bin/phpize
Export pkg_config_path=/usr/local/lib/pkgconfig/
./configure--with-php-config=/usr/local/webserver/php-d/php-5.5.0/bin/php-config
Make
Make install

Attention:
Avoid compatibility issues, please use the latest version, please do not use the previous version of 3.0.1
If an error occurred while installing: * * * [Imagick_file.lo] Error 1, please call Pkgconfig
Please modify the above directory path according to your personal situation
Install Memcache:
Install this module need server support memcached, here and upgrade PHP unrelated, this part omitted, need to search by yourself
Download Address: Http://pecl.php.net/package/memcache
Copy CodeThe code is as follows:
Tar xvzf memcache-3.0.tgz
CD memcache-3.0.8
/usr/local/webserver/php-d/php-5.5.0/bin/phpize
./configure \
--enable-memcache \
--with-php-config=/usr/local/webserver/php-d/php-5.5.0/bin/php-config
Make
Make install

Note: Please do not use 2.2.6 and the following versions, incompatible
Installing Phpredis-master
Installing this module requires the server to support Redis, which is not related to the upgrade of PHP, this part omitted, please search by yourself
Download Address: Https://github.com/nicolasff/phpredis
Copy CodeThe code is as follows:
Unzip Master
CD Phpredis-master
/usr/local/webserver/php-d/php-5.5.0/bin/phpize
./configure \
--enable-redis \
--with-php-config=/usr/local/webserver/php-d/php-5.5.0/bin/php-config
Make
Make install

At this point, all the required modules are installed.
3. Configure PHP.ini
Copy CodeThe code is as follows:
Vi/usr/local/webserver/php-d/php-5.5.0/etc/php.ini

# Find Extension_dir
Extension_dir = "/usr/local/webserver/php-d/php-5.5.0/lib/php/extensions/no-debug-non-zts-20121212/"

Extension = "imagick.so"
Extension = "memcache.so"
Extension = "pdo_mysql.so"
Extension = "redis.so"

# Find Date.timezone
Date.timezone = Asia/shanghai

# Find Session.save_handler
Session.save_handler = Redis

# Find Session.save_path
Session.save_path = "Tcp://127.0.0.1:6379?weight=1"

Configuring Zend Opcache
has always been accustomed to using eaccelerator to provide acceleration for PHP, but there are two problems:
Eaccelerator temporarily incompatible php5.5.0
Eaccelerator and Zend Opcache conflict
Fortunately, the php5.5.0 default provides Zend Opcache for PHP acceleration, the configuration method is as follows:
Copy CodeThe code is as follows:
Zend_extension =/usr/local/webserver/php-d/php-5.5.0/lib/php/extensions/no-debug-non-zts-20121212/opcache.so
; The path above zend_extension path is 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

Note: If the opcache.so instructions are not found in your PHP extension, please reinstall
4. Configure php-fpm.conf
Copy CodeThe code is as follows:
PID =/usr/local/webserver/php-d/php-5.5.0/var/run/php-fpm.pid
Error_log =/usr/local/webserver/php-d/php-5.5.0/logs/php-fpm.log

Log_level = Notice

Emergency_restart_threshold = 10
Emergency_restart_interval = 60s

Process_control_timeout = 5s
Daemonize = yes

Rlimit_files = 65535
Rlimit_core = 0

user = www
Group = www

Listen.backlog =-1
Listen.owner = www
Listen.group = www
Listen.mode = 0666
Listen.allowed_clients = 127.0.0.1

PM = static
Pm.max_children = 64
Pm.start_servers = 20
Pm.min_spare_servers = 5
Pm.max_spare_servers = 35
Pm.max_requests = 1024

Ping.response = Pong
Slowlog =/usr/local/webserver/php-d/php-5.5.0/logs/$pool. Log.slow
Request_slowlog_timeout = 0
Request_terminate_timeout = 0
Catch_workers_output = yes

Env[hostname] = $HOSTNAME
Env[path] =/usr/local/bin:/usr/bin:/bin
ENV[TMP] =/tmp
ENV[TMPDIR] =/tmp
ENV[TEMP] =/tmp

Php_admin_value[sendmail_path] =/usr/sbin/sendmail-t-i-f jht2718@163.com
Php_flag[display_errors] = On

Note: Please modify the configuration file according to your own situation
5. Modify the Startup item:
Copy CodeThe code is as follows:
cp/usr/local/webserver/php-d/php-5.5.0/bin/php/etc/init.d/php

http://www.bkjia.com/PHPjc/825010.html www.bkjia.com true http://www.bkjia.com/PHPjc/825010.html techarticle Server environment: centos–5.4 PHP Upgrade: 5.4.14-5.5.0 Upgrade experience: relatively smooth, but there is a point to note: Eaccelerator can not be compatible with php5.5.0, fortunately, PHP in the 5.5.0 default mention ...

  • 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.