Apache初学

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的访问到指定默认发布目录中
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值