您的位置:首页 > 运维架构 > Apache

apache 服务器配置

2018-04-10 19:22 211 查看
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

并按照先后顺序依次查找。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息