CentOS配置文档之五:服务器的优化配置
前几日装的PHP5.3竟然不支持最新的ZendOptimizer3.3.3版本。尝试了第一点的ZendOpt还是不支持,只有更换了低版本的PHP5.2.1才解决问题。
一、安装ZendOptimizer优化模块
下载bz2包,直接install即可。完全傻瓜式操作。
二、Apache服务器的优化
为了不必要的信息泄露,我们需要对Apache的conf文件作相应的配置调整
1、/extra/httpd-default.conf
#在出现错误页的时候不显示服务器操作系统的名称
ServerTokens Prod
#在错误页中不显示Apache的版本
ServerSignature Off
2、/httpd.conf
#将管理员邮箱设置为自己常用的邮箱
ServerAdmin yobbozhu@gmail.com
#修改主机名
ServerName 192.168.1.200
#禁用WWW目录下的目录浏览权限,并启用可执行CGI功能(default区块和<Directory “/var/www/html”>区块)
Options Includes ExecCGI FollowSymLinks
#允许扩展名为.pl的CGI脚本运行
AddHandler cgi-script .cgi .pl
#允许使用.htaccess(default区块和<Directory “/var/www/html”>区块)
AllowOverride All
#添加“!414”到日志记录规则中,对于过长的日志不记录,找到
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”" combined,修改为
LogFormat “%h %l %u %t \”%!414r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”" combined
*完成后重启apache服务
三、测试页面
1、phpinfo();
2、index.html
3、test.cgi
#!/usr/bin/perl
print “Content-Type: text/html\n\n”;
print “<html><body>”;
print “Hello,World!CGI is working!<br>”;
print “</body></html>”;
4、.htaccess文件
#www目录下建立.htaccess文件,内容
DirectoryIndex index2.html
#/wwwroot/index2.html,内容
This is index2 html file.
运行执行http://192.168.1.200后出现index2文件内容即可证明.htaccess成功生效

