Home > 工作 > 部署Centos5.4服务器–PHP篇

部署Centos5.4服务器–PHP篇

其实,在写这篇文章的时候,我很心虚,因为对于安装php,我是照搬张宴博客里面的操作,连安装文件也都是他那里下载下来的;

而且,我发现,安装张宴的安装方法,就会报1个错误,而这个错误,我都在博客里面提过了:

php错误 127:make[1]: *** [install-pear-installer]

还有一个是添加上Zend支持(主要是更新zend版本到3.x):

Attention: Zend Optimizer not Installed ——已解决

安装具体步骤:

1、下载需要的工具(张宴博客里面有)

mcrypt-2.6.8.tar.gz
pcre-8.01.tar.gz
libiconv-1.13.tar.gz
memcache-2.2.5.tgz
eaccelerator-0.9.6.tar.bz2
memcached-1.4.5.tar.gz
PDO_MYSQL-1.0.2.tgz
libmcrypt-2.5.8.tar.gz
mhash-0.9.9.9.tar.gz
php-5.2.13-fpm-0.5.13.diff.gz
ImageMagick.tar.gz
ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
imagick-2.3.0.tgz

2、更新库文件(centos系统)

yum -y install gcc gcc-c++ pcre pcre-devel autoconf libjpeg libjpeg-devel libpng libpng-devel  freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2- devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5  krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap  openldap-clients openldap-servers

3、进入软件目录,运行以下命令,前提是软件名称、版本均正确的情况(安装路径是/usr/local/php,建议先复制蓝色之前的这部分,然后蓝色部分单独执行,因为这部分可能会报错,需要参见上面给的解决方法,切忌!

tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure --prefix=/usr/local
make
make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./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
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../

tar zxvf php-5.2.13.tar.gz
gzip -cd php-5.2.13-fpm-0.5.13.diff.gz | patch -d php-5.2.13 -p1
cd php-5.2.13/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-iconv-dir=/usr/local --with-freetype-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 --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/php/etc/php.ini
cd ../

tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
tar jxvf eaccelerator-0.9.6.tar.bz2
cd eaccelerator-0.9.6/
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
tar zxvf 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
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
cd ../
tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\nextension = "imagick.so"\n#' /usr/local/php/etc/php.ini
sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/php/etc/php.ini
sed -i "s#; always_populate_raw_post_data = On#always_populate_raw_post_data = On#g" /usr/local/php/etc/php.ini
mkdir -p /usr/local/eaccelerator_cache

tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
mkdir /usr/local/Zend
mkdir /usr/local/Zend/lib
cp ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so /usr/local/Zend/lib

4、以上步骤如果觉得过于恐怖,可以一步一步分开运行,接下来是编辑php.ini文件

vim /usr/local/php/etc/php.ini
末尾输入:
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/usr/local/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"
[zend]
zend_optimizer.optimization_level=15
zend_extension=/usr/local/Zend/lib/ZendOptimizer.so

5、编辑php-fpm.conf文件,加上php运行的用户和用户组

<value name=”user”>www</value>
<value name=”group”>www</value>    
 

6、安装成功,运行php,看9000端口是否开放(9000端口开放,php安装成功)

/usr/local/php/sbin/php-fpm start

netstat -ntl

OK,基本上是这样的,可能有遗漏,欢迎大家指正~~~工具包我找个时间传到新浪共享上面。

原创文章,转载请注明: 转载自三叶草

本文链接地址:http://www.anjing.me/1064.html

特别声明:商业网站转载需经作者同意,否则视为侵权!

相关日志

POSTED ON 2010/09/01, ,

Comments:15

Leave my own
  1. #1 joyla
    10/09/01 回复

    大牛,我仰望你!

  2. #7 立青
    10/09/01 回复

    原来安装一个环境要那么大的东西支持!
     
    强大,多多想你学习, 我回来了,第一时间来看看

    • #8 三叶草
      10/09/01 回复

      哈哈……别人的东西,稍加消化就成了自己的

  3. #9 Solo
    10/09/01 回复

    很久没有玩CentOS了。忙.

  4. #11 jiechic
    10/09/01 回复

    好多步骤呢,有空要仔细看

  5. #13 zhangyang
    10/09/02 回复

    伟大的CentOS,我也仰望你一个。

  6. #14 ugg uk
    10/09/02 回复

    有点晕 早上淋雨了  头昏昏的一整天!

    • #15 三叶草
      10/09/02 回复

      你的域名好长好长….

      我们这里也下大雨了~~~

Leave a Reply

TOP