“Apache”的版本间差异
		
		
		
		
		
		跳到导航
		跳到搜索
		
				
		
		
	
| 无编辑摘要 | |||
| 第4行: | 第4行: | ||
|  <Directory "/var/www/html"> |  <Directory "/var/www/html"> | ||
|  Options FollowSymLinks #该目录下允许文件系统使用符号连接。 |  Options FollowSymLinks #该目录下允许文件系统使用符号连接。 | ||
| ⚫ | |||
|  AllowOverride  AuthConfig #允许存在于.htaccess文件中的指令类型 |  AllowOverride  AuthConfig #允许存在于.htaccess文件中的指令类型 | ||
|  Order allow,deny #Order:控制在访问时Allow和Deny两个访问规则哪个优先 |  Order allow,deny #Order:控制在访问时Allow和Deny两个访问规则哪个优先 | ||
| 第9行: | 第10行: | ||
|  #Deny:拒绝访问的主机列表。 |  #Deny:拒绝访问的主机列表。 | ||
|  </Directory> |  </Directory> | ||
| *AllowOverride 的选项 | *AllowOverride 的选项 | ||
| :None: 当AllowOverride被设置为None时。不搜索该目录下的.htaccess文件(可以减小服务器开销)。 | :None: 当AllowOverride被设置为None时。不搜索该目录下的.htaccess文件(可以减小服务器开销)。 | ||
| 第20行: | 第22行: | ||
| *.httpasswd 可以用htpasswd -b -c filepath  username password 生成 | *.httpasswd 可以用htpasswd -b -c filepath  username password 生成 | ||
| ⚫ | |||
| *options FollowSymLinks,符号链接对应的目录应该有明确的<Directory>定义,要注意[[SELinux]]的设置。 | |||
| ⚫ | |||
| ⚫ | |||
|  Options Indexes | |||
| ⚫ | |||
|  <IfModule mod_userdir.c> |  <IfModule mod_userdir.c> | ||
|    UserDir enabled ;这个很重要 |    UserDir enabled ;这个很重要 | ||
|    UserDir public_html |    UserDir public_html | ||
|  </IfModule> |  </IfModule> | ||
| 在fc21中这个配置在 /etc/httpd/conf.d/userdir.conf 文件当中 | |||
| ==[[SElinux]]的配置== | ==[[SElinux]]的配置== | ||
| *设置某目录http可访问 | |||
| ⚫ | |||
| *在SElinux enable的时候不能读~/public_html 目录下的内容 | *在SElinux enable的时候不能读~/public_html 目录下的内容 | ||
|  setsebool -P httpd_read_user_content 1 |  setsebool -P httpd_read_user_content 1 | ||
|  setsebool -P  |  setsebool -P httpd_enable_homedirs true (不知道哪个是对的) | ||
|  chcon -R -t httpd_sys_content_t /home/*/public_html (对已经存在的目录需要这么做) | |||
2015年5月27日 (三) 11:21的版本
常见httpd.conf的配置
增加某个目录可以访问
<Directory "/var/www/html"> Options FollowSymLinks #该目录下允许文件系统使用符号连接。 Options Indexes #允许列出目录中的所有内容 AllowOverride AuthConfig #允许存在于.htaccess文件中的指令类型 Order allow,deny #Order:控制在访问时Allow和Deny两个访问规则哪个优先 Allow from all #A允许访问的主机列表(可用域名或子网,例如:Allow from 192.168.0.0/16)。 #Deny:拒绝访问的主机列表。 </Directory>
- AllowOverride 的选项
- None: 当AllowOverride被设置为None时。不搜索该目录下的.htaccess文件(可以减小服务器开销)。
- All: 在.htaccess文件中可以使用所有的指令。
- .htaccess是默认的AccessFileNam (文件名是可以改变的,其文件名由AccessFileName指令决定):内容如下
authname "password required" #要求输入密码的对话框上的显示,可以任意 authtype basic authuserfile /var/www/html/wiki/.htpasswd #这个指向存储密码的文件(其实最好不要在同一目录下) require valid-user
- .httpasswd 可以用htpasswd -b -c filepath username password 生成
允许Userdir下的public_html模式
<IfModule mod_userdir.c> UserDir enabled ;这个很重要 UserDir public_html </IfModule>
在fc21中这个配置在 /etc/httpd/conf.d/userdir.conf 文件当中
SElinux的配置
- 设置某目录http可访问
chcon -R -t httpd_sys_content_t your_directory
- 在SElinux enable的时候不能读~/public_html 目录下的内容
setsebool -P httpd_read_user_content 1 setsebool -P httpd_enable_homedirs true (不知道哪个是对的) chcon -R -t httpd_sys_content_t /home/*/public_html (对已经存在的目录需要这么做)