Compile PHP5.3.8 with CentOS6

Source: Internet
Author: User
Tags imagemagick sapi
Part of the content of PHP5.3.8 compiled by CentOS6 comes from the internet. download the following software package and select the latest one.

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gzwget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.6.1.tar.bz2 wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz wget http://blog.s135.com/soft/linux/nginx_php/imagick/imagick-2.3.0.tgz 

Support Libraries required for compiling and installing PHP

tar zxvf libiconv-1.13.1.tar.gzcd libiconv-1.13.1/./configure --prefix=/usr/localmakemake installcd ../tar zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8/./configuremakemake install/sbin/ldconfigcd libltdl/./configure --enable-ltdl-installmakemake installcd http://www.cnblogs.com/tar zxvf mhash-0.9.9.9.tar.gzcd mhash-0.9.9.9/./configuremakemake installcd ../ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.laln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.soln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.aln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.laln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.soln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-configtar zxvf mcrypt-2.6.8.tar.gzcd mcrypt-2.6.8//sbin/ldconfig./configuremakemake installcd ../

Download PHP 5.3.8.

mkdir /usr/local/webserver wget http://cn.php.net/get/php-5.3.8.tar.bz2/from/this/mirrortar jfvx php-5.3.8.tar.bz2cd php-5.3.8

Start compilation

./configure --prefix=/usr/local/webserver/php  --with-config-file-path=/usr/local/webserver/php/etc  \--with-mysql=/usr/local/webserver/mysql \--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config \--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-discard-path --enable-safe-mode \--enable-bcmath --enable-shmop --enable-sysvsem \--enable-inline-optimization --with-curl --with-curlwrappers \--enable-mbregex --enable-fastcgi --enable-fpm \--enable-force-cgi-redirect --enable-mbstring --with-mcrypt \--with-gd --enable-gd-native-ttf --with-openssl --with-mhash \--enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl \--with-xmlrpc --enable-zip --enable-soap
make ZEND_EXTRA_LIBS='-liconv'make install
cp php.ini-production /usr/local/webserver/php/etc/php.inicp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpmcp sapi/fpm/php-fpm.conf /usr/local/webserver/php/etc/

Install the PHP Extension Library

tar zxvf memcache-2.2.5.tgzcd memcache-2.2.5//usr/local/webserver/php/bin/phpize./configure --with-php-config=/usr/local/webserver/php/bin/php-configmakemake installcd ../tar jxvf eaccelerator-0.9.6.1.tar.bz2cd eaccelerator-0.9.6.1//usr/local/webserver/php/bin/phpize./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-configmakemake installcd ../tar zxvf PDO_MYSQL-1.0.2.tgzcd PDO_MYSQL-1.0.2//usr/local/webserver/php/bin/phpize./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysqlmakemake installcd ../tar zxvf ImageMagick.tar.gzcd ImageMagick-6.5.1-2/./configuremakemake installcd ../tar zxvf imagick-2.3.0.tgzcd imagick-2.3.0//usr/local/webserver/php/bin/phpize./configure --with-php-config=/usr/local/webserver/php/bin/php-configmakemake installcd ../

You need to modify the php. ini and php-fpm.conf files
Add the following fields to the php. ini file:

extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/"extension = "memcache.so"extension = "pdo_mysql.so"extension = "imagick.so"
[eaccelerator]zend_extension=/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"eaccelerator.shm_size="64"eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"eaccelerator.enable="1"eaccelerator.optimizer="1"eaccelerator.check_mtime="1"eaccelerator.debug="0"eaccelerator.filter=""eaccelerator.shm_max="0"eaccelerator.shm_ttl="3600"eaccelerator.shm_prune_period="3600"eaccelerator.shm_only="0"eaccelerator.compress="1"eaccelerator.compress_level="9"

Php-fpm uncomment the following line

[global]pid = run/php-fpm.piderror_log = log/php-fpm.logemergency_restart_threshold = 0[www]listen = 127.0.0.1:9000listen.allowed_clients = 127.0.0.1user = nobodygroup = nobodypm = dynamicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35

Modify the/etc/sysctl. conf file and add the following content:

kernel.shmmax = 134217728

Start the PHP-FPM process

service php-fpm start

Note: If compilation fails, troubleshoot the issue based on the error message, for example, libldap. so is stored in/usr/lib64 by default. if this problem occurs, you only need to copy the file and it will be OK.

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.