The detailed method of Linux compiling and upgrading PHP _php Tips

Source: Internet
Author: User
Tags fpm ldap redis zts zend
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 5.5.0 provided by default 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 Code code as follows:

# Unzip installation package
Tar zxvf php-5.5.0.tar.gz

# Enter Directory
CD php-5.5.0

# Compile Installation
./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, and modify the corresponding directory path according to your situation
Don't forget to match opcache:–enable-opcache when installing
Php-5.3.10 was added with the –enable-safe-mode option at compile time, but php-5.4.0 has removed the option and can compile it./configure–help | grep "Safe-mode" view, no information output, said no support!
The same places: ' –enable-discard-path ', ' –enable-fastcgi ', ' –enable-force-cgi-redirect ', ' –with-curlwrappers '
2. Compile and install the php5.5.0 extension module:
Install Imagick
Install this module requires server support ImageMagick, here and upgrade PHP is irrelevant, this part of the omitted, please search yourself
Download Address: Http://pecl.php.net/package/imagick
Copy Code code 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 there is an error in the installation, make: * * * [Imagick_file.lo] 1, please call Pkgconfig
Please modify the above directory path according to your personal situation
Install Memcache:
Install this module requires server support memcached, here and upgrade PHP is irrelevant, this part of the omitted, please search yourself
Download Address: Http://pecl.php.net/package/memcache
Copy Code code 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
Install Phpredis-master
Install this module requires server support Redis, here and upgrade PHP is irrelevant, this part of the omitted, please search yourself
Download Address: Https://github.com/nicolasff/phpredis
Copy Code code 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 Code code 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"

Configure Zend Opcache
It has always been customary to use eaccelerator to speed up PHP, but now there are two issues:
Eaccelerator is temporarily incompatible php5.5.0
Eaccelerator and Zend Opcache conflict
Fortunately php5.5.0 default provides Zend Opcache for PHP acceleration, the configuration method is as follows:
Copy Code code 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 description does not succeed in your PHP extension module, please reinstall
4. Configure php-fpm.conf
Copy Code code 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 entry:
Copy Code code as follows:

cp/usr/local/webserver/php-d/php-5.5.0/bin/php/etc/init.d/php

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.