Environment: centos6.5
Configuration file Interpretation
#根目录: Used to store Apache configuration files and related log information
ServerRoot "/usr/local/apache"
#设置服务器监听的端口
Listen 80
Listen 8080
#注意可以设置多个监听端口, the port number of the ServerName must be chosen to be declared here.
#设置管理员邮件地址
ServerAdmin [email protected]
#设置主机名称
ServerName www.example.com:80
#如果没有域名, you can use an IP address
#ServerName 1.2.3.123:80
#注意这里的端口号必须从上面的Listen那一项中声明的端口号中选取, or it will fail.
#也可以省略端口, you can access it whenever you use any of the ports declared in Listen
#ServerName www.test.com:8080
#设置错误日志
Errorlog "/usr/log"
#设置文档目录
DocumentRoot "/home/wwwroot/"
#文档目录是指包含web网站源代码的那个目录
#设置首页
DirectoryIndex index.html index.php
#这个首页是指客户端访问网站的时候首先看到的页面文件名, this file should be in the DocumentRoot directory.
#可以设置多个文件名, you will try again in turn, and stop trying if you try to succeed
#设置网站的编码格式 (GB2312 or UTF-8)
Adddefaultcharset UTF-8
Note: Directories use double quotes to enclose the path.
Case: A Web server needs to be built within the department with the following requirements:
- The IP address and port used are 192.168.1.80:80
- Home using index.html file
- Admin e-mail address [email protected]
- The website is encoded in GB2312
- All site resources are placed in the "/var/www/html" directory
- Set Apache's root directory to "/etc/httpd" directory
Configuring the Apache Server