1、安装
yum -y install httpd
2、防火墙开放端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
3、目录文件信息
服务目录 /etc/httpd
主配置文件 /etc/httpd/conf/httpd.conf
网站数据目录 /var/www/html
访问日志 /var/log/httpd/access_log
错误日志 /var/log/httpd/error_log
4、常用配置属性
ServerRoot 服务目录
ServerAdmin 管理员邮箱
User 运行服务的用户
Group 运行服务的用户组
ServerName 网站服务器的域名
DocumentRoot 网站数据目录
Listen 监听的IP地址与端口号
DirectoryIndex 默认的索引页页面
ErrorLog 错误日志文件
CustomLog 访问日志文件
Timeout 网页超时时间,默认为300秒.
Include 需要加载的其他文件
5、配置虚拟主机,可以基于主机、端口和IP
httpd.conf在/etc/httpd/conf下,默认自动引用 /etc/httpd/conf.d/下的所有.conf文件所以我们把 vhost.conf建立在 /etc/httpd/conf.d/目录下
cd /etc/httpd/conf.d/
vi vhost.conf ,内容如下
<VirtualHost *:80>
ServerAdmin service@xxx.cn
directoryIndex index.html index.php index.htm
ServerName x.xxx.net
DocumentRoot /www/web
<Directory "/www/web">
Options -Indexes
AllowOverride All
Require all granted
</Directory>
</VirtualHost>