您的位置:首页 > 理论基础 > 计算机网络

httpd配置

2016-07-12 21:46 316 查看
httpd重要文件

/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
/etc/httpd/conf.d/README
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/httpd/logs
/etc/httpd/modules
/etc/httpd/run
/etc/logrotate.d/httpd
/etc/rc.d/init.d/htcacheclean
/etc/rc.d/init.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd
/usr/lib64/httpd

/usr/sbin/apachectl
/usr/sbin/htcacheclean
/usr/sbin/httpd
/usr/sbin/httpd.event
/usr/sbin/httpd.worker
/usr/sbin/httxt2dbm
/usr/sbin/rotatelogs
/usr/sbin/suexec
/usr/share/doc/httpd-2.2.15

/var/cache/mod_proxy
/var/lib/dav
/var/log/httpd
/var/run/httpd
/var/www
/var/www/cgi-bin
/var/www/error

/var/www/html
/var/www/icons

下面主要说一下配置
主要是修改/etc/httpd/conf/httpd.conf文件达到
配置文件:
/etc/httpd/conf/httpd.conf
### Section 1: Global Environment
### Section 2: 'Main' server configuration
### Section 3: Virtual Hosts

修改:
httpd命令:
-t:检测httpd.conf配置文件的语法错误
-M:编译的所有的模块
-l:静态编译的模块

reload:重读配置文件
restart:重启

修改监听端口:
Listen[ip:]port
可以定义多个监听端口
省略ip表示0.0.0.0
持久连接:
KeepAlive off | on 持久连接开关
MaxKeepAliveRequests 最大连接数
KeepAliveTimeout 15 最长连接时间
MPM:多路处理模块
prefork
worker
event
DSO:LoadModule
LoadModule Mod_name Mod_path(相对Server Root)

Main' Server
定义主机
ServerName

DocumentRoot:站点路径

站点资源访问控制
目录
<Diectory "目录路径">
</Directory>

文件
<File ""></File>
<FileMatch "正则表达式"></FileMatch>

url

<Location "/PATH/TO/SOME_URL">
</Location>

<LocationMatch "URL_PATTERN">
</LocationMatch>
目录中的常用指令:
Options:展开方式,空白隔开
Indexes:索引
Includes:包含
FollowSymLinks:链接,不在根目录也能访问
SymLinksifOwnerMatch:允许跟踪机制
ExecCGI:执行CGI脚本
MultiViews:
None
AllowOverride:允许访问的资源。不建议启用

order和allow/deny form
Deny,Allow :Deny指令在Allow指令之前被评估。默认允许所有访问。任何不匹配Deny指令或者匹配Allow指令的客户都被允许访问。
Allow,Deny :Allow指令在Deny指令之前被评估。默认拒绝所有访问。任何不匹配Allow指令或者匹配Deny指令的客户都将被禁止访问。

定义站点主页面
DirectoryIndex。多个值得话,左面优先
路径别名
DocumentRoot " "
Alias 定义路径别名

日志:
错误日志:
ErrorLog logs/error_log
LogLevel warn 错误级别

定制日志:
%h:远程主机名
%l:
%u:
%t:

基于用户的访问控制
<Diectory "控制的目录路径">
Options None
AllowOverride None
AuthType Basic
AuthName ""
AuthUserFile "密码文件"
Require user 用户列表
</Directory>
htpasswd -m 密码文件 账户
-c:创建文件
-m:md5加密
-s:sha加密
-D:删除指定用户

基于组账号认证
<Diectory "控制的目录路径">
Options None
AllowOverride None
AuthType Basic
AuthName ""
AuthUserFile "密码文件"
AuthGrouprFile "组文件"
Require group 组列表
</Directory>
vim一个组文件。一行一个组定义,格式为:
groupName 用户列表

虚拟主机:多站点基于不同信息进行表示。现在一般用FQDN
<VirtualHost IP:PORT>
ServerName 主机名
DocumentRoot 网站文件路径
</VirtualHost>

Errorlog 日志
CusomLog
Alias 别名
ServerAlias 主机别名

/etc/httpd/conf/*.conf
虚拟主机的信息一般写在一个conf文件中,一个主机一个conf文件,便于维护。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: