Apache使用说明
安装(未完成)
基础
apache和apache2,版本不同,功能特性不同apache2和httpd指在不同架构下的说法,功能一致,配置些许不同(如apache2.conf和httpd.conf)httpd is the same as apache2. It depends on the OS you use. For example in RHEL 6.2 it is called httpd and in Ubuntu it is called apache2.
版本查看
1
2apache2 -v # Debian/Ubuntu
httpd -v # CentOS/RHEL/Fedora
命令说明
权限不够加
sudo查看是否启用了模块:
apache2ctl -M | grep [模块名]- 如:
sudo apache2ctl -M | grep ssl,启用了显示ssl_module (shared)
- 如:
启用配置/模块/站点:
a2ensite/a2enmod/a2enconf- 如启用
SSL模块:a2enmod ssl,然后执行systemctl reload apache2
- 如启用
取消配置/模块/站点:
a2dissite/a2dismod/a2disconf- 如取消
SSL模块:a2dismod ssl,然后执行systemctl reload apache2
- 如取消
配置说明
以
Debian/Ubuntu下apache2为例文件架构说明
apache2.conf:Apache 的主要配置文件,包含了全局的配置指令和其他配置文件的引用ports.conf:定义 Apache 监听的端口和协议xxx-available:Apache服务器目前所有支持的信息conf-available:支持的配置,存放其他的 Apache 配置文件的目录,例如安全策略、认证和授权等mods-available:支持的模块,存放 Apache 模块配置文件的目录,每个文件对应一个模块sites-available:支持的站点,存放虚拟主机配置文件的目录,每个文件对应一个虚拟主机
xxx-enable:Apache服务器目前可用的信息- 是
xxx-available的一个软连接,通过a2ensite/a2enmod/a2enconf创建,通过a2dissite/a2dismod/a2disconf销毁,每次执行命令都需要使用systemctl reload apache2重载配置 conf-available:现在可用的配置,存放已启用的其他 Apache 配置文件的目录,通常通过在conf-available目录中创建符号链接来启用其他配置文件mods-available:现在可用的模块,存放已启用的 Apache 模块配置文件的目录,通常通过在mods-available目录中创建符号链接来启用模块sites-available:现在可用的站点,存放已启用的虚拟主机配置文件的目录,通常通过在sites-available目录中创建符号链接来启用虚拟主机
- 是
配置文件地址:
/etc/apache2/apache2.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
33
34
35
36
37It is split into several files forming the configuration hierarchy outlined
below, all located in the /etc/apache2/ directory:
# /etc/apache2/
|-- apache2.conf
| `-- ports.conf
|-- mods-enabled
| |-- *.load
| `-- *.conf
|-- conf-enabled
| `-- *.conf
`-- sites-enabled
`-- *.conf
#
* apache2.conf is the main configuration file (this file). It puts the pieces
together by including all remaining configuration files when starting up the
web server.
# * ports.conf is always included from the main configuration file. It is
supposed to determine listening ports for incoming connections which can be
customized anytime.
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
directories contain particular configuration snippets which manage modules,
global configuration fragments, or virtual host configurations,
respectively.
# They are activated by symlinking available configuration files from their
respective *-available/ counterparts. These should be managed by using our
helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
their respective man pages for detailed information.
# * The binary is called apache2. Due to the use of environment variables, in
the default configuration, apache2 needs to be started/stopped with
/etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
work with the default configuration.
参考
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 cv-programmer!








