http和https简单使用

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了http和https简单使用相关的知识,希望对你有一定的参考价值。

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|<Directory "/www/westos">

122| require all granted

</Directory>

121|<Directory "/www/westos">

require all granted

Order Allow,Deny

Allow from All

Deny from 172.25.254.150

126|</Directory>

二、设置用户登陆网页

1)建立用户及密码

cd /etc/httpd

htpasswd -cm htpasswdfile admin 

htpasswd -m htpasswdfile westos

121|<Directory "/www/westos">

AllowOverride All

Authuserfile /etc/httpd/htpasswdfile

Authname "Please input username and password"

Authtype basic

Require valid-user

</Directory>

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

<virtualhost_default_:80>

Documentroot /var/www/html

Customlog "logs/default.log" combined

</virtualhost>

<Directory "/var/www/html">

Required all granted

</Directory>


vim music.conf

<virtualhost *:80>

Servername music.linux.com

Documentroot /var/www/virtual/music.linux.com

Customlog "logs/music.log" combined

</virtualhost>

<Directory "/var/www/virtual/music.linux.com/html">

Required all granted

</Directory>


vim news.conf

<virtualhost *:80>

Servername news.linux.com

Documentroot /var/www/virtual/news.linux.com

Customlog "logs/news.log" combined

</virtualhost>

<Directory "/var/www/virtual/news.linux.com/html">

Required all granted

</Directory>

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

genkey www.linux.com

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享


以上是关于http和https简单使用的主要内容,如果未能解决你的问题,请参考以下文章

HTTPS, SPDY和 HTTP/2性能的简单对比

https协议的简单理解

简单比较 http https http2

如何使用nodejs搭建一个简单的https服务器

使用Nancy搭建简单的Http服务的示例demo

git简单使用