Linux under the PHP 5.4.* compile installation steps detailed

Source: Internet
Author: User

It is said that php5.4 is faster than the previous versions of PHP, so it is necessary to install to test (domestic more popular PHP programs such as Discuz and so on php5.4 support seems not too friendly, so webmaster friends or to be cautious upgrade). The following is a note that compiles the installation on 64-bit centos6.1, for informational purposes only.

1, download

wget Http://cn.php.net/get/php-5.4.8.tar.gz/from/this/mirror
wget http://pecl.php.net/get/memcache-2.2.7.tgz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
wget https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
wget https://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
wget "Http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0"
wget "Http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0"
wget ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick.tar.gz
wget "Http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0"
wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz

2. Some other preparatory work

Yum install ncurses-devel libxml2-devel bzip2-devel libcurl-devel curl-devel libjpeg-devel libpng-devel freetype-devel Net-snmp-devel-y

Ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib64/(assuming MySQL is installed.) If you do not add this, you may be able to make mistakes when compiling later.

3, and these preparations (compile some PHP need to use the support library)

Tar xzvf libic*
CD libic*
./configure--prefix=/usr/local
Make
Make install
Cd..

Tar xzvf libmcry*
CD libmcry*
./configure
Make
Make install
/sbin/ldconfig
CD libltdl/
./configure
--enable-ltdl-install
Make
Make install
Cd.. /.. /

Tar zxvf mhash-0.9.9.9.tar.gz
CD mhash-0.9.9.9/
./configure
Make
Make install
Cd.. /

Ln-s/usr/local/lib/libmcrypt.la/usr/lib/libmcrypt.la
Ln-s/usr/local/lib/libmcrypt.so/usr/lib/libmcrypt.so
Ln-s/usr/local/lib/libmcrypt.so.4/usr/lib/libmcrypt.so.4
Ln-s/usr/local/lib/libmcrypt.so.4.4.8/usr/lib/libmcrypt.so.4.4.8
Ln-s/USR/LOCAL/LIB/LIBMHASH.A/USR/LIB/LIBMHASH.A
Ln-s/usr/local/lib/libmhash.la/usr/lib/libmhash.la
Ln-s/usr/local/lib/libmhash.so/usr/lib/libmhash.so
Ln-s/usr/local/lib/libmhash.so.2/usr/lib/libmhash.so.2
Ln-s/usr/local/lib/libmhash.so.2.0.1/usr/lib/libmhash.so.2.0.1
Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config

Tar zxvf mcrypt-2.6.8.tar.gz
CD mcrypt-2.6.8/
/sbin/ldconfig
./configure
Make
Make install
Cd.. /

4. Start compiling and installing PHP

Tar xvzf php-5.4.*.tar.gz CD php-5.4.*

./configure--prefix=/usr/local/php--with-config-file-path=/etc \
--with-mysql=/usr/local/mysql/--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql/--with-iconv-dir=/usr/local--enable-fpm \
--disable-phar--with-fpm-user=www--with-fpm-group=www--with-pcre-regex \
--with-zlib--with-bz2--enable-calendar--with-curl--enable-dba--with-libxml-dir \
--enable-ftp--with-gd--with-jpeg-dir--with-png-dir--with-zlib-dir--with-freetype-dir \
--enable-gd-native-ttf--enable-gd-jis-conv--with-mhash--enable-mbstring--with-mcrypt \
--enable-pcntl--enable-xml--disable-rpath--enable-shmop--enable-sockets--enable-zip \
--enable-bcmath--with-snmp--disable-ipv6

Make zend_extra_libs= '-liconv '

Make Test

Make install

CP Php.ini-production/etc/php.ini

5. Compile and install some of the extension modules of PHP

Tar zxvf memcache-*.tgz
CD memcache-*/
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
Make
Make install
Cd.. /

Tar xzvf libevent*
CD libevent*
./configure--prefix=/usr/local
Make
Make install
Cd..

Tar xvzf memcached-*.gz
CD memcached-*
./configure--with-libevent=/usr/local--prefix=/usr/local/memcached
Make
Make install
Cd.. /

Tar zxvf ImageMagick.tar.gz
CD imagemagick-*/
./configure
Make
Make install
Cd.. /

Tar zxvf imagick-*.tgz
CD imagick-*/
Export pkg_config_path=/usr/local/lib/pkgconfig//usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
Make
Make install
Cd.. /

6, modify some of the PHP parameter configuration

Vi/etc/php.ini
Add these:

Extension_dir =/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
Extension = "memcache.so"
Extension = "imagick.so"
Modify these:

Cgi.fix_pathinfo=0

After the server has installed PHP, you need to disable some potentially dangerous PHP functions for security reasons. The following functions can be disabled if they do not have special needs:

Exec,system,phpinfo,eval,passthru,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter, Ini_alter,ini_restore,dl,pfsockopen,fsocket,fsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_ Socket_server

Disable method:

Modify PHP.ini, find disable_functions, and modify to:

Disable_functions = exec,system,phpinfo,eval,passthru,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_ Status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,fsocket,fsockopen,openlog,syslog,readlink,symlink, Popepassthru,stream_socket_server
Resources:

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.