<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[[eaccelerator.so配置]CentOS 4.4 编译安装 apache 2.2.4(mod_ssl)+php 5.2.1 with Suhosin-Patch+mysql 5.0.33+Zend Optimizer v3.2.2+eaccelerator-0.9.5+phpmyadmin 2.10笔记]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Mon, 06 Aug 2007 02:42:55 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	CentOS 4.4 编译安装 apache 2.2.4(mod_ssl)+php 5.2.1 with Suhosin-Patch+mysql 5.0.33+Zend Optimizer v3.2.2+eaccelerator-0.9.5+phpmyadmin 2.10笔记 v1.2<br/><br/>v1.2 2007年2月12日 apache 更新为2.2.4版本，增加mod_ssl和openssl支持，增加apr和apr-util的编译， php更新为5.2.1,增加集成Suhosin补丁，mysql 更新为5.0.33, Zend Optimizer 更新为3.2.2，增加phpmyadmin.修改一些文字错误。<br/><br/>v1.0 2007年1月11日<br/><br/>先声明，我绝对是个Linux的菜鸟，以下的这些文字个人的安装笔记，是参考了网上许多高手的成功经验组合而成的，说实话我自己的东西不多 ：）我想把这些经验写下来，既可以对其他跟我一样摸索的兄弟一个经验，也可以防止以后自己都忘记了，嘿嘿。<br/><br/>所以如果某个大虾看到我借用了你的资源，请你不要生气。也欢迎大家进行指点。<br/><br/>1.下载centos 4.4<br/>我是下载的DVD版本，大家也可以下载服务器CD安装版本，其实都差不多。大家可以到这儿下载，速度很快的。<br/>http://ftp.iasi.roedu.net/mirrors/centos.org/4.4/isos/i386/<br/><br/>下载后当然就刻录成光盘。我建议你刻录DVD啦，如果是菜鸟，也可以在图形界面进行学习，不会这么抓不住头脑。<br/><br/>2.1 安装CentOS4.4<br/>作为服务器，不安装不需要的组件，所以在选择组件的时候，除了选择FTP SERVER外取消所有组件的选择。也不要选web服务器。因为我们后面要手动编译安装。<br/><br/>系统约定RPM包和源码包存放位置<br/><br/>RPM包和源码包存放位置 /usr/local/src<br/>源码包编译安装位置(prefix) /usr/local/xxx<br/>脚本以及维护程序存放位置 /usr/local/sbin<br/>MySQL 数据库位置 /var/lib/mysql<br/>Apache 网站根目录 /home/www<br/>Apache 虚拟主机日志根目录 /data/logs/www<br/>yum RPM包信息文件 /etc/yum.list<br/><br/>2.2 更新系统，此处我们使用up2date,先修改up2date镜像。<br/><br/>vi /etc/sysconfig/rhn/sources<br/>我把源修改成这样了：<br/><br/>yum centos4-Base http://mirror.be10.com/centos/4/os/$ARCH/<br/>yum centos4-Updates http://mirror.be10.com/centos/4/updates/$ARCH/<br/>yum centos4-extras http://mirror.be10.com/centos/4/extras/$ARCH/<br/>yum centos4-contrib http://mirror.be10.com/centos/4/contrib/$ARCH/<br/>yum centos4-addons http://mirror.be10.com/centos/4/addons/$ARCH/<br/>yum centos4-centosplus http://mirror.be10.com/centos/4/centosplus/$ARCH/<br/>然后执行：<br/><br/># up2date -l //列出更新<br/># up2date -uf //更新包括版本的所有程序。如果不包括内核，则用up2date -u<br/>3、系统环境部署及调整<br/><br/>（1）. 检查系统是否正常<br/><br/># more /var/log/messages //检查有无系统内核级错误信息<br/># demesg //检查硬件设备是否有错误信息<br/># ifconfig //检查网卡设置是否正确<br/># ping www.163.com // 检查网络是否正常<br/>（2）. 关闭不需要的服务<br/><br/># export LANG=&#039;en_US&#039; //设置语言<br/># setup //选择启动的服务<br/>进入system service 选项。<br/>以space 键选定所需服务。<br/>以下仅列出需要启动的服务，未列出的服务一律关闭：<br/><br/>crond<br/>irqbalance 仅当服务器CPU为S.M.P架构或支持双核心、HT技术时，才需开启，否则关闭。<br/>microcode_ctl<br/>network<br/>vsftpd<br/>sshd<br/>syslog<br/><br/>（3）、修改/etc/yum.repos.d/CentOS-Base.repo，将镜象站点地址改为在中国的镜象站点地址。不然我们通过yum安装软件速度会极慢。修改如下：<br/><br/># CentOS-Base.repo<br/>#<br/># This file uses a new mirrorlist system developed by Lance Davis for CentOS.<br/># The mirror system uses the connecting IP address of the client and the<br/># update status of each mirror to pick mirrors that are updated to and<br/># geographically close to the client. You should use this for CentOS updates<br/># unless you are manually picking other mirrors.<br/>#<br/># If the mirrorlist= does not work for you, as a fall back you can try the<br/># remarked out baseurl= line instead.<br/>#<br/>#<br/><br/>[base]<br/>name=CentOS-$releasever - Base<br/>baseurl=http://mirror.vmmatrix.net/CentOS/$releasever/os/$basearch/<br/>http://mirror.be10.com/centos/$releasever/os/$basearch/<br/>http://centos.hostlink.com.hk/$releasever/os/$basearch/<br/>http://ftp.hostrino.com/pub/centos/<br/>gpgcheck=1<br/>gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4<br/><br/>#released updates<br/>[update]<br/>name=CentOS-$releasever - Updates<br/>baseurl=http://mirror.vmmatrix.net/CentOS/$releasever/os/$basearch/<br/>http://mirror.be10.com/centos/$releasever/os/$basearch/<br/>http://centos.hostlink.com.hk/$releasever/os/$basearch/<br/>http://ftp.hostrino.com/pub/centos/<br/>gpgcheck=1<br/>gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4<br/><br/>#packages used/produced in the build but not released<br/>[addons]<br/>name=CentOS-$releasever - Addons<br/>baseurl=http://mirror.vmmatrix.net/CentOS/$releasever/os/$basearch/<br/>http://mirror.be10.com/centos/$releasever/os/$basearch/<br/>http://centos.hostlink.com.hk/$releasever/os/$basearch/<br/>http://ftp.hostrino.com/pub/centos/<br/>gpgcheck=1<br/>gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4<br/><br/>#additional packages that may be useful<br/>[extras]<br/>name=CentOS-$releasever - Extras<br/>baseurl=http://mirror.vmmatrix.net/CentOS/$releasever/os/$basearch/<br/>http://mirror.be10.com/centos/$releasever/os/$basearch/<br/>http://centos.hostlink.com.hk/$releasever/os/$basearch/<br/>http://ftp.hostrino.com/pub/centos/<br/>gpgcheck=1<br/>gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4<br/><br/>#additional packages that extend functionality of existing packages<br/>[centosplus]<br/>name=CentOS-$releasever - Plus<br/>baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/<br/>gpgcheck=1<br/>enabled=0<br/>gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4<br/><br/>#contrib - packages by Centos Users<br/>[contrib]<br/>name=CentOS-$releasever - Contrib<br/>baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/<br/>gpgcheck=1<br/>enabled=0<br/>gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4<br/>保存。<br/><br/>然后导入key升级相应yum数据<br/><br/># rpm --import /usr/share/doc/centos-release-4/RPM-GPG-KEY-centos4<br/># yum list tee /etc/yum.list //读取yum list 数据，将其输出到 /etc/yum.list。<br/>（4）、定时校正服务器时间<br/><br/># yum install ntp<br/># crontab -e<br/>0 23 * * * root /usr/sbin/ntpdate 210.72.145.44 &gt; /dev/null 2&gt;&amp;1<br/>以上命令设置好后存盘。您的机器将在每天的23:00根据中国国家授时中心的NTP服务器时间自动校准时间。<br/><br/>(5). 对TCP/IP网络参数进行调整，加强抗SYN Flood能力<br/><br/># echo &#039;net.ipv4.tcp_syncookies = 1&#039; &gt;&gt; /etc/sysctl.conf //将net.ipv4.tcp_syncookies = 1写入sysctl.conf 文件<br/># sysctl -p //查看<br/>（6）、FTP服务器的配置<br/><br/>vi /etc/vsftpd/vsftpd.conf<br/>把anonymous_enable=YES注释掉不允许匿名登录。<br/>把chroot_list_enable=YES<br/>chroot_list_file=/etc/vsftpd.chroot_list<br/>前的注释去掉。<br/>把ftpd_banner=*前的注释去掉。后面改成你的欢迎信息(这样设置可以避免显示ftp服务器的版本信息)<br/>然后保存，service vsftpd start就可以了。<br/><br/>这时应当添加用户，因为root默认不能通过FTP方式登录。<br/><br/># adduser username<br/># passwd userpassword<br/>这样对于我们上传一些文件到系统中很方便。<br/><br/>4. 重新启动系统<br/><br/># init 6<br/>5. 使用 yum 程序安装所需开发包（以下为标准的 RPM 包名称）<br/><br/># yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel<br/># 这里我们将编译GD所必须的一些小软件比如libpng,libtiff,freetype,libjpeg等先用RPM的方式一并安装好，避免手动编译浪费时间，同时也能避免很多错误，这几个小软件的编译很麻烦。这几个小软件编译错误了，GD当然安装不了，php5的编译当然也没戏了。所以我们抓大放小，对这些小牛鬼蛇神采取快速简洁的方式进行安装。并且对服务器的性能也不能产生什么影响。<br/><br/>6. 源码编译安装所需包 (Source)<br/>(1) GD2<br/><br/># cd /usr/local/src<br/># wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz<br/># tar xzvf gd-2.0.33.tar.gz<br/># cd gd-2.0.33<br/># ./configure --prefix=/usr/local/gd2 --mandir=/usr/share/man //./configure 配置。<br/># make //make 是用来编译的，它从 Makefile 中读取指令，然后编译。<br/># make install //make install 是用来安装的，它也从 Makefile 中读取指令，安装到指定的位置。<br/>(2) Apache 日志截断程序<br/><br/># cd /usr/local/src<br/># wget http://cronolog.org/download/cronolog-1.6.2.tar.gz<br/># tar xzvf cronolog-1.6.2.tar.gz<br/># cd cronolog-1.6.2<br/># ./configure --prefix=/usr/local/cronolog<br/># make<br/># make install<br/>(3) libxml 库程序<br/><br/># cd /usr/local/src<br/># wget http://ftp.gnome.org/pub/gnome/sources/libxml2/2.6/libxml2-2.6.26.tar.gz<br/># tar zxvf libxml2-2.6.26.tar.gz<br/># cd libxml2-2.6.26<br/># ./configure --prefix=/usr/local/libxml2<br/># make<br/># make install<br/>7、编译mysql 5.0.33<br/><br/>cd /usr/local/src<br/># wget http://mysql.oss.eznetsols.org/Downloads/MySQL-5.0/mysql-5.0.33.tar.gz<br/># tar xzvf mysql-5.0.33.tar.gz<br/># cd mysql-5.0.33<br/>修改mysql 客户端最大连接数， 默认的只有100,远远达不到我们的要求。<br/><br/># vi sql/mysqld.cc<br/>搜索找到下面一行：<br/><br/>&#123;&quot;max_connections&quot;, OPT_MAX_CONNECTIONS,<br/>&quot;The number of simultaneous clients allowed.&quot;, (gptr*) &amp;max_connections,<br/>(gptr*) &amp;max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,<br/>0&#125;,<br/>将其中的100改为1500, 当然小点也可以，根据你的需要来，不建议改的太大。<br/><br/>&#123;&quot;max_connections&quot;, OPT_MAX_CONNECTIONS,<br/>&quot;The number of simultaneous clients allowed.&quot;, (gptr*) &amp;max_connections,<br/>(gptr*) &amp;max_connections, 0, GET_ULONG, REQUIRED_ARG, 1500, 1, 16384, 0, 1,<br/>0&#125;,<br/>保存。<br/><br/># CHOST=&quot;i686-pc-linux-gnu&quot; CFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; CXXFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; ./configure --prefix=/usr/local/mysql --localstatedir=/var/lib/mysql --with-comment=Source --with-server-suffix=-Community-Server --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=latin1 --with-collation=latin1_swedish_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --without-isam<br/>配置成功会提示：<br/><br/>MySQL has a Web site at http://www.mysql.com/ which carries details on the<br/>latest release, upcoming features, and other information to make your<br/>work or play with MySQL more productive. There you can also find<br/>information about mailing lists for MySQL discussion.<br/><br/>Remember to check the platform specific part of the reference manual for<br/>hints about installing MySQL on your platform. Also have a look at the<br/>files in the Docs directory.<br/><br/>Thank you for choosing MySQL!<br/><br/>// 注意 ，CHOST=”i686-pc-linux-gnu” CFLAGS=”-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer” CXXFLAGS=”-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer” 这个环境参数只针对intel P4 芯片，如果你的CPU是AMD的，注意不能使用。请查看相应的编译优化参数。否则程序会无法编译，即使编译成功也无法运行，嘿嘿。<br/><br/># make<br/>编译的时间可能会比较长，毕竟优化的比较厉害。<br/><br/># make install<br/>编译安装完成后执行后续操作：<br/><br/># useradd mysql //添加 mysql 用户<br/># cd /usr/local/mysql<br/># bin/mysql_install_db --user=mysql<br/># chown -R root:mysql . //设置权限，注意后面有一个 &quot;.&quot;<br/># chown -R mysql /var/lib/mysql //设置 mysql 目录权限<br/># chgrp -R mysql . //注意后面有一个 &quot;.&quot;<br/># cp share/mysql/my-medium.cnf /etc/my.cnf<br/># cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld //开机自动启动 mysql。<br/># chmod 755 /etc/rc.d/init.d/mysqld<br/># chkconfig --add mysqld<br/># /etc/rc.d/init.d/mysqld start //启动 MySQL<br/># bin/mysqladmin -u root password &quot;password_for_root&quot;<br/># service mysqld stop //关闭 MySQL<br/>8. 编译安装 Apache<br/><br/># cd /usr/local/src<br/># wget http://www.ip97.com/apache.org/httpd/httpd-2.2.4.tar.gz<br/># tar zxvf httpd-2.2.4.tar.gz<br/># cd httpd-2.2.4<br/>依次安装apr和apr-util<br/><br/># cd srclib/apr<br/># ./configure --prefix=/usr/local/apr --enable-threads --enable-other-child USE=ipv6<br/># make &amp;&amp; make install<br/><br/># cd ../apr-util<br/># ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ --with-mysql=/usr/local/mysql<br/># make &amp;&amp; make install<br/><br/>cd /usr/local/src/httpd-2.2.4<br/># CHOST=&quot;i686-pc-linux-gnu&quot; CFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-deflate=shared --with-mysql=/usr/local/mysql --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-htpasswd --enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve --enable-static-htdbm --enable-static-ab --enable-static-checkgid --disable-cgid --disable-cgi --with-mpm=worker --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --enable-ssl --with-ssl=/usr/include/openssl<br/><br/># make<br/># make install<br/># echo &#039;/usr/local/apache2/bin/apachectl start &#039; &gt;&gt; /etc/rc.local //将 apachectl 的调用加入到你的系统启动文件中。<br/>注解：<br/>./configure //配置源代码树<br/>–prefix=/usr/local/apache2 //体系无关文件的顶级安装目录PREFIX ，也就Apache的安装目录。<br/>–enable-module=so //打开 so 模块，so 模块是用来提 DSO 支持的 apache 核心模块<br/>–enable-mods-shared=all //编译全部的模板，对于不需要我们可以在httpd.conf去掉。<br/>–enable-cache //支持缓存<br/>–enable-file-cache //支持文件缓存<br/>–enable-mem-cache //支持记忆缓存<br/>–enable-disk-cache //支持磁盘缓存<br/>–enable-static-support //支持静态连接(默认为动态连接)<br/>–enable-static-htpasswd //使用静态连接编译 htpasswd - 管理用于基本认证的用户文件<br/>–enable-static-htdigest //使用静态连接编译 htdigest - 管理用于摘要认证的用户文件<br/>–enable-static-rotatelogs //使用静态连接编译 rotatelogs - 滚动 Apache 日志的管道日志程序<br/>–enable-static-logresolve //使用静态连接编译 logresolve - 解析 Apache 日志中的IP地址为主机名<br/>–enable-static-htdbm //使用静态连接编译 htdbm - 操作 DBM 密码数据库<br/>–enable-static-ab //使用静态连接编译 ab - Apache HTTP 服务器性能测试工具<br/>–enable-static-checkgid //使用静态连接编译 checkgid<br/>–disable-cgid //禁止用一个外部 CGI 守护进程执行CGI脚本<br/>–disable-cgi //禁止编译 CGI 版本的 PHP<br/>–with-mpm=worker // 让apache以worker方式运行<br/>–enable-ssl // 编译 ssl模块。<br/><br/>将apache设置成开机自启动:<br/><br/>在/etc/rc.d/rc.local文件中加入一行<br/><br/>/usr/local/apache2/bin/apachectl start<br/>这样每次重新启动系统以后,apache也会随系统一起启动.<br/><br/>或者<br/><br/># cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd<br/>然后 vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)<br/># chkconfig: 2345 10 90<br/># description: Activates/Deactivates Apache Web Server<br/>最后，运行chkconfig把Apache添加到系统的启动服务组里面：<br/># chkconfig --add httpd<br/># chkconfig httpd on<br/>9、编译php 5.2.1并打上Suhosin Patch。<br/>Suhosin 是php增强型安全补丁，可以编译到静态内核中，也可以编译成php动态扩展。我个人强烈你建议安装成静态内核。Suhosin已经进入freebsd和 gentoo的ports。下面的以下先说静态安装步骤。当然你也可以在安装php后将它编译成php的动态扩展。<br/><br/># cd /usr/local/src<br/># wget http://cn.php.net/get/php-5.2.1.tar.gz/from/this/mirror<br/>wget http://www.hardened-php.net/suhosin/_media/suhosin-patch-5.2.1-0.9.6.2.patch.gz<br/># tar zxvf php-5.2.1.tar.gz<br/># gunzip suhosin-patch-5.2.1-0.9.6.2.patch.gz<br/># cd php-5.2.1<br/>patch -p 1 -i ../suhosin-patch-5.2.1-0.9.6.2.patch<br/><br/>#./buildconf --force<br/><br/># CHOST=&quot;i686-pc-linux-gnu&quot; CFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; CXXFLAGS=&quot;-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer&quot; ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-zlib-dir --with-bz2 --with-tiff-dir --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd2 --with-freetype-dir --with-jpeg-dir --with-png-dir --with-ttf --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/etc --with-iconv --disable-ipv6 --enable-static --enable-maintainer-zts --enable-memory-limit --enable-zend-multibyte --enable-inline-optimization --enable-zend-multibyte --enable-sockets --enable-soap --enable-suhosin --with-openssl<br/><br/># make<br/><br/># make install<br/><br/># cp php.ini-recommended /etc/php.ini<br/>在这里也顺便说一下将suhosin安装成为php的动态扩展的方法。毕竟网上根本不见它的中文安装教程。<br/><br/>虽然我个人不推荐这种方式。<br/><br/>wget http://www.hardened-php.net/suhosin/_media/suhosin-0.9.16.tgz<br/>tar zxvf suhosin-0.9.16.tgz<br/>cd suhosin-0.9.16<br/>./configure --with-php-config=/usr/local/php/bin/php-config<br/>make<br/>make install<br/>会提示编译的模块存在的目录，记住它。<br/><br/>Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/<br/>然后在php.ini中增加一行下列语句。<br/><br/>extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/suhosin.so<br/>10 、整合apache 与php<br/><br/># vi /usr/local/apache2/conf/httpd.conf<br/>在最后一行加上：<br/><br/>AddType application/x-httpd-php .php<br/>查找：(设置 WEB 默认文件)<br/><br/>DirectoryIndex index.html<br/>替换为：<br/><br/>DirectoryIndex index.php index.html index.htm //在 WEB 目录不到默认文件，httpd 就会执行 /var/www/error/noindex.html<br/>找到这一段：<br/><br/># AllowOverride controls what directives may be placed in .htaccess files.<br/># It can be &quot;All&quot;, &quot;None&quot;, or any combination of the keywords:<br/># Options FileInfo AuthConfig Limit<br/>#<br/>AllowOverride none<br/>更改为<br/><br/>AllowOverride all<br/>允许apache rewrite<br/><br/># 监听443端口,支持https连接<br/>取消注释 httpd.conf 中的<br/><br/>Include conf/extra/httpd-ssl.conf<br/>保存httpd.conf，退出。<br/><br/># /usr/local/apache2/bin/apachectl restart //重启 Apache<br/>11. 查看确认 L.A.M.P 环境信息<br/><br/>vi /usr/local/apache2/htdocs/phpinfo.php<br/>增加下面一行，并保存。<br/><br/># chmod 755 /usr/local/apache2/htdocs/phpinfo.php<br/>用浏览器打开 http://127.0.0.1/phpinfo.php<br/><br/># echo &#039; &#039; &gt; /usr/local/apache2/htdocs/testdb.php<br/># chmod 755 /usr/local/apache2/htdocs/testdb.php<br/># service mysqld start<br/>用浏览器打开 http://127.0.0.1/testdb.php<br/>检查 phpinfo 中的各项信息是否正确。<br/><br/>12、设置SSL并创建自己的CA<br/><br/># cd /usr/share/ssl/misc<br/># ./CA -newca<br/>屏幕上出现如下的提示:CA certificate filename (or enter to create)<br/><br/>这是要求输入要创建的CA的证书文件名, 可以直接回车或输入证书文件名。<br/><br/>Making CA certificate …<br/>Generating a 1024 bit RSA private key<br/>………++++++<br/>…………………………..++++++<br/>writing new private key to ‘./demoCA/private/./cakey.pem’<br/>Enter PEM pass phrase:<br/><br/>Verifying password - Enter PEM pass phrase:-<br/><br/>此时要求输入和验证CA的私钥口令、国家代码（中国是CN）、省份、城市或地区、组织或企业名称、部门名称、CA的名称或服务器的主机名称、管理员电子邮件地址。<br/><br/>至此,在当前目录下生成了demoCA的目录,CA的证书就在该目录下,文件名为cacert.pem<br/><br/>生成服务器的证书请求<br/><br/># ./CA -newreq<br/>屏幕上出现如下的提示:<br/><br/>Generating a 1024 bit RSA private key<br/>……………………………………………..++++++<br/>…..++++++<br/>writing new private key to ‘newreq.pem’<br/>Enter PEM pass phrase:<br/>Verifying password - Enter PEM pass phrase:<br/><br/>此时要求输入和验证服务器的私钥口令、国家代码（中国是CN）、省份、城市或地区、组织或企业名称、部门名称、CA的名称或服务器的主机名称、管理员电子邮件地址。<br/><br/>Please enter the following ‘extra’ attributes<br/><br/>to be sent with your certificaterequest<br/><br/>A challenge password []:<br/><br/>An optional company name []:<br/><br/>.Request (and private key) is in newreq.pem<br/><br/>这是要求输入服务器的相关信息。<br/><br/>此时,在当前目录下生成了一个名为newreq.pem的文件,包含了要生成服务器数字证书的请求。<br/><br/>签署证书<br/><br/># ./CA -sign<br/>屏幕上出现如下的提示:<br/><br/>Using configuration from /usr/share/ssl/openssl.cnf<br/><br/>Enter PEM pass phrase: <br/><br/>此时一样需要输入CA的私钥口令、国家代码（中国是CN）、省份、城市或地区、组织或企业名称、部门名称、CA的名称或服务器的主机名称、管理员电子邮件地址。<br/><br/>Certificate is to be certified until Nov 19 13:46:19 2002 GMT (365 days)<br/><br/>Sign the certificate? [y/n]:y<br/><br/>这时显示证书请求文件中的各项信息,并询问是否要签署证书，回答y，进行签署。<br/><br/>1 out of 1 certificate requests certified, commit? [y/n]y<br/><br/>回答y,会显示已经签署的证书的信息,并在当前目录下生成服务器的证书文件newcert.pem。<br/><br/># mkdir /usr/local/apache2/conf/ssl.crt/<br/># mkdir /usr/local/apache2/conf/ssl.key/<br/># cp newcert.pem /usr/local/apache2/conf/ssl.crt/server.pem<br/># cp newreq.pem /usr/local/apache2/conf/ssl.key/server.pem<br/>更改服务器的证书文件的相关配置<br/><br/># vi /usr/local/apache2/conf/extra/httpd-ssl.conf<br/>查找并修改<br/><br/># Server Certificate:<br/># Point SSLCertificateFile at a PEM encoded certificate. If<br/># the certificate is encrypted, then you will be prompted for a<br/># pass phrase. Note that a kill -HUP will prompt again. Keep<br/># in mind that if you have both an RSA and a DSA certificate you<br/># can configure both in parallel (to also allow the use of DSA<br/># ciphers, etc.)<br/>SSLCertificateFile /usr/local/apache2/conf/ssl.crt/server.pem<br/>#SSLCertificateFile /usr/local/apache2/conf/server-dsa.crt<br/><br/># Server Private Key:<br/># If the key is not combined with the certificate, use this<br/># directive to point at the key file. Keep in mind that if<br/># you&#039;ve both a RSA and a DSA private key you can configure<br/># both in parallel (to also allow the use of DSA ciphers, etc.)<br/>SSLCertificateKeyFile /usr/local/apache2/conf/ssl.key/server.pem<br/>#SSLCertificateKeyFile /usr/local/apache2/conf/server-dsa.key<br/>示例文件<br/><br/>在SSL的根目录中生成一个index.html,它是如下所示:<br/><br/>＜html＞<br/><br/>这是SSL示例!<br/><br/>＜/html＞<br/>测试<br/><br/>假如Web服务器的DNS名称是www.cnprint.org.<br/><br/>在浏览器的URL地址栏里输入 http://www.cnprint.org/，浏览器便会显示APACHE安装时确省的Test Page.<br/><br/>在浏览器的URL地址栏里输入 https://www.cnprint.org/，注意:是 https 而不是http !<br/><br/>浏览器会提示站点已经采用了SSL进行数据的加密传输.由于我们的CA证书不是浏览器缺省的信任的根证书,所以,浏览器会说无法确认服务器的证书可信。暂时不管,一直NEXT,最后,浏览器会显示:这是SSL示例!<br/><br/>可以把CA的证书放在非SSL的站点上,让浏览器下载并安装CA证书,并将其设置成可信任的根证书,便可解决上面的问题.8 解除HTTPD起动时的口令输入。<br/><br/>由于安全的原因,Web服务器的私钥是口令加密了的，每次重新起动HTTPD或Linux时,都会要求输入Web服务器的私钥的口令。<br/><br/>如果要解除HTTPD起动时的口令输入,可以这样:<br/><br/># cd /usr/local/apache2/conf/ssl.key/<br/># cp server.pem server.pem.org<br/># openssl rsa -in server.pem.org -out server.pem<br/># chmod 400 server.pem<br/>另外在网上看到一个方法，我没有试。有兴趣的可以试下。<br/><br/>创建SSL密码自动应答文件，否则每次Apache启动的时候，都会要求你输入SSL的密码.<br/>创建 /usr/local/apache2/conf/ssl.key/sendsslpwd ,内容如下.<br/><br/>#!/bin/bash<br/>SSLpasswd=&quot;YOUR PASSPHRASE&quot;<br/>echo $SSLpasswd<br/>chmod 755 /usr/local/apache2/conf/ssl.key/sendsslpwd<br/>此时，Web服务器的私钥已经没有口令加密,一定要确保server.pem文件除root外,任何用户均无权读取它。<br/><br/>13、安装 Zend Optimizer<br/><br/># cd /usr/local/src<br/># wget http://downloads.zend.com/optimizer/3.2.2/ZendOptimizer-3.2.2-linux-glibc21-i386.tar.gz<br/># tar xzvf ZendOptimizer-3.2.2-linux-glibc21-i386.tar.gz<br/># ./ZendOptimizer-3.2.2-linux-glibc21-i386/install.sh<br/>按照它的提示一步步进行就行了。<br/><br/>14、安装eaccelerator<br/>eaccelerator是php的加速软件，使用后php的执行效率会有较大幅度的提升。目前eaccelerator 0.9.5已经和ZendOptimizer-3.2.2能够很好兼容啦。不过我个人觉得，ZendOptimizer-3.2.2没有加速的功能，只是起到了运行zend加密文件的作用而已。闲话不多说了，大家有兴趣的，可以去google下。<br/><br/># cd /usr/local/src<br/># wget http://bart.eaccelerator.net/source/0.9.5/eaccelerator-0.9.5.tar.bz2<br/># tar -jxvf eaccelerator-0.9.5.tar.bz2<br/># cd eaccelerator-0.9.5<br/><br/>export PHP_PREFIX=&quot;/usr/local/php&quot;<br/>$PHP_PREFIX/bin/phpize //指定一下php的目录<br/><br/># ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config // 设置<br/><br/># make &amp; make install<br/>编译安装后我们会看到屏幕提示的eaccelerator.so所在的目录，比如我得到的是/usr/local/php/lib/php/extensions/no-debug-zts-20060613/eaccelerator.so，记住这个路径，待会要用到。<br/><br/>修改php.ini（安装完zend之后，php.ini存放于/usr/local/Zend/etc）<br/>在文件最后，zend之前，注意，这部分内容务必放在zend之前，不然可能会出现不可预期的服务器问题。添加下列信息：<br/><br/>[eaccelerator]<br/>extension=&quot;/usr/local/php/lib/php/extensions/no-debug-zts-20060613/eaccelerator.so&quot;<br/>eaccelerator.shm_size=&quot;32&quot;<br/>eaccelerator.cache_dir=&quot;/tmp/eaccelerator&quot;<br/>eaccelerator.enable=&quot;1&quot;<br/>eaccelerator.optimizer=&quot;1&quot;<br/>eaccelerator.check_mtime=&quot;1&quot;<br/>eaccelerator.debug=&quot;0&quot;<br/>eaccelerator.filter=&quot;&quot;<br/>eaccelerator.shm_max=&quot;0&quot;<br/>eaccelerator.shm_ttl=&quot;0&quot;<br/>eaccelerator.shm_prune_period=&quot;0&quot;<br/>eaccelerator.shm_only=&quot;0&quot;<br/>eaccelerator.compress=&quot;1&quot;<br/>eaccelerator.compress_level=&quot;9&quot;<br/>解释:<br/>zend_extension 是安装完程序自动指示给我们的<br/>eaccelerator.shm_size=”32″ 缓存大小单位MB<br/>eaccelerator.cache_dir=”/tmp/eaccelerator” 缓存路径<br/><br/># mkdir /tmp/eaccelerator // 建立目录<br/># chmod 0777 /tmp/eaccelerator // 修改目录属性<br/>最后重新启动apachectl<br/><br/>抄一个eaccelerator.so配置备案：【2013-06-05】<br/><textarea name="code" class="php" rows="15" cols="100">
[eaccelerator]
zend_extension=&quot;/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
eaccelerator.shm_size=&quot;128&quot;
eaccelerator.cache_dir=&quot;/dev/shm/eaccelerator_cache&quot;
eaccelerator.enable=&quot;1&quot;
eaccelerator.optimizer=&quot;1&quot;
eaccelerator.check_mtime=&quot;1&quot;
eaccelerator.debug=&quot;0&quot;
eaccelerator.filter=&quot;&quot;
eaccelerator.shm_max=&quot;0&quot;
eaccelerator.shm_ttl=&quot;300&quot;
eaccelerator.shm_prune_period=&quot;120&quot;
eaccelerator.shm_only=&quot;0&quot;
eaccelerator.compress=&quot;1&quot;
eaccelerator.compress_level=&quot;9&quot;
</textarea><br/><br/><br/>重启apache，phpinfo显示：<br/><br/>This program makes use of the Zend Scripting Language Engine:<br/>Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies<br/>with eAccelerator v0.9.5, Copyright (c) 2004-2006 eAccelerator, by eAccelerator<br/>with Zend Extension Manager v1.0.11, Copyright (c) 2003-2006, by Zend Technologies<br/>with Zend Optimizer v3.2.2, Copyright (c) 1998-2006, by Zend Technologies<br/><br/>也会有eAccelerator的具体信息。<br/><br/>15、安装phpmyadmin，管理mysql数据库<br/><br/># cd /usr/local/apache2/htdocs/<br/># wget http://jaist.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.10.0-beta1-all-languages.tar.bz2<br/><br/># tar jxvf phpMyAdmin-2.10.0-beta1-all-languages.tar.bz2<br/># mv phpMyAdmin-2.10.0-beta1-all-languages phpmyadmin<br/><br/># cd phpmyadmin/libraries<br/>修改配置文件<br/><br/># vi config.default.php<br/>找到这几行进行修改：<br/><br/>$cfg[&#039;Servers&#039;][$i][&#039;auth_type&#039;] = &#039;http&#039;; // Authentication method (valid choices: config, http, HTTP, signon or cookie)<br/>$cfg[&#039;Servers&#039;][$i][&#039;user&#039;] = &#039;root&#039;; // MySQL user<br/>$cfg[&#039;Servers&#039;][$i][&#039;password&#039;] = &#039;PASSWORD&#039;; // MySQL password (only needed<br/>经过这几个步骤，我们一个比较安全的LAMP服务器就环境基本建立成功啦。感觉上也不是很难，是吧？<br/>当然对于打造基于动态IP的网站，以上的信息还不够，还有建立ADSL拨号，NAT，动态域名更新，防火墙，安装论坛程序等一系列的工作，我会慢慢地写出自己的心得与大家分享。毕竟这对我来说，也是个学习的过程。<br/>
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [eaccelerator.so配置]CentOS 4.4 编译安装 apache 2.2.4(mod_ssl)+php 5.2.1 with Suhosin-Patch+mysql 5.0.33+Zend Optimizer v3.2.2+eaccelerator-0.9.5+phpmyadmin 2.10笔记]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>