LAMP环境配置及GD库加PHP加速软件eAccelerator加Zend的安装
操作系统:Centos 5
系统环境:各种开发工具包都装上,再加上这些小的开发软件,不然GD装不上去,PHP也自然装不上去。
          bzip2-devel zlib-devel libjpeg-devel libpng-devel freetype-devel openssl-devel
          libxml2-devel gettext-devel   (可从光盘中安装,也可用YUM命令来安装)
1:安装GD2库
   tar zxvf gd-2.0.35.tar.gz
   cd gd-2.0.35
   ./configure --prefix=/usr/local/gd
    make
    make install
2:安装apache
   tar zxvf httpd-2.2.6.tar.gz
   cd httpd-2.2.6
   ./configure --prefix=/usr/local/apache --with-ssl --enable-ssl --enable-so --enable-rewrite
# --with-ssl --enable-ssl 传输过程中带加密功能
# --enable-so 动态加载库 (PHP是动态的,所以要开启)
    make
    make install
安装完后apache目录在/usr/local/apache,配置文件是conf/httpd.conf,默认文件目录是htdocs
将apache 设置成开机自启动:
 1:在/etc/rc.d/rc.local文件中加入一行
    /usr/local/apache/bin/apachectl start
    这样每次重新启动系统时以后,apache也会随系统一起启动
 2:或者将apache安装为系统服务
    cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
    然后 vi /etc/rc.d/init.d/httpd添加(#!/bin/sh 下面)
    # chkconfig:2345 10 90 (其中10代表优先启动的级别,90代表优先被杀进程的级别)
    # description: Activates/Deactivates Apache Web Server
    最后,运行chkconfig 把 Apache 添加到系统的启动服务组里面:
    chkconfig --add httpd
    chkconfig httpd on
4: 安装Mysql5
   tar zxvf mysql-5.0.46.tar.gz
   cd mysql-5.0.46
   ./configure --prefix=/usr/local/mysql --with-comment=Source --with-server-suffix=-enterprise-gpl --with-mysqld-user=mysql --without-debug --with-socket-path=/var/lib/mysql/mysql.sock --with-big-tables  --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldtlags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --without-isam --enable-local-infile --with-readline --with-raid --sysconfdir=/etc --localstatedir=/var/lib/mysql

出错:checking for termcap functions library... configure: error: No curses/termcap library found
请安装:ncurses和ncurses-devel两个包

InnoDB表驱动是一种存储引擎,它的特性是支持事务,适合企业级用户,想安装这个表驱动要加上(--with-plugins=innobase)
# --prefix=/usr/local/mysql  mysql数据库的安装目录
# --with-mysqld-user=mysql   mysql数据库的运行用户
# --with-charset=utf8 --with-collation=utf8_general_ci  mysql数据库的默认字符集
# --sysconfdir=/etc  my.ini配置文件的路径
# --localstatedir=/var/lib/mysql  数据库存放的路径
    make
    make install
安装完以后要初始化数据库,当然你是升级的话不用做这步:
/usr/local/mysql/bin/mysql_install_db
创建mysql数据库的用户和用户组
groupadd mysql
useradd -g mysql mysql
修改数据库存放目录的用户组
chown -R mysql:mysql /var/lib/mysql
复制mysql配置文件
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
把mysql服务复制到系统服务文件夹内及修改其权限
cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
加载到系统服务中
chkconfig --add mysqld
修改其运行级别
chkconfig --level 3 mysqld on
默认密码为空,修改其密码
use mysql;
UPDATE user SET Password = password ( 'chris!benq7*' ) WHERE User = 'root' ;
之后重启mysql会有相关这类skip-federated错误的话,说明你你没有安装这个存储插件,解决方法是在my.cnf中注释掉skip-federated这项,或你在安装的时候把这个存储插件安装上,在配置环境中(./configure)加上 --with-plugins=federated,就OK了!
skip-federated 也是mysql的一种存储引擎。在mysql 5.0.3中就被支持,在mysql 5.0.64默认编译是不开启的

5: 安装php5
   tar zxvf php-5.2.5.tar.gz
   cd phhp-5.2.5
   ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-zlib-dir --with-bz2 --with-libxml-dir --with-gd=/usr/local/gd --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-ttf --enable-mbstring --with-mysql=/usr/local/mysql --with-config-file-path=/etc --with-iconv --disable-ipv6 --enable-static --enable-zend-multibyte --enable-inline-optimization --enable-zend-multibyte --enable-sockets --with-openssl --with-gettext --enable-ftp
# --with-apxs2=/usr/local/apache/bin/apxs apache的apxs文件目径
# --with-mysql=/usr/local/mysql mysql数据库的安装路径
# --with-gd=/usr/local/gd gd库的安装路径
# --with-config-file-path=/etc php配置文件(php.ini)的存放路径
# --disable-ipv6 取消ipv6功能
# --with-openssl 开启加密功能
# --enable-fastcgi 开启PHP的fastcgi模式
   make
   make install
复制PHP配置文件
cp php.ini-recommended /etc/php.ini
整合apache与php
vi /usr/local/apache/conf/httpd.conf
找到DocumentRoot "/usr/local/apache/htdocs"和<Directory "/usr/local/apache/htdocs">改成自己的文件存放目录
安全起见,不显示网站根目录,加#号注释以下语句
# Options Indexes FollowSymLinks
开启rewrite重写功能
找到这一段
# AllOverride controls what directives may be placed in .htaccess files.
# It cat be "ALL","None", or any combination of the keywords;
# Options Filelnfo AuthConfig Limit
#
 AllowOverride none
更改为:AllowOverride all
找到 AddType application/x-gzip .gz .tgz 在下面加上
AddType application/x-httpd-php .php

使用PHP探针测试
<?php
phpinfo();
?>

6: 安装Zend
   解压Zend的之后,运行命令 ./install.sh ,按要求一步一步安装下去
7:安装eAccelerator
   eaccelerator 是PHP的加速软件,使用后PHP的执行效率会有较大幅度的提升。目前eaccelerator和Zend能够基本上兼容。
   ZendOptimizer没有加速功能,反而使PHP运行变慢,只是起到个运行Zend加密文件的作用而以。
   tar -jxvf eaccelerator-0.9.5.2.tar.bz2
   cd eaccelerator-0.9.5.2
   export PHP_PREFIX="/usr/local/php"
   $PHP_PREFIX/bin/phpize
   ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
    make
    make install
    编译安装后我们会看到屏幕提示的 eaccelerator.so所在的目录,php5.2X系统是在/usr/local/php/lib/extensions/no/nodebug-zts-20060613/eaccelerator.so,记住这个路径,待会要用到。
安装为Zend扩展:
修改php.ini (安装完Zend之后,php.ini配置文件将存放于/usr/local/Zend/etc目录下)
在文件最后,[Zend]的下一行加入以下代码
zend_extension="/usr/local/php/lib/extensions/no/nodebug-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
然后创建目录: mkdir /tmp/eaccelerator ,修改目录权限 chmod 777 /tmp/eaccelerator
重启apache,查看php探针,在Zend信息那块会出现eaccelerator相关的信息,这时表明eaccelerator加速软件安装成功。