Apache 常见配置文件
conf/httpd.conf控制服务器程序运作的指令。
log/httpd.pid
Httpd 程序运行的进程号,可以用
Kill –HUP httpd_pid 重起Web服务器
log/error_log
ErrorLog 指令设定
logs/access_log
TransferLog指令设定
Group 启动 Apache 服务器的组身份
User 启动 Apache 服务器的用户身份
Port 启动 Apache 服务器的端口
ServerAdmin 电子邮件地址
ServerName 完整的域名
TimeOut 数字
UserDir 指定用户主页空间目录名
DirectoryIndex 指定主页首页的可用文件名
语法: DocumentRoot 目录名称
预设: DocumentRoot /usr/local/etc/httpd/htdocs
用於: server config, virtual host
状态: 核心
这个指令设定 httpd从这个目录提供档案服务。除非符合像是 Alias这样的指令,伺服器把所要求的 URL附加到文件根 (document root)来组合到达文件的路径。例如:
DocumentRoot/usr/web
如此对於 http://www.my.host.com/index.html档案的存取便会参照到 /usr/web/index.html
语法: ErrorDocument 错误代码 文件
用於: server config, virtual host
状态: 核心
有问题或错误发生的状况下,可以配置阿帕契做四种反应
1.如同 NCSA httpd 1.3 的反应
2.输出自定的(customized)讯息
3.重导到某个本地的 URL以处理该问题/错误
4.重导到某个外部的 URL以处理该问题/错误
通常的配置:
ErrorDocument 500 /cgi-bin/tester
ErrorDocument 404 /cgi-bin/bad_urls.pl
ErrorDocument 401 http://www.foo.bar/subscription_info.html
ErrorDocument 403 "Sorry can't allow you acess today
语法: MaxClients 数字
预设: MaxClients 150
用於: server config
状态: 核心
这个 MaxClients 指令设定所能支援的同时存取要求数目;不会建立比此值还多的子程序。
语法: Alias url-路径 目录-档案名称
用於: server config, virtual host
状态: 基础
Alias 这个指令使文件可以存放在 DocumentRoot 之外的本地档案系统里。以 url-路径 开始的 URLs 将会被对映到以 目录-档案名称开始的本地档案去。例如:
Alais /image /ftp/pub/image
对於 http://myserver/images/foo.gif 的这个请求会使得伺服器回传档案 /ftp/pub/image/foo.gif
语法: Redirect url-路径 url
用於: server config, virtual host
状态: 基础
模组: mod_alias
Redirect这个指令对映旧的 URL到新的去。新的 URLs 会被回传客户端以便配合新的位址再次尝试撷取。Url-路径 (%-decoded)路径;任何以这个路径作为开始的文件请求都将回传一个错误并重导到以 url作为开始的新(%-encoded) url 去。例如:
Redirect /service http://foo2.bar.com/service
如果客户端请求 http://myserver/service/foo.txt则会被告知应该撷取 http://foo2.bar.com/service/foo.txt来取代。
语法: ScriptAlias url-路径 目录-档案名称
用於: server config, virtual host
状态: 基础
模组: mod_alias
ScriptAlias 这个指令除了还另外把目标目录标记为包含 CGI指令稿以外其功能与 Alias指令相同,以 url-路径 作为开始的 URLs 将会被对映到以 目录-档案名称作为开始的指令稿去。例如:
ScriptAlias /cgi-bin/ /web/cgi-bin/
"100" : Continue
"101" : witching Protocols
"200" : OK
"201" : Created
"202" : Accepted
"203" : Non-Authoritative Information
"204" : No Content
"205" : Reset Content
"206" : Partial Content
"300" : Multiple Choices
"301" : Moved Permanently
"302" : Found
"303" : See Other
"304" : Not Modified
"305" : Use Proxy
"307" : Temporary Redirect
"400" : Bad Request
"401" : Unauthorized
"402" : Payment Required
"403" : Forbidden
"404" : Not Found
"405" : Method Not Allowed
"406" : Not Acceptable
"407" : Proxy Authentication Required
"408" : Request Time-out
"409" : Conflict
"410" : Gone
"411" : Length Required
"412" : Precondition Failed
"413" : Request Entity Too Large
"414" : Request-URI Too Large
"415" : Unsupported Media Type
"416" : Requested range not satisfiable
"417" : Expectation Failed
"500" : Internal Server Error
"501" : Not Implemented
"502" : Bad Gateway
"503" : Service Unavailable
"504" : Gateway Time-out
"505" : HTTP Version not supported
单独的个人主页:http://servername/~username
登录为root, 修改用户主目录权限#chmod 705 /home/username 让其他人有权进入该目录浏览。
以自己的用户名登录,创建public_html目录,保证该目录也有正确的权限让其他人进入。
Apache默认的主页文件是index.html,不是index.htm,请将首页的文件名设为 index.html
用户自己在主目录下创建的目录最好把权限设为0700,确保其他人不能进入访问。
在/etc/rc.d/rc.local中增加命令让机器增加一个IP
/sbin/ifconfig eth0:0 192.168.11.4
/sbin/route add -host 192.168.11.4 eth0:0
在conf/httpd.conf 中配置
ServerAdmin webmaster@host.foo.com
DocumentRoot /www/docs/host.foo.com
ServerName host.foo.com
ErrorLog logs/host.foo.com-error_log
TransferLog logs/host.foo.com-access_log
页:
[1]