【转】centos LNAMP之三(编译安装 php 5.3.6)

转自:http://hi.baidu.com/gevilrror/blog/item/210bbff903adbb06a8d311e4.html

1. 安装编译前提

a. 编译环境
# yum -y install gcc gcc-c++ make

b. php 相关模块
# yum -y install libjpeg-devel libpng-devel freetype-devel libxml2-devel libxslt-devel zlib-devel curl-devel mhash-devel openldap-devel gd-devel

c. libiconv模块安装
# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
# cd libiconv-1.13.1
# ./configure --prefix=/usr/local/libiconv && make && make install

d. libmcrypt模块安装
# wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmcrypt%2Ffiles%2FLibmcrypt%2F2.5.8%2F&ts=1304912647&use_mirror=nchc
# tar zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# ./configure && make && make install
# cd libltdl
# ./configure --enable-ltdl-install && make && make install

e. mysql库链接
# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

2. php编译安装

a. 针对apache的编译安装
# vi /usr/local/httpd/bin/apxs
将第一行的

1#!/replace/with/path/to/perl/interpreter -w

替换为

1#!/usr/bin/perl -w

# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-curl --with-curlwrappers --with-mhash --with-mcrypt --with-gd --enable-gd-native-ttf --with-xsl --with-openssl --with-ldap --with-ldap-sasl --with-xmlrpc --without-pear --enable-zip --enable-soap --enable-mbstring --enable-ftp --enable-sockets --enable-pcntl --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --disable-rpath --enable-mbregex --with-apxs2=/usr/local/httpd/bin/apxs
# make && make install

配置
# vi /usr/local/httpd/conf/httpd.conf
找到

1AddType application/x-gzip .gz .tgz

下行添加

1AddType application/x-httpd-php .php

找到

1<IfModule dir_module>
2    DirectoryIndex index.html
3</IfModule>

修改为

1<IfModule dir_module>
2    DirectoryIndex index.html index.htm index.php
3</IfModule>

b. 针对nginx的编译安装
# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-curl --with-curlwrappers --with-mhash --with-mcrypt --with-gd --enable-gd-native-ttf --with-xsl --with-openssl --with-ldap --with-ldap-sasl --with-xmlrpc --without-pear --enable-zip --enable-soap --enable-mbstring --enable-ftp --enable-sockets --enable-pcntl --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --disable-rpath --enable-mbregex --enable-safe-mode --enable-fpm --with-fpm-user=www --with-fpm-group=www
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# vi /usr/local/php/etc/php-fpm.conf 取消以下;分号注释

1;pid = run/php-fpm.pid
2;pm.start_servers = 20
3;pm.min_spare_servers = 5
4;pm.max_spare_servers = 35

# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod 755 /etc/init.d/php-fpm
# chkconfig --add php-fpm
# chkconfig --level 2345 php-fpm on

c. 配置
# mkdir /usr/local/php/etc
# cp php.ini-development /usr/local/php/etc/php.ini
# curl http://pear.php.net/go-pear | /usr/local/php/bin/php
# vi /usr/local/php/etc/php.ini
找到

1;extension_dir = "./"

替换为

1extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"

3. php扩展模块安装

a. 安装autoconf
# yum -y install autoconf

b. 安装memcache
# wget http://pecl.php.net/get/memcache-3.0.6.tgz
# tar xvf memcache-3.0.6.tgz
# cd memcache-3.0.6
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install

c. 安装pdo-mysql
# wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
# tar xvf PDO_MYSQL-1.0.2.tgz
# cd PDO_MYSQL-1.0.2
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql && make && make install

d. 安装ImageMagick
# wget http://image_magick.veidrodis.com/image_magick/ImageMagick-6.6.9-9.tar.gz
# tar zxvf ImageMagick-6.6.9-9.tar.gz
# cd ImageMagick-6.6.9-9
# ./configure && make && make install
# wget http://pecl.php.net/get/imagick-3.1.0b1.tgz
# tar xvf imagick-3.1.0b1.tgz
# cd imagick-3.1.0b1
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install

# vi /usr/local/php/etc/php.ini
找到

1;extension=php_zip.dll

下行添加

1extension = "memcache.so"
2extension = "pdo_mysql.so"
3extension = "imagick.so"

4. php加速应用

a. ZendGuardLoader
# tar zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
# cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
# vi /usr/local/php/etc/php.ini 未尾加上

1[Zend Guard Loader]
2zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/ZendGuardLoader.so"

b. eAccelerator
# wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
# cd eaccelerator-0.9.6.1
# /usr/local/php/bin/phpize
# ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config && make && make install
# mkdir -p /usr/local/php/eaccelerator_cache
# cp control.php /usr/local/nginx/html/
# vi /usr/local/php/etc/php.ini 未尾加上

01[eaccelerator]
02zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
03eaccelerator.shm_size="64"
04eaccelerator.cache_dir="/usr/local/php/eaccelerator_cache"
05eaccelerator.enable="1"
06eaccelerator.optimizer="1"
07eaccelerator.check_mtime="1"
08eaccelerator.debug="0"
09eaccelerator.filter=""
10eaccelerator.shm_max="0"
11eaccelerator.shm_ttl="3600"
12eaccelerator.shm_prune_period="3600"
13eaccelerator.shm_only="0"
14eaccelerator.compress="1"
15eaccelerator.compress_level="9"
16eaccelerator.allowed_admin_path="/usr/local/nginx/html/control.php"

转自:http://www.xtgly.com/2011/05/17/centos-lnamp%E4%B9%8B%E4%B8%89%EF%BC%88%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85-php-5-3-6%EF%BC%89.htm


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值