apache2的目录及配置介绍
来源:互联网 发布:java中的包是什么意思 编辑:程序博客网 时间:2024/05/29 15:33
在Ubuntu中安装apache
安装指令:sudo apt-get installapache2
安装结束后:
产生的启动和停止文件是:/etc/init.d/apache2
启动:sudo apache2ctl -kstart
停止:sudo apache2ctl -kstop
重新启动:sudo apache2ctl -krestart
配置文件保存在:/etc/apache2
httpd.conf
Ubuntu发行版本的主配置文件是:
apache2.conf
在apache2.conf引用到了以下文件:
# 包含动态模块的配置:
Include/etc/apache2/mods-enabled/*.load
Include/etc/apache2/mods-enabled/*.conf
# 包含用户自己的配置:
Include/etc/apache2/httpd.conf
# 包含端口监听的配置:
Include/etc/apache2/ports.conf
# 包含一般性的配置语句片断:
Include/etc/apache2/conf.d/
# 包含虚拟主机的配置指令:
Include/etc/apache2/sites-enabled/
修改httpd.conf
增加以下内容:
ServerName127.0.0.1:80
ubuntu apache2配置
1.apache2.conf 是主配置文件,httpd.conf用户配置文件
2.虚拟目录在 httpd.conf 中
DocumentRoot "路径"
ServerName 名称
allow from all Options +Indexes
3.根设置(默认主目录)在
4.重启命令
sudo /etc/init.d/apache2restart或者
cd /etc/init.d
sudo apache2 -k restart
stop 停止;start 启动
5.日志文件在 /var/log/apache2/
ServerName
DocumentRoot /home/vsftpd/kimoqi
ServerName
DocumentRoot /home/vsftpd/wangguan/webapps
ServerName
DocumentRoot /home/vsftpd/wangguan/chem
vi/etc/httpd/conf/httpd.conf
在Windows下,Apache的配置文件通常只有一个,就是httpd.conf。但我在UbuntuLinux上用apt-getinstallapache2命令安装了Apache2后,竟然发现它的httpd.conf(位于/etc/apache2目录)是空的!进而发现Ubuntu的Apache软件包的配置文件并不像Windows的那样简单,它把各个设置项分在了不同的配置文件中,看起来复杂,但仔细想想设计得确实很合理。
严格地说,Ubuntu的Apache(或者应该说Linux下的Apache?我不清楚其他发行版的apache软件包)的配置文件是/etc/apache2/apache2.conf,Apache在启动时会自动读取这个文件的配置信息。而其他的一些配置文件,如httpd.conf等,则是通过Include指令包含进来。在apache2.conf中可以找到这些Include行:
引用
# Include moduleconfiguration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
# Include all the userconfigurations:
Include /etc/apache2/httpd.conf
# Include ports listing
Include /etc/apache2/ports.conf
……
# Include generic snippets of statements
Include /etc/apache2/conf.d/
# Include the virtual hostconfigurations:
Include /etc/apache2/sites-enabled/
结合注释,可以很清楚地看出每个配置文件的大体作用。当然,你完全可以把所有的设置放在apache2.conf或者httpd.conf或者任何一个配置文件中。Apache2的这种划分只是一种比较好的习惯。
安装完Apache后的最重要的一件事就是要知道Web文档根目录在什么地方,对于Ubuntu而言,默认的是/var/www。怎么知道的呢?apache2.conf里并没有DocumentRoot项,httpd.conf又是空的,因此肯定在其他的文件中。经过搜索,发现在/etc/apache2/sites-enabled/000-default中,里面有这样的内容:
引用
NameVirtualHost *
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
……
这是设置虚拟主机的,对我来说没什么意义。所以我就把apache2.conf里的Include/etc/apache2/sites-enabled/一行注释掉了,并且在httpd.conf里设置DocumentRoot为我的用户目录下的某个目录,这样方便开发。
再看看/etc/apache2目录下的东西。刚才在apache2.conf里发现了sites-enabled目录,而在/etc/apache2下还有一个sites-available目录,这里面是放什么的呢?其实,这里面才是真正的配置文件,而sites-enabled目录存放的只是一些指向这里的文件的符号链接,你可以用ls/etc/apache2/sites-enabled/来证实一下。所以,如果apache上配置了多个虚拟主机,每个虚拟主机的配置文件都放在sites-available下,那么对于虚拟主机的停用、启用就非常方便了:当在sites-enabled下建立一个指向某个虚拟主机配置文件的链接时,就启用了它;如果要关闭某个虚拟主机的话,只需删除相应的链接即可,根本不用去改配置文件。
mods-available、mods-enabled和上面说的sites-available、sites-enabled类似,这两个目录是存放apache功能模块的配置文件和链接的。当我用apt-getinstallphp5安装了PHP模块后,在这两个目录里就有了php5.load、php5.conf和指向这两个文件的链接。这种目录结果对于启用、停用某个Apache模块是非常方便的。
最后一个要说的是ports.conf,这里面设置了Apache使用的端口。如果需要调整默认的端口设置,建议编辑这个文件。或者你嫌它实在多余,也可以先把apache2.conf中的Include/etc/apache2/ports.conf一行去掉,在httpd.conf里设置Apache端口。
ubuntu里缺省安装的目录结构很有一点不同。在ubuntu中module和virtualhost的配置都有两个目录,一个是available,一个是enabled,available目录是存放有效的内容,但不起作用,只有用ln连到enabled过去才可以起作用。对调试使用都很方便,但是如果事先不知道,找起来也有点麻烦。
/etc/apache2/sites-available里放的是VH的配置,但不起作用,要把文件link到 sites-enabled 目录里才行。
进一步的配置和使用,就可以查阅APACHE的手册了
Apache配置文件httpd.conf说明
DocumentRoot"/var/www/html"
DirectoryIndex index.htmlindex.htm index.phpindex.html.var
Listen192.168.1.1:80
Listen192.168.1.2:8080
ServerRoot"/etc/httpd"
ErrorLoglogs/error_log
CustomLog logs/access_logcombined
ServerAdmin
ServerName
AddDefaultCharsetGB2312
Alias/down
Alias/ftp
基于域名的虚拟主机
NameVirtualHost220.123.55.99
www.iigoogle.com>
NameVirtualHost220.123.55.99:80
www.iigoogle.com:80>
javalover
- apache2的目录及配置介绍
- apache2.2的目录文件及 虚拟主机的配置
- ubuntu16.04配置apache2的目录
- 关于Apache2.4限制目录访问配置的问题
- PHP5+Apache2.4配置遇到的问题及解决办法
- 配置apache2使用能访问用户目录
- Apache2 配置禁止显示目录列表
- apache2 linux 配置端口映射相应目录
- Apache2+Tomcat4的配置
- Apache2的配置详解
- 这篇文章主要介绍了Apache2.4.x版wampserver本地php服务器如何让外网访问及启用.htaccess,需要的朋友可以参考下 Apache 从2.2升级到 Apache2.4.x 后配置
- 图文介绍apache2.2.x安装配置
- Linux 各目录及每个目录的详细介绍
- Linux 各目录及每个目录的详细介绍
- Linux 各目录及每个目录的详细介绍
- Linux各目录及每个目录的详细介绍
- Linux 各目录及每个目录的详细介绍
- Linux 各目录及每个目录的详细介绍
- 第4周项目1:求最大公约数
- 数学公式排版测试
- 安装包管理
- Linux进程命令
- Linux重定向
- apache2的目录及配置介绍
- Linux用户管理常用命令
- vi命令
- CAS单点登录(SSO)完整教程
- Linux解压命令
- web常用命令
- IO常用命令
- shadow
- passwd