Home  >  Article  >  Backend Development  >  Detailed method of compiling and upgrading PHP on Linux_PHP Tutorial

Detailed method of compiling and upgrading PHP on Linux_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:25:36913browse

Server environment: CentOS – 5.4
php upgrade: 5.4.14 – 5.5.0
Upgrade experience: relatively smooth, but there is one thing that needs to be explained: eaccelerator is not compatible with php5.5.0. Fortunately, php is provided by default in 5.5.0 Zend OPcache, so friends who have been accustomed to eaccelerator may have to say bye bye to eaccelerator temporarily if they want to upgrade to php5.5.0.
1. Install php5.5.0
Download the php installation package: http://www.php.net/get/php-5.5.0.tar.gz/from/a/mirror

Copy code The code is as follows:

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

# Enter the 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

There are several places that need to be explained:
When installing, please add according to your own situation, Delete the additional components and modify the corresponding directory path
Don’t forget to match opcache when installing: –enable-opcache
php-5.3.10 added the –enable-safe-mode option when compiling, but php-5.4. 0 has removed this option. When compiling, you can check it with ./configure –help | grep “safe-mode”. If there is no information output, it means it is no longer 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:
Install imagick
Installing this module requires the server to support ImageMagick. This has nothing to do with upgrading php. This part is omitted. If necessary, please search by yourself
Download address: http: //pecl.php.net/package/imagick
Copy code The 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

Note:
To avoid compatibility issues, please use the latest version, please do not use versions before 3.0.1
If an error is reported during installation make: *** [imagick_file.lo] Error 1, please call pkgconfig
Please modify the above directory path according to your personal situation
Install memcache:
Installing this module requires the server to support memcached. This has nothing to do with upgrading php. This part is omitted. If necessary, please search by yourself
Download address: http://pecl.php.net/package/memcache
Copy code The 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 versions 2.2.6 and below, which are incompatible
Install phpredis-master
Installing this module requires the server to support redis. This has nothing to do with upgrading php. This part is omitted. If necessary, please search for it yourself
Download Address: https://github.com/nicolasff/phpredis
Copy code The 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 required modules are installed complete.
3. Configure php.ini
Copy the code The 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
I have always been accustomed to using eAccelerator to provide acceleration for php, but there are currently two problems:
eAccelerator is temporarily incompatible with php5.5.0
eAccelerator conflicts with Zend Opcache
Fortunately php5.5.0 provides Zend Opcache for PHP acceleration by default. The configuration method is as follows:
Copy the code The 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 above zend_extension path is the path of 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 opcache.so is not found in your php extension module, it means the installation was not successful, please reinstall
4. Configure php-fpm.conf
Copy code The 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_F les = 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 startup items:
Copy the code The code is as follows:

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825010.htmlTechArticleServer environment: CentOS – 5.4 php upgrade: 5.4.14 – 5.5.0 Upgrade experience: relatively smooth, but there are One thing to note: eaccelerator is not compatible with php5.5.0. Fortunately, php is provided by default in 5.5.0...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn