Chinaunix首页 | 论坛 | 博客
  • 博客访问: 93873
  • 博文数量: 23
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 253
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-01 20:41
文章分类

全部博文(23)

分类: 系统运维

2015-03-02 16:25:55

关闭selinux 或者 selinux设置允许

虚拟主机:

apache服务,服务于多个不同的站点

apache

中心主机,虚拟主机,不能同时使用,如果同时使用的话,中心主机要定义成虚拟主机

虚拟主机:基于ip的、基于端口的、基于域名的

基于域名的:解析的都是同一个ip,所以http报文中用host字段来判断

apache 2.2开启虚拟主机要启用 NameVirtualHostapache 2.4直接各自定义就行

如果有这么三个域名:

此时,a.org需要认证

ServerName

DocumentRoot  /www/a.org/

/www/a.org">

Option

AllowOverride AuthConfig

. . . . .

定义用户访问目录文件的访问属性

 

Alias ..

Errorlog

CustomLog

 

  定义url,访问image目录下资源的时候的权限和方法

 

<\Location>

ScriptAlias CGI脚本目录  CGIcommon gateway interface服务端动态

 

虚拟主机定义: 先取消中心主机,注释中心主机的DocumentRoot即可然后在配置文件中添加virtual host,或者 conf.d目录线建立virtual.conf

 

 

基于iphost的写法

ip180

ip2 80

基于域名

ip80

ServerName 不同即可

 

给网卡添加ip地址

ip addr add 192.168.1.1/24 dev eth0

显示ip地址

ip addr show

 

基于ip的:

Document "/www/c.com"

ServceName c.com

Document "/www/a.org"

ServceName a.org

基于端口的:

Document "/www/c.com"

ServerName c.com

Document "/www/a.org"

ServerName a.org

  然后再主配置文件中添加 Listen 的端口

 

基于域名的:

一种方法:

添加 NameVirtualHost  xxx.xxx.xxx.xxx:xx

ServerName        

DocumentRoot /www/c.com/

ServerName

DocumentRoot /www/a.org/

ServerName

DocumentRoot /www/b.org/

ServerName

DocumentRoot /www/d.org/

 

第二种方法:不添加NameVirtualHost

ServerName

DocumentRoot /www/a.org/

ServerName

DocumentRoot /www/d.org/

 

 

定义默认虚拟主机:

DocumentRoot /www/default

. . .

 

 

使用单独的日志文件:

CustomLog /www/a.org/httpd/access_log combined

CustomLog /www/a.org/httpd/error_log combined

 

 

SetHandler  server-status

Order Deny,Allow

Deny from all

Allow from .foo.com  

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 



阅读(734) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~