http登录linux,51CTO博客-专业IT技术博客创作平台-技术成就梦想

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

34afa1187dff8421eeb057b74e3eae85.png

c8df9594ae6888066e9c77cf532cd3a0.png

bd398b5faa63111a99ea5a2675c998b0.png

c3abc6c1cad041f4cea9f54ef98d91ef.png

c57f5f30cea0f86f3f7aa9a4dbe16e64.png

fd1df4b4bcf743e57ffc801a37ebfd7d.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值