《Apache Cookbook》学习笔记

本文档详细介绍了Apache服务器的安装、模块配置、日志管理、虚拟主机、URL重写、SSL安全以及性能优化等多个方面。从安装Apache开始,包括下载源代码、编译配置、启动服务器等步骤,然后逐步讲解如何安装和配置mod_dav、mod_perl、mod_php、mod_ssl以及mod_security等关键模块。此外,还涉及了日志记录的多种方式,如通用日志格式、组合日志格式、记录POST内容、Cookie等。在虚拟主机配置中,讲解了基于域名和IP的虚拟主机设置。URL重写部分涵盖了各种重定向和重写规则,以实现URL管理和安全性。最后,文章讨论了性能调优,如内存管理、负载均衡、HTTP基准测试等,以及目录列表的展示和自定义。通过这些内容,读者可以深入理解并熟练掌握Apache服务器的高级使用技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第1章  安装
http://httpd.apache.org/download.cgi:下载源代码
% tar xzvf httpd-2.0.59.tar.gz
% ./buildconf
% ./configure --prefix=/usr/local/apache
> --with-layout=Apache --enable-modules=most --enable-mods-shared=all \
> --with-mpm=prefork:--prefix,指定文件被安装到文件系统中的目录名,--enable-layout,选择一个预先定义好的文件系统结构,--enable-mods-shared,决定各module是以DSO的方式加载还是被静态地编译到服务器中,--with-mpm,定义服务器是以多线程(Worker)还是以多进程(Prefork)方式处理请求
% make
% make install
apachectl start: 开启服务器
apachectl graceful: 重新加载配置文件,并重起服务器,会等待当前打开的活动连接完成操作以后再关闭该连接
apachectl restart: 同上,但当前存在的连接会被立即中断
apachectl stop: 停止服务器,所有存在的连接立即被中断
172.0.0.1: 测试服务器是否开启
源代码目录树最上层的config.layout文件:查看安装位置

第2章  增加常用模块
2.2 安装mod_dav
<IfModule mod_dav_fs.c>
        DAVLockDB /var/lib/dav/lockdb
</IfModule>
<Directory "/var/www/html/dav-test">
        Dav On
</Directory>: 将配置增加到/etc/httpd/conf.d/mod_dav.conf
# chgrp apache dav-test
# chmod g+w dav-test: 创建dav-test临时目录,更改所属组和访问权限
# apachectl graceful: 重启服务器
# setenforce 0: 关闭SELinux
# getenforce: 获取当前SELinux运行状态
% cd /tmp
% echo "Plain text" > dav-test.txt
% cadaver
dav:! open http://localhost/dav-test
dav:/dav-test/> put dav-test.txt
dav:/dav-test/> propset dav-test.txt MyProp 1023
dav:/dav-test/> propget dav-test.txt MyProp
dav:/dav-test/> propdel dav-test.txt MyProp
dav:/dav-test/> close
dav:!> exit: 通过cadaver工具测试WebDAV请求  
2.4 安装mod_perl
% perl Makefile.PL MP_APXS=/usr/local/apache/bin/apxs MP_CCOPTS=-fgnu89-inline MP_APR_CONFIG=/usr/local/src/httpd-2.4.20/srclib/apr/apr-config
% make
# make install
LoadModule perl_module /usr/local/apache/modules/mod_perl.so: 将配置增加到/etc/httpd/conf.modules.d/11-perl.conf
Alias /perl/ /var/www/html/perl/
<Location /perl/>
      SetHandler perl-script
      PerlResponseHandler ModPerl::Registry
      PerlOptions +ParseHeaders
      Options +ExecCGI
      Order allow,deny
      Allow from all
</Location>: 将配置增加到/etc/httpd/conf.d/mod_perl.conf
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "mod_perl 2.0 rocks!\n";: 将脚本增加到/var/www/html/perl/rock.pl
% chmod a+rx /var/www/html/perl/rock.pl: 改变文件权限
firefox http://localhost/perl/rock.pl: 测试mod_perl
2.5 安装mod_php
http://php.net: 下载php-7.0.8
% cd php-7.0.8
% ./configure --with-apxs2=/usr/local/apache/bin/apxs
% make
% make install
LoadModule php7_module /usr/local/apache/modules/libphp7.so: 增加到/etc/httpd/conf.modules.d/11-php.conf
<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>: 增加到/etc/httpd/conf.d/libphp7.conf
<?php phpinfo(); ?>: 增加到/var/www/html/php/info.php
firefox http://localhost/php/info.php: 测试mod_php
2.7 安装mod_ssl
yum install openssl-devel: 安装openssl-devel
% ./configure --prefix=/usr/local/apache --with-layout=Apache --enable-modules=most --enable-mods-shared=all --with-mpm=prefork --enable-ssl
% make
% make install: ./configure 后增加--enable-ssl
2.9 安装mod_security
http://modsecurity.org: 下载modsecurity-2.9.1
下载并安装apr-util-1.5.4
# ./configure --with-apxs=/usr/local/apache --with-apr=/usr/local/src/httpd-2.4.20/srclib/apr/apr-config
# make
# make install
LoadFile /usr/lib64/libxml2.so
LoadFile /usr/lib64/liblua-5.3.so
LoadModule security2_module /usr/local/apache/modules/mod_security2.so: 增加到/etc/httpd/conf.modules.d/11-security.conf

第3章  日志
"%h %l %u %t \"%r\" %>s %b": 通用日志格式,客户端的主机名称或IP地址、在客户端上的用户名称、验证客户端所用的用户名称、接收到请求的时间、设计的HTTP请求行的内容、服务器处理请求的最后状态,以及在服务器的响应中所传送的网页内容的字节数
"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"{User-agent}i\"": 组合日志格式,Referer为连接到所请求文件网页的URL,User-agent为提出请求的浏览器或其他客户端软件的名称与版本
CustomLog logs/access_log combined: 日志文件以组合日志格式来启用记录日志功能
LogLevel Debug: 设置错误日志记录等级为debug, emerg紧急状况,alert必须立即采取措施,crit危机的状况,error错误的状况,warn警告的状况,info只提供信息,debug调试级信息
3.3 记录网页的POST内容
使用mod_security:
SecAuditLogType Concurrent
SecAuditLogStorageDir /var/www/audit_log/data/
SecAuditLog /var/www/audit_log/index
SecAuditLogParts ABCFHZ
3.6 记录Cookie
记录从客户端收到的cookie:
CustomLog logs/cookies_in.log "%{UNIQUE_ID}e %{Cookie}i"
CustomLog logs/cookies2_in.log "%{UNIQUE_ID}e %{Cookie2}i"
记录由服务器设定并传送给客户的cookie:
CustomLog logs/cookies_out.log "%{UNIQUE_ID}e %{Set-Cookie}o"
CustomLog logs/cookies2_out.log "%{UNIQUE_ID}e %{Set-Cookie2}o"
3.7 不记录来自本机的网页请求
使用SetEnvNoCase:
<FilesMatch \.(jpg|gif|png)$>
    SetEnvIfNoCase Referer "^http://www.example.com/" local_referrer=1
</FilesMatch>
CustomLog logs/access_log combined env!=local_referrer
3.8 在特定时刻更新日志
CustomLog "| /usr/sbin/rotatelogs /etc/httpd/logs/access_log.%Y-%m-%d 86400" combined: 每隔一天(86400秒)将日志更新到access_log.2016-7-1文件中
3.14 记录服务器的IP地址
CustomLog log/served-by.log "%A": 若虚拟主机带有多个地址,记录响应请求的服务器的IP地址
3.17 记录请求标头中的任意字段
在访问日志格式的声明中使用%{ }i的日志格式变量,若记录Host标头,则使用%{Host}i
3.18 记录响应标头中的任意字段
在访问日志的格式声明中使用%{ }o的日志格式变量,若记录Last-Modified标头,则使用%{Last-Modified}o

第4章  虚拟主机
4.1 设置一个基于域名的虚拟主机
ServerName 127.0.0.1
<VirtualHost *:80>
    ServerName server1
    DocumentRoot "/var/www/html/server1"
</VirtualHost>
<VirtualHost *:80>
    ServerName server2
    DocumentRoot "/var/www/html/server2"
</VirtualHost>
httpd -S: 查看当前apache中被成功配置的虚拟主机信息
4.3 建立以IP寻址的虚拟主机
ServerName 127.0.0.1
<VirtualHost 10.0.0.1>
    ServerName server1
    DocumentRoot "/var/www/html/server1"
</VirtualHost>
<VirtualHost>
    ServerName server2
    DocumentRoot "/var/www/html/server2"
</VirtualHost>
4.8 替每个虚拟主机建立日志记录
<VirtualHost *:80>
    ServerName server1
    DocumentRoot "/var/www/html/server1"
    ErrorLog "/var/www/html/logs/error_log"
    CustomLog "/var/www/html/logs/server1/access_log" combined
</VirtualHost>

第5章  别名、重定向及重写
5.1 将URL对应到一个目录
Alias "/desired-URL-prefix" "/path/to/other/directory": 将以/desired-URL-prefix开头的URL对应到/path/to/other/directory目录中的文件,例对http://example.com/desired-URL-prefix/something.html的请求会让/path/to/other/directory/something.html文件传送至客户端
5.2 给现有网页内容创建新的URL
Alias "/newurl" "/www/htdocs/oldurl": 将/newurl对应到/www/hodocs/oldurl
5.3 让用户有自己的URL
UserDir public_html: 让所有用户的Web目录位于其主目录下
UserDir "/www/user/*/htdocs": 将所有用户的Web目录都放在集中的位置
RewriteEngine On
RewriteCond "/home/$1/public_html" -d [NC]
RewriteRule "^/([^/]+)/(.*)" "/home/$1/public_html/$2": 不使用~符号就可以访问他们的网页空间
5.4 以单一指令创建多个URL别名
AliasMatch "^/pupp(y|ies)" "/www/docs/small_dogs": 以/puppy及/puppies开头的URL对应到/www/docs/small_dogs目录
AliasMatch "^/P-([:alnum:]])([^/]*)" "/usr/local/projects/$1/$2": 以/P-Example开头的URL对应到/usr/local/projects/E/Example目录
5.5 映射多个URL到相同的CGI目录
ScriptAliasMatch "^/[sS]cript?|cgi(-bin)?/" "/www/cgi-bin/": 将以/script/,/scripts/,/Script/,/Scripts/,/cgi/及/cgi-bin/开头的请求对应至/www/cgi-bin/目录
5.6 给每个用户创建CGI目录
<Directory "/home/*/public_html/cig-bin/">
    Options ExecCGI
    DetHandler cgi-script
</Directory>
ScriptAliasMatch "/~([^/]+)/cig-bin/(.*)" "/home/$1/public_html/cgi-bin/$2"
5.7 重定向到其他位置
Redirect "/example" "http://www2.example.com/new/location"
5.8 将多个URL重定向到同以位置
RedirectMatch "^/[fF]ish(ing)?(/.*)?" "http://fish.example.com/$2"
5.9 允许不区分大小写的URL
CheckSpelling on: 使用mod_speling模块
5.10 在网页上高亮显示PHP源代码,而不需要建立符号链接
RewriteRule "^(.+\.php)s$" "$1" [H=application/x-httpd-php-source]
5.11 替换请求URL中的文字
RewriteRule "(.*)string1(.*)" "$1string2$2" [N,PT]
5.12 将路径信息重写至CGI参数
RewriteEngine on
RewriteRule "^/book/([^/]*)/([^/]*)" "/cgi-bin/book.cgi?author=$1&subject=$2" [PT]
5.13 拒绝访问未被引用的请求
RewriteEngine On
RewriteCond "%{HTTP_REFERER}" !=""
RewriteCond "%{HTTP_REFERER}" "!^http://mysite.com/.*$" [NC]
RewriteRule "\.(jpg|gif|png)$ - [F]
5.14 重定向未引用的请求到一个说明页面
RewriteEngine On
RewriteCond "%{HTTP_REFERER}" "^$"
RewriteRule "(.*)" "/cgi-bin/need-referer" [PT,E=ORIG:$1]
5.15 依据查询子符传来重写
RewriteCond "%{QUERY_STRING}" "^user=([^=]*)"
RewriteRule "/people" "http://%1.usres.example.com/" [R]
5.16 将服务器的全部或符分重定向至SSL
RewriteCond "%{SERVER_PORT}" "^80$"
RewriteRule "^(.*)$" "https://%{SERVER_NAME}$1" [R,L]
5.17 将目录转换成主机名称
RewriteRule "^/(patha|pathb|pathc)(/.*)" "http://$1.example.com$2" [R]: 将http://example.com/patha/some/file.html的请求重定向至http://patha.example.come/some/file.html
RewriteRule "^/([^./]*)(/.*)" "http://$1.example.com$2" [R]: 重定向任何最上层的路径片段
RewriteRule "^/~([^./]*)(/.*)" "http://$1.example.com$2" [R]: 将所有用户的请求,以相同的用户名称重定向至不同的主机
5.18 将所有请求重定向至单一主机
RewriteCond "%{HTTP_HOST}" "!^www.example.com" [NC,OR]: NC(no case)让正则表达式忽略大小写,OR(or)或,只要两种状况之一为真,则应用规则
RewriteCond "%{SERVER_NAME}" "!^www.example.com" [NC]
RewriteRule "(.*)" "http://www.example.com$1" [R]: R(Redirect)启用实际的Redirect
5.19 将文件名转换成参数
RewriteRule "^/dir/([^./]*)\.html" "/dir/script.cgi?doc=$1" [PT]: PT执行后续的所有适当的URL重写或操作
5.20 URL路径和查询字符串的重写
RewriteRule "^(/path/to)/(\d+)" "$1?id=$2" [PT]
5.21 重写一个主机名称为一个主机
RewriteCond "%{HTTP_HOST}" "^([^.]+)\.example\.com" [NC]
RewriteRule "(.*)" "http://example.com/%1$1" [R]
5.22 把URL的一部分作为查询参数输入
RewriteRule "/(.*)" "/cgi-bin/remap?page=$1" [QSA,PT]: QST允许任何存在于原始请求中的查询字符串信息被保留,并合并到一个RewriteRule中的URL中去,PT让服务器继续处理请求而不是在完成重写之后立即结束后续请求

第6章  安全防护
6.4 限制上传文件的大小
<Directory "/usr/local/apache/uploads">
    LimitRequestBody 10000
</Directory>: 限制上传文件的大小为10000字节
6.5 禁止在网站外使用图像
<FileMatch "\.(jpg|jpeg|gif|png)$">
    SetEnvIfNoCase Referer "^http://([^/]*\.)?myserver.com/" local_referrer=1
    Order Allow,Deny
    Allow from env=local_referrer
</FileMatch>
6.6 同时要求弱验证和强验证
<Directory /www/htdocs/sensitive>
    Satisfy All
    AuthType Basic
    AuthName Sensitive
    AuthUserFile /www/passwords/users
    AuthGroupFile /www/passwords/groups
    Require group salesmen
    Order deny,allow
    Deny from all
    Allow from 192.168.1
</Directory>
6.7 管理.hppasswd文件
使用htpasswd工具/使用Perl模块Apache::Htpasswd来管理密码文件
6.11 使用文件所有权来授权
<Directory /home/*/public_html/private>
    AuthType Basic
    AuthName "MyOwnFiles"
    AuthUserFile /some/master/authdb
    Require file-owner
</Directory>
6.18 安全的WebDAV
<Directory "/www/htdocs/dav-test">
    Order Allow,Deny
    Deny from all
    AuthDigestFile "/www/acl/.htpasswd-dav-test"
    AuthDigestDomain "/dav-test/"
    AuthName "DAV access"
    Require valid-user
    Satisfy Any
</Directory>
6.20 禁止通过代理服务器访问特定的URL
ProxyBlock .rm .ra .mp3: 使用关键词来阻挡
<Directory proxy:http://other-host.org/path>
    Order Allow,Deny
    Deny from all
    Satisfy All
</Directory>: 以特定末端的URL来阻挡
6.25 禁止访问网站根目录以外的文件
<Directory />
    Order deny,allow
    Deny from all
    AllowOverride None
    Options None
</Directory>
6.28 使用mod_evasive防止DOS(拒绝服务)攻击
6.31 使用mod_security阻挡蠕虫攻击
6.32 使用只读和写的混合权限访问一个Subversion Repository
<Location "/repos"
    DAV svn
    SVNParentPath "/repository/subversion"
    AuthType Basic
    AuthName "Log in for write access"
    AuthUserFile "/path/to/authfile"
    <LimitExcept GET REPORT OPTIONS PROPFIND>
        Requre valid-user
    </LimitExcept>
</Location>

第7章  SSL
SSL:Secure Socket Layer,加密套接字协议层
7.3 产生一个自签署的SSL证书
% openssl genrsa -out server.key 1024: genrsa产生RSA密钥,-out指定产生的密钥文件的名称,1024产生密钥时使用多少随机字节
% openssl req -new -key server.key -out server.csr
% cp server.key server.key.org
% openssl rsa -in server.key.org -out server.key
% openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
将以上文件移至配置目录,并在httpd.conf中加入以下内容
SSLCertificateFile "/www/conf/server.crt"
SSLCertificateKeyFile "/www/conf/server.key"
7.4 产生一个被信任的CA
% CA.pl -newca
% CA.pl -newreq
% CA.pl -signreq
% CA.pl -pkcs12
7.5 让网站的一部分由SSL提供服务
<Directory /www/secure>
    SSLRequireSSL
</Directory>
7.6 使用客户端证书来验证
SSLVerifyClient require
SSLVerityDepth 1
SSLCACertificateFile conf/ssl.crt/ca.crt

第8章  动态网页内容
8.1 启用CGI目录
Alias /cgi-bin/ /www/cgi-bin/
<Location /cgi-bin/>
    Options ExecCGI
    SetHandler cgi-script
</Location>
8.2 在不使用ScriptAlias目录中启用CGI目录
<Directory "/foo">
    Options +ExecCGI
    AddHandler cgi-script .cgi .py .pl
</Directory>
8.3 给一个CGI目录指定默认的文档
<Directory /www/cgi-bin>
    Options ExecCGI
    SetHandler cgi-script
    DirectoryIndex index.pl

    Order allow,deny
    Allow from all
    AllowOverride none
</Directory>
8.8 为特定内容类型调用CGI程序
Action watermark /cgi-bin/watermark.cgi
AddHandler watermark .gif .jpg: 当请求.gif或.jpg文件时,就会调用watermark.cgi
8.9 让SSI能顺利工作
<Directory /www/html/example>
    Options +Includes
    AddType text/html .shtml
    AllFilter INCLUDES .shtml
</Directory>
8.10 显示上次修改的时间
<!--#config timefmt="%B %e, %Y" -->
This document was last modified on <!--#echo var="LAST_MODIFIED" -->
8.11 包含一个标准的页头
<!--#include virtual="/include/headers.html" -->
8.12 包含一个CGI程序的输出
<!--#include virtual="/cgi-bin/content.cgi" -->
8.16 启用PHP脚本处理
AddHandler application/x-httpd-php .phtml .php
8.18 在CGI程序的输出中支持服务器端包含指令
Options +Includes
AddOutputFilter INCLUDES .cgi
8.19 让ScriptAlias目录中的脚本程序的输出支持服务器端包含指令
Options +Includes
SetOutputFilter INCLUDES
8.20 让所有的Perl脚本被mod_perl来执行
PerlModule Apache::Registry
<FilesMatch \.pl$>
    SetHandler perl-script
    PerlHandler Apache::Registry
</FilesMatch>
8.21 开启Python脚本处理
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On

第9章  错误处理
9.3 自定义错误信息
ErrorDocument 405 /errors/notallowed.html
9.5 将非法URL重定向到其他网页
ErrorDocument 404 /index.html
DirectoryIndex index.html /path/to/notfound.html

第10章  代理服务器
10.1 保护你的代理服务器
<Proxy *>
    Order Deny,Allow
    Deny from all
    Allow from .yourdomain.com
</Proxy>
10.2 防止代理服务器被用作开放式的邮件转发工具
<Directory proxy:*>
    RewriteEngine On
    RewriteRule "^proxy:[a-z]*://[^/]*:25(/|$)" "-" [F,NC,L]
</Directory>
10.3 将请求传递给其他服务器
ProxyPass /other/ http://other.server.com/
ProxyPassReverse /ether/ http://other.server.com/: URL为/other/example.html的请求将对应到http://other.server.com/example.html
10.4 阻断对特定位置的代理请求
ProxyBlock forbiddensite.com www.competitor.com monster.com: 禁止所列出网站的代理请求
10.5 以其他服务器作为mod_perl网页内容的代理服务器
ProxyPass /dynamic/ http://localhost:90/
ProxyPassReverse /dynamic/ http://localhost:90/
10.6 配置一个启用高速缓存功能的代理服务器
ProxyRequests on
CacheRoot /var/spool/httpd/proxy
10.7 过滤代理的网页内容
ExtFilterDefine naughtywords mode=output intype=text/html cmd="/bin/seds/darned/blasted/g"
<Proxy *>
    SetOutpueFilter naughtywords
</Proxy>
10.8 对代理服务器要求进行身份验证
ProxyPass "/secretserver/" "http://127.0.0.1:8080"
<Directory "proxy:http://127.0.0.1:8080"
    AuthName SecretServer
    AuthType Basic
    AuthUserFile /path/to/secretserver.htpasswd
    Require valid-user
</Directory>
10.9 使用mod_proxy_balancer进行负载均衡
<Proxy balancer://mycluster>
    BalancerMember http://192.168.1.50:80
    BalancerMember http://192.168.1.51:80
</Proxy>
ProxyPass /application balancer://mycluster/
10.10 虚拟主机的代理
<VirtualaHost *:80>
    ServerName server2.example.com
    ProxyPass / http://192.168.1.52:80
    ProxyPassReverse / http://192.168.1.52:80
</VirtualHost>
10.11 拒绝代理FTP请求
# LoadModule proxy_ftp_module modules/mod_proxy_ftp.so: 确保mod_proxy_ftp不被加载

第11章  性能
11.1 决定需要多少内存
内存=pache进程平均所需的内存容量*最大负荷量
11.2 使用ab对Apache进行基准测试
ab -n 1000 -c 10 http://www.example.com/test.html: -n请求的次数,-c并发水平,每次同时发出的请求数,-k使ab运行在keepalive模式下
11.3 调节keepalive的设定
KeepAlive On
MaxKeepAliveRequests 0: 0表示在单一连接时间允许不限数目的请求
KeepAliveTimeout 15
11.4 得到网站快照
<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny form all
    Allow from 192.168.1
</Location>
ExtendedStatus On
11.5 避免DNS查询
HostNameLookups Off
11.6 最佳化符号链接
Options FollowSymLinks
11.7 最小化.htaccess文件对性能的影响
AllowOverride None: 以<Directory>区块启用必要的.htaccess文件
11.8 禁用网页内容协商
Option -MultViews
AddHandler type-map var
11.11 将经常查看的文件存入高速缓冲区
CacheFile /www/htdocs/index.html
CacheFile /www/htdocs/other_page.html: 编译时需设定--enable-file_cache
11.12 平均分配名服务器间的负载
www.example.com. 86400 IN A 192.168.10.2
www.example.com. 86400 IN A 192.168.10.3
www.example.com. 86400 IN A 192.168.10.4
www.example.com. 86400 IN A 192.168.10.5
www.example.com. 86400 IN A 192.168.10.6
www.example.com. 86400 IN A 192.168.10.7
FileETag MTime Size
11.13 将目录列表存入高速缓冲区
IndexOptions +TrackModified
11.14 使用mod_perl加速Perl CGI程序的运行
PerlModule ModPerl::PerlRun
Alias /cgi-perl/ /usr/local/apache2/cgi-bin/
<Location /cgi-perl>
    SetHandler perl-script
    PerlResponseHandler ModPerl::PerlRun
    Options +ExecCGI
</Location>
PerlModule ModPerl::Registry
Alias /perl/ /usr/local/apache2/cgi-bin/
<Location /perl>
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    Options +ExecCGI
</Location>
11.15 缓存动态内容
CacheEnable disk /
CacheRoot /var/www/cache
CacheDefaultExpire 600
CacheMinExpire 600

第12章  目录列表
12.1 生成目录内容列表
<Directory /www/htdocs/images>
    Options +Indexes
</Directory>
Options FollowSymLinks Indexes: 服务器启用mod_autoindex
12.2 在目录列表页面上显示一个标准的页头和页脚
IndexOptions +SuppressHTMLPreamble
HeaderName /includes/header.html
ReadmeName /includes/footer.html
12.3 给目录列表应用样式表
IndexStyleSheet /styles/listing.css
12.4 在目录列表中隐藏一些列表项
IndexIgnore *.tmp *.swp .svn secret.txt
12.5 在一个目录列表中检索特定文件
http://servername/directory/?P=a*: 名称以a开头的文件将被列出
12.6 对目录列表进行排序
IndexOrderDefault Descending Date
12.7 允许客户端指定排序顺序
http://servername/directory/?C=D&O=D: C排序列,N名称,M上次修改时间,S文件大小,D使用AddDescription指令设置的文件描述,O(order),A升序,D降序
12.8 指定列表的显示格式
IndexOptions FancyIndexing
IndexOptions FancyIndexing HTMlTables
12.9 允许客户端指定格式
http://www.example.com/icons/?F=0: 指定格式为简单的符号列表
http://www.example.com/icons/?F=1: 指定格式为格式化的列表
http://www.example.com/icons/?F=2: 指定格式为HTML表格排列的列表
12.10 给文件增加描述
AddDescription "GIF image" .gif
12.11 自动产生文档标题
IndexOptions ScanHTMLTitles
12.12 改变列表图标
AddIcon /icons/image.gif .gif .jpg .png
12.13 把文件夹排在目录列表的最前面
IndexOptions FoldersFirst
12.14 让文件按照版本号进行排序
IndexOptions VersionSort
12.15 允许用户指定版本排序
http://www.example.com/download/?V=1: 启用版本排序
http://www.example.com/download/?V=0: 禁用版本排序
12.16 不允许用户修改列表
IndexOptions +IgnoreClient
12.18 控制特定的列
IndexOptions SuppressLastModified: 隐藏列表中文件的时间戳,SuppressDescription隐藏description列,SuppressIcon不显示图标,SuppressSize隐藏文件大小
12.19 显示禁止访问的文件
IndexOptions +ShowForbidden
Over 90 hands-on recipes to successfully build and automate development life cycle tasks following Maven conventions and best practices About This Book Understand the features of Apache Maven that makes it a powerful tool for build automation Full of real-world scenarios covering multi-module builds and best practices to make the most out of Maven projects A step-by-step tutorial guide full of pragmatic examples Who This Book Is For If you are a Java developer or a manager who has experience with Apache Maven and want to extend your knowledge, then this is the ideal book for you. Apache Maven Cookbook is for those who want to learn how Apache Maven can be used for build automation. It is also meant for those familiar with Apache Maven, but want to understand the finer nuances of Maven and solve specific problems. What You Will Learn Install Apache Maven successfully on your preferred OS Explore the various features of Apache Maven to build efficient automation tools Discover when and how to use the various Apache Maven plugins Generate and publish your project documentation using Apache Maven Analyze and control code quality and code coverage using Apache Maven Build various types of Java projects as well as other binaries Set up complex projects using the concept of inheritance In Detail Apache Maven offers a comprehensive set of features to build, test, release, and deploy software projects and maintain enterprise development infrastructure. This book is a hands-on guide that enables you to explore the vast potential of Apache Maven, the leading software build tool. You will start off by successfully installing Apache Maven on your favorite OS, and then you will create your first working project. Furthermore, the book walks you through setting up and using Maven with popular Java Integrated Development Environments (IDEs) so you can exploit Maven features to build standard Java applications. Above all, you will also learn to create site reports and documentation for your project along with handling typical build requirements and other advanced Maven usages. Table of Contents Chapter 1: Getting Started Chapter 2: IDE Integration with Maven Chapter 3: Maven Lifecycle Chapter 4: Essential Maven Plugins Chapter 5: Dependency Management Chapter 6: Code Quality Plugins Chapter 7: Reporting and Documentation Chapter 8: Handling Typical Build Requirements Chapter 9: Multimodule Projects Chapter 10: Java Development with Maven Chapter 11: Advanced Maven Usage
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值