apache 服务器配置

Apache 的conf 的文件夹中httpd.conf  就是Apache 的配置文件,根目录是htdocs文件夹

1.Apache 默认 监听端口号

   Listen 命令可以修改默认 监听端口号:

httpd.conf 中

# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80


在这里我们就可以改端口号了,需要注意的是,Apache服务器需要重启,才能生效。


2.修改网站根目录

需要修改DocumentRoot DocumentRoot 下的子命令<Directory >

httpd.conf 中

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "E:/woderuanjian/Apache Software Foundation/Apache2.4/htdocs"
<Directory "E:/woderuanjian/Apache Software Foundation/Apache2.4/htdocs">

    #
    #
    Options Indexes FollowSymLinks

    #
    #
    AllowOverride None


    #
    Require all granted
</Directory>

修改时,我们把DocumentRoot,和<Directory > 后的地址文件夹 都修改成同一个“F:/web”,这样Apache 根目录就就是F:/web了,重启Apache

在浏览器中输入127.0.0.1,就会显示F:/web下的文件


3.更改网站默认加载文件

httpd.conf 中

DirectoryIndex

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

红色这句话 说明,我们在浏览器中输入127.0.0.1是,会自动加载根目录下的 index.html 文件,如果不存在 index.html 文件的话, 就会显示 跟目录下的所有文件的名字,大家可以自行试一下,如果我们需要增加默认加载文件,就直接在 DirectoryIndex index.html 这里进行输入空格后添加到后面即可。如下:

    DirectoryIndex index.html index.php welcome.jsp

并按照先后顺序依次查找。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值