apache2.4服务器配置

一、apache2.4配置
安装apache2.4,参考 http://jingyan.baidu.com/article/7e4409533d7f0f2fc0e2ef91.html,这里说明非常详细,一步步进行安装就可以了。
1、配置虚拟目录
找到conf/httpd.conf
apache以模块化配置一目乐然,在<IfModule alias_module>添加以下配置:
<IfModule alias_module>
Alias /static "E:/apache/static"
<Directory "E:/apache/static">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
#拒绝显示的图片
<FilesMatch \.(?i:gif|jpe?g|png)$>
Require all denied
</FilesMatch>
</Directory>
Alias /index "E:/apache/index"
<Directory "E:/apache/index">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>


Alias /download "E:/apache/download"
<Directory "E:/apache/download">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
#强制点击下载
ForceType application/octet-stream
</Directory>
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server's namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http://www.example.com/bar

#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
#
# If you include a trailing / on /webpath then the server will
# require it to be present in the URL. You will also likely
# need to provide a <Directory> section to allow access to
# the filesystem path.

#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the target directory are treated as applications and
# run by the server when requested rather than as documents sent to the
# client. The same rules about trailing "/" apply to ScriptAlias
# directives as to Alias.
#
ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"

</IfModule>
我配置了三个文件目录 ,他们分别在E:/apache/static、E:/apache/index、E:/apache/download下,通过/static、/index、/download分别来访问到
例如:在浏览器输入localhost:8088/static,就可以列出本地E:/apache/static下的所有子文件夹和文件。
上面的强制点击下载,也可以全局配置:
#匹配URL 以/download开头下的所有文件,conten-type强制二进制,点击下载
<LocationMatch ".*(/download)+?">
ForceType application/octet-stream
</LocationMatch>
2、虚拟机的配置
打开注释
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
找到httpd-vhosts.conf,然后配置:
<VirtualHost *:8088>
ServerName wj.com
ServerAlias wj.com *.wj.com
DocumentRoot "E:/apache/static"
</VirtualHost>

<VirtualHost *:8088>
ServerName lwj.com
ServerAlias lwj.com *.lwj.com
DocumentRoot "E:/apache/index"
</VirtualHost>

<VirtualHost *:8088>
ServerName rx.download.net
ServerAlias rx.download.net *.rx.download.net
DocumentRoot "E:/apache/download"
</VirtualHost>
配置完毕虚拟机以后,就不需要以前的通道了,所以注释掉所有的Alias ,
#Alias /static "E:/apache/static"
#Alias /index "E:/apache/index"
#Alias /download "E:/apache/download" 这三个就不再需要配置了,
然后输入 lwj.com:8088、rx.download.net:8088就可以访问不同路径

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值