apache配置文件详解及虚拟主机的搭建
1、404跳转:
<IfModule dir_module>
DirectoryIndex index.php index.html /error.php
</IfModule>
#/error.php是apache的根目录
2、apache配置段:
(1)目录权限限制
Alias /dir/ "/var/www/html" #虚拟目录即访问dir的时候跳转到/var/www/html目录
<Directory /var/www/html/> #目录访问权限 ,或者<Directory /var/*/html/> *表示通配符
Options Indexes FollowSymLinks #允许目录索引,支持软连接
Order Allow,Deny #先允许后拒绝
Deny from 192.168.1.111 #拒绝访问该目录
Allow from all #允许访问该目录
AllowOverride All #开启.htaccess(默认是开启的),把目录配置权限交给用户,上面的配置内容不用写
</Directory>
(2)文件权限限制(Files可以嵌套到Directory配置段里,即限制某个目录下的某个文件不能访问)
<Files "demo.html">
Order Deny,Allow
Deny from all
</Files>
<FilesMatch \.(gif|jpe?g|png)$> #正则模式
Order Deny,Allow
Deny from all
</FilesMatch>
(3)以pri开头的网络地址
<Location '/pri'>
......
</Location>
3、.htaccess(不建议使用,比较浪费apache资源)
Options Indexs FollowSymLinks #允许目录索引,支持软连接
Order Allow,Deny #先允许后拒绝
Allow from all #允许所有访问
4、虚拟主机的配置(重点):
#
# 管理员邮箱
# 网站根目录
# Directory限制该目录的权限
# 绑定域名
# 绑定其他域名
# 错误日志
# 正常访问日志
#
<VirtualHost *:80>
ServerAdmin admin@php.com
DocumentRoot "/home/php5"
<Directory "/home/php5">
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
ServerName www.php.com
ServerAlias cs.php.com
ErrorLog "/home/php5/logs/error_log"
CustomLog "/home/php5/logs/access_log"
</VirtualHost>
# 禁止所有以logs开头的文件都禁止访问
<Location "/logs">
Order Deny,Allow
Deny from all
</Location>
apache配置文件详解及虚拟主机的搭建的更多相关文章
- (原创)LAMP搭建之二:apache配置文件详解(中英文对照版)
LAMP搭建之二:apache配置文件详解(中英文对照版) # This is the main Apache server configuration file. It contains the # ...
- ubuntu apache2配置详解(含虚拟主机配置方法)
ubuntu apache2配置详解(含虚拟主机配置方法) 在Windows下,Apache的配置文件通常只有一个,就是httpd.conf.但我在Ubuntu Linux上用apt-get inst ...
- apache配置文件详解与优化
apache配置文件详解与优化 一.总结 一句话总结:结合apache配置文件中的英文说明和配置详解一起看 1.apache模块配置用的什么标签? IfModule 例如: <IfModule ...
- Apache配置文件详解
1.1 ServerRoot 配置 [ServerRoot "" 主要用于指定Apache的安装路径,此选项参数值在安装Apache时系统会自动把Apache的路径写入.Windo ...
- apache配置文件详解(中英文对照版)
# This is the main Apache server configuration file. It contains the # configuration directives that ...
- Apache 配置文件详解
0x01 禁止目录列表访问 () 备份httpd.conf配置文件,修改内容: <Directory "/web"> Options FollowSymLinks Al ...
- linux下的apache配置文件详解
.Apache的配置由httpd.conf文件配置,因此下面的配置指令都是在httpd.conf文件中修改. 站点的配置(基本配置) (1) 基本配置: ServerRoot "/mnt/s ...
- Apache服务的主要目录和配置文件详解
Apache服务的主要目录和配置文件详解 2014-01-14 19:05:14 标签:httpd配置文件详解 apache配置文件 httpd配置文件 apache文件目录 原创作品,允许转载,转载 ...
- ubuntu nginx 安装以及配置文件详解
1.到nginx官网下载源码包.最好下载稳定版本,nginx官网http://www.nginx.org/ 2.安装nginx依赖包运行命令: sudo apt-get install libssl- ...
随机推荐
- vue 之循环添加不同class
在vue中按条件为class动态添加直接使用:class="[{ active: isActive }, errorClass]"之类的表达式就可以 但是如果我们要为一个循环列表按 ...
- BZOJ 4326 NOIP2015 运输计划(二分答案 + 树上差分思想)
题目链接 BZOJ4326 这个程序在洛谷上TLE了……惨遭卡常 在NOIP赛场上估计只能拿到95分吧= = 把边权转化成点权 首先求出每一条路径的长度 考虑二分答案,$check(now)$ 对于 ...
- sudo apt-get upgrade 不成功遇到问题
一. sudo apt-get update 和 sudo apt-get upgrade 出错:(Ubuntu更新过程被中断后的问题) Ubuntu的更新过程是先下载完源里的文件就开始执行升级,如果 ...
- 想用idea的update classes and resources找不到了,热部署无法使用
发现为了方便调试页面,想用idea的update classes and resources找不到了,发现需要把deployment选择exploded 的那个war包,才能在service--> ...
- 使用spring声明式事务,spring使用AOP来支持声明式事务,会根据事务属性,自动在方法调用之前决定是否开启一个事务,并在方法执行之后决定事务提交或回滚事务。
使用spring声明式事务,spring使用AOP来支持声明式事务,会根据事务属性,自动在方法调用之前决定是否开启一个事务,并在方法执行之后决定事务提交或回滚事务.
- java正则过虑字符
public static void main(String[] args) { String testrString = "{\"abc\" : \"[123 ...
- XCode 4.3 Unable to load persistent store UserDictionary.sqlite 以及 ios simulator failed to install the application
I have been working on an iOS app for some time, all of a sudden I am getting the following crash ev ...
- 邁向IT專家成功之路的三十則鐵律 鐵律十六:IT人交友之道-單純
元曲知名的作家 白樸,曾在沉醉東風﹒漁夫一文創作中,寫道:「雖無刎頸交,卻有忘機友」.IT人交朋友應首重在單純而非廣泛,因為實際上越複雜的朋友圈,只會為你的工作以及生活帶來許多不必要的麻煩.至於男女朋 ...
- UNIX&Linux发展图谱
来自为知笔记(Wiz)
- sh_Spring整合Hibernate
分别介绍了Sping和Hibernate,以下是将它们整合到一块去了. 一.Hibernate内容 1.创建PO类. package cn.tgb.domain; //User实体 public ...