1.安装
yum install httpd -y
systemctl start httpd
systemctl stop firewalld
systemctl enable httpd
systemctl disable firewalld
apache基本信息
1.apache的默认发布文件
index.html
2.apache的配置文件
/etc/httpd/conf/httpd.conf
/etc/httpd/conf.d/*.conf
3.apache的默认发布目录
/var/www/html
4.apache的默认端口 80
apache基本配置
1.修改默认发布文件
1> vim /etc/httpd/conf/httpd.conf
164 DirectoryIndex westos.html (/var/www/html/westos.html)
2> systemctl restart httpd
2.修改默认发布目录
当selinux是disable状态
vim /etc/httpd/conf/httpd.conf
120 DocumentRoot "/nono/html"
<Directory "/nono/html">
Require all granted
</Directory>
systemctl restart httpd
vim /etc/httpd/conf/httpd.conf
120 DocumentRoot "/westos/html"
<Directory "/westos/html">
Require all granted ##允许所有人访问
</Directory>
当selinux是enforcing状态
vim /etc/httpd/conf/httpd.conf
systemctl restart httpd
semanage fcontext -a -t httpd_sys_content_t ‘/westos(/.*)?’ #修改安全上下文
restorecon -RvvF /westos
apache虚拟主机建立
mkdir /var/www/nono/news.nono.com -p
mkdir /var/www/nono/mail.nono.com -p
echo “news.westos.com” /var/www/nono/news.nono.com/index.html
echo “game.westos.com” /var/www/nono/mail.nono.com/index.htm
vim /etc/httpd/conf.d/default.conf ##未指定域名的访问都访问default
vim /etc/httpd/conf.d/news.conf ##指定域名news.nono.com的访问到指定默认发布目录中
vim /etc/httpd/conf.d/game.conf ##指定域名mail.nono.com的访问到指定默认发布目录中