linux下apache配置文件在哪里


本文摘自PHP中文网,作者藏色散人,侵删。

Linux下Apache的配置文件是 /etc/apache2/apache2.conf,Apache在启动时会自动读取这个文件的配置信息。而其他的一些配置文件,如 httpd.conf等,则是通过Include指令包含进来。

在apache2.conf里有sites-enabled目录,而在 /etc/apache2下还有一个sites-available目录,其实,这里面才是真正的配置文件,而sites- enabled目录存放的只是一些指向这里的文件的符号链接,你可以用ls /etc/apache2/sites-enabled/来证实一下。

所以,如果apache上配置了多个虚拟主机,每个虚拟主机的配置文件都放在 sites-available下,那么对于虚拟主机的停用、启用就非常方便了:当在sites-enabled下建立一个指向某个虚拟主机配置文件的链 接时,就启用了它;如果要关闭某个虚拟主机的话,只需删除相应的链接即可,根本不用去改配置文件。

1

sudo cp /etc/apache2/sites-avaliable/000-default.conf , 命名为 test.conf

2.修改配置文件:test.conf

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

<VirtualHost *:80>

# The ServerName directive sets the request scheme, hostname and port that

# the server uses to identify itself. This is used when creating

# redirection URLs. In the context of virtual hosts, the ServerName

# specifies what hostname must appear in the request's Host: header to

# match this virtual host. For the default virtual host (this file) this

# value is not decisive as it is used as a last resort host regardless.

# However, you must set it for any further virtual host explicitly.

ServerName www.test.com

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html/test/

ErrorLog /var/www/html/test/error.log

CustomLog /var/www/html/test/access.log combined

<Directory "/var/www/html/test">

    Options FollowSymLinks

    DirectoryIndex index.php index.html index.htm

    AllowOverride All #注意这个地方的配置,会影响本地目录下的.htaccess的启用

    Order deny,allow

    Allow from All

</Directory>

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,

# error, crit, alert, emerg.

# It is also possible to configure the loglevel for particular

# modules, e.g.

#LogLevel info ssl:warn

# For most configuration files from conf-available/, which are

# enabled or disabled at a global level, it is possible to

# include a line for only one particular virtual host. For example the

# following line enables the CGI configuration for this host only

# after it has been globally disabled with "a2disconf".

#Include conf-available/serve-cgi-bin.conf

</VirtualHost>

建立链接文件:

1

sudo ln -s /etc/apache2/sites-available/test.conf /etc/apache2/sites-enabled/test.conf

或者: sudo a2ensite test.conf

阅读剩余部分

相关阅读 >>

linux系统操作讲解之基础命令分类

linux 文件权限详解

linux什么是管道?

怎么为一台实例分配一个公网 ip 地址

linux系统如何切换到root用户

怎么打开linux文件

linux打开文件命令有哪些

linux如何解压文件

linux下如何删除乱码文件的方法

如何在linux下建站目录分配权限

更多相关阅读请进入《Apache》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...