Apache初学

来源:互联网 发布:老版本的知乎 ios 编辑:程序博客网 时间:2024/06/07 05:58

1.安装

yum install httpd -y systemctl start httpd systemctl stop firewalld systemctl enable httpd systemctl disable firewalld

apache基本信息

1.apache的默认发布文件index.html2.apache的配置文件/etc/httpd/conf/httpd.conf /etc/httpd/conf.d/*.conf3.apache的默认发布目录/var/www/html4.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.confsystemctl restart httpdsemanage 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的访问到指定默认发布目录中
原创粉丝点击