http服务使用
一、http的基本设置
1)安装http服务
yum install httpd -y
2)查看http的默认设置
164|index.html/*是http的默认发布文件
119|/var/www/html/*是默认的
42|Listen 80/*默认端口
3)如果不关闭防火墙需要修改selinux的标贴(ls -Zd可以查看http的标贴)
mkdir /www/westos -p
semanage fcontext -a -t httpd_sys_content_t '/www/westos(/.*)?'
restorecon -RvvF /www/
4)更换默认发布目录,限制ip访问
vim /etc/httpd/conf/httpd.conf
120|DocumentRoot "/www/westos"
121|
122|require all granted
121|
require all granted
Order Allow,Deny
Allow from All
Deny from 172.25.254.150
126|
二、设置用户登陆网页
1)建立用户及密码
cd /etc/httpd
htpasswd -cm htpasswdfile admin
htpasswd -m htpasswdfile westos
121|
AllowOverride All
Authuserfile /etc/httpd/htpasswdfile
Authname "Please input username and password"
Authtype basic
Require valid-user
2)建立多个访问页面
mkdir /var/www/virtual/news.linux.com/html -p
mkdir /var/www/virtual/music.linux.com/html -p
cd /var/www/virtual/news.linux.com/html
vim index.html
news.linux.com
cd /var/www/virtual/music.linux.com/html
vim index.html
music.linux.com
cd /etc/httpd/conf.d/
vim default.conf
Documentroot /var/www/html
Customlog "logs/default.log" combined
Required all granted
vim music.conf
Servername music.linux.com
Documentroot /var/www/virtual/music.linux.com
Customlog "logs/music.log" combined
Required all granted
vim news.conf
Servername news.linux.com
Documentroot /var/www/virtual/news.linux.com
Customlog "logs/news.log" combined
Required all granted
vim /etc/resolv.conf
172.25.254.150 music.linux.com news.linux.com www.linux.com
三、安全登陆https
yum install mod_ssl -y
yum install crypto-utils -y
cd /etc/httpd/conf.d
5|Listen 443 https