http_conf主配置说明
root@lamp01 apache]# grep -Ev "#|^$" conf/httpd.confDocumentRoot "/usr/local/apache/htdocs" -->服务器的根目录Listen 80 -->监听本机所有IP的80端口User daemon -->默认用户Group daemon -->默认属组ServerAdmin you@example.com -->管理员邮箱DocumentRoot "/usr/local/apache/htdocs" -->默认站点目录-->权限控制,表示根目录拒绝所有连接 Options FollowSymLinks AllowOverride None Order deny,allow Deny from all -->新添加站点时候必须重新配置 Options Indexes FollowSymLinks -->允许显示目录结构,不安全 AllowOverride None Order allow,deny Allow from all -->网站首页 DirectoryIndex index.html -->文件匹配 Order allow,deny Deny from all Satisfy All ErrorLog "logs/error_log" -->错误日志配置LogLevel warn -->错误日志级别-->日志类型 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio CustomLog "logs/access_log" common-->支持cgi-bin的配置,以及淘汰的语言 ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/" AllowOverride None Options None Order allow,deny Allow from all DefaultType text/plainRequestHeader unset Proxy early TypesConfig conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz SSLRandomSeed startup builtinSSLRandomSeed connect builtin
Apache结构优化:
1.不对外展示目录结构vim /usr/local/apache/conf/http.conf#新添加站点时候必须重新配置 Options -Indexes FollowSymLinks #注释掉htdocs下的Indexes(添加-) AllowOverride None Order allow,deny Allow from all
2.删除cgi-bin(已经淘汰的)
vim /usr/local/apache/conf/http.conf ##AllowOverride None #Options None #Order allow,deny #Allow from all #
3.关闭界面不显示Apache版本号(注释掉即可)
vim /usr/local/apache/conf/extra/httpd-default.conf #ServerTokens Full #ServerSignature On
4.打印不带图片的日志
隐藏Apache版本信息
1.编译源文件,进行修改 vim /root/software/httpd-2.2.34/include/ap_release.h 2.修改默认UNIX vim /root/software/httpd-2.2.34/os/unix/os.h define PLATFORM "WIN" -->修改点