http服务搭建---ssl加密

Web服务器
浏览器:谷歌、火狐、IE、QQ浏览器.、百度浏览器、360浏览器、goole chrome、2345浏览器
服务器 :html(写网页)超文本标记语言,
Jsp(java服务端网页) php(服务器编程语言) asp(动态服务器语言)
解析和执行只能在服务器上执行
Html与Jsp php asp区别:
1、 html是一切网页语言的基础
2、 Jsp php可以动态链接数据库,但是最终都由服务器解析成html
3、 Jsp php asp 文档都以html为基础只是用程序代码动态输出html代码,同一文档输出不同的html代码,也是就是我们在浏览器看到的结果
4、 Jsp是一般浏览器都能编译的
5、 Asp和php都需要服务器的支持
6、 Jsp php asp都是动态网页,当你访问时,现在服务器上执行,然后将执行后的网页代码返回到电脑,你就能看到内容
7、 Html是静态网页的内容,不需要在服务器端执行,直接发送到你的电脑

先安装httpd
Yum install –y httpd
Systemctl restart httpd
Systemctl status httpd
关闭防火墙
Systemctl stop firewalld
Setenforce 0
[root@localhost ~]# echo welcome to rhce > /var/www/html/index.html
[root@localhost html]# cat index.html
<h1>
welcome to rhce
<h1>
加粗加大
产看生成的文件目录
[root@localhost html]# rpm -ql httpd
默认网络内容所在地 /var/www/html

AllowOverride参数就是指明Apache服务器是否去找.htacess文件作为配置文件,如果设置为none,那么服务器将忽略.htacess文件,如果设置为All,那么所有在.htaccess文件里有的指令都将被重写。对于AllowOverride,还可以对它指定如下一些能被重写的指令类型
这里写图片描述
主配置文件是/etc/httpd/conf/httpd.conf。
配置存储在的/etc/httpd/conf.d/目录
[root@localhost ~]# cat /etc/httpd/conf.d/vhost.conf
<Directory “/www”>
allowoverride none
require all granted
</Directory>
<VirtualHost 172.16.50.37:80>
DocumentRoot “/www/80”
Servername 172.16.50.37
ErrorLog “/var/log/httpd/80-error_log”
CustomLog “/var/log/httpd/80-access_log” common
</VirtualHost>

虚拟主机(Virtual Host )是指在网络服务器上分出一定的磁盘空间,用户可以租用此部分空间,以供用户放置站点及应用组件,提供必要的数据存放和传输功能, 虚拟主机,也叫“网站空间”,就是把一台运行在互联网上的物理服务器划分成多个“虚拟”服务器

一、 基于ip多主机搭建
添加地址
[root@localhost ~]# nmcli connection modify ens33 +ipv4.addresses 172.16.50.38/24
[root@localhost ~]# nmcli connection modify ens33 ipv4.method manual
[root@localhost ~]# nmcli connection modify ens33 connection.autoconnect yes
[root@localhost ~]# nmcli connection up ens33
配置文件
[root@localhost ~]# cat /etc/httpd/conf.d/vhost.conf
<Directory “/www”>
allowoverride none
require all granted
</Directory>
<VirtualHost 172.16.50.37:80>
DocumentRoot “/www/37”
Servername 172.16.50.37
ErrorLog “/var/log/httpd/37-error_log”
CustomLog “/var/log/httpd/37-access_log” common
</VirtualHost>
<VirtualHost 172.16.50.38:80>
DocumentRoot “/www/38”
Servername 172.16.50.38
ErrorLog “/var/log/httpd/38-error_log”
CustomLog “/var/log/httpd/38-access_log” common
</VirtualHost>
[root@localhost ~]# mkdir /www/{37,38} –p
[root@localhost www]# echo welcom to 37 > /www/37/index.html
[root@localhost www]# echo welcom to 38 > /www/38/index.html
[root@localhost www]# systemctl restart httpd
二、基于多端口

[root@localhost conf.d]# mkdir /www/{8080,9080}
[root@localhost conf.d]# echo welcom to 8080 > /www/8080/index.html
[root@localhost conf.d]# echo welcom to 9080 > /www/9080/index.html
[root@localhost conf.d]# vi vhost.conf
<Directory “/www”>
allowoverride none
require all granted
</Directory>
<VirtualHost 172.16.50.37:80>
DocumentRoot “/www/37”
Servername 172.16.50.37
ErrorLog “/var/log/httpd/37-error_log”
CustomLog “/var/log/httpd/37-access_log” common
</VirtualHost>
<VirtualHost 172.16.50.38:80>
DocumentRoot “/www/38”
Servername 172.16.50.38
ErrorLog “/var/log/httpd/38-error_log”
CustomLog “/var/log/httpd/38-access_log” common
</VirtualHost>
<VirtualHost 172.16.50.38:8080>
DocumentRoot “/www/8080”
Servername 172.16.50.38
ErrorLog “/var/log/httpd/8080-error_log”
CustomLog “/var/log/httpd/8080-access_log” common
</VirtualHost>
<VirtualHost 172.16.50.38:9080>
DocumentRoot “/www/9080”
Servername 172.16.50.38
ErrorLog “/var/log/httpd/9080-error_log”
CustomLog “/var/log/httpd/9080-access_log” common
</VirtualHost>
listen 8080
listen 9080
[root@localhost conf.d]# systemctl retart httpd
三、基于主机名(网址)
修改hosts文件 C:\Windows\System32\drivers\etc
172.16.50.38 www.haha.com
172.16.50.38 www.xixi.com
[root@localhost conf.d]# vi vhost.conf
<Directory “/www”>
allowoverride none
require all granted
</Directory>
<VirtualHost 172.16.50.37:80>
DocumentRoot “/www/37”
Servername 172.16.50.37
ErrorLog “/var/log/httpd/37-error_log”
CustomLog “/var/log/httpd/37-access_log” common
</VirtualHost>
<VirtualHost 172.16.50.38:80>
DocumentRoot “/www/38”
Servername 172.16.50.38
ErrorLog “/var/log/httpd/38-error_log”
CustomLog “/var/log/httpd/38-access_log” common
</VirtualHost>
<VirtualHost 172.16.50.38:80>
DocumentRoot “/www/haha”
Servername www.haha.com
ErrorLog “/var/log/httpd/haha-error_log”
CustomLog “/var/log/httpd/haha-access_log” common
</VirtualHost>
<VirtualHost 172.16.50.38:80>
DocumentRoot “/www/xixi”
Servername www.xixi.com
ErrorLog “/var/log/httpd/xixi-error_log”
CustomLog “/var/log/httpd/xix-access_log” common
</VirtualHost>
“vhost.conf” 28L, 816C
[root@localhost conf.d]# echo welcom to haha > /www/haha/index.html
[root@localhost conf.d]# echo welcom to xixi > /www/xixi/index.html
[root@localhost conf.d]# systemctl restart httpd
SSL:加密
[root@localhost conf.d]# cat vhost.conf
<Directory “/www”>
allowoverride none
require all granted
</Directory>
<VirtualHost 172.16.50.37:80>
DocumentRoot “/www/37”
Servername 172.16.50.37
ErrorLog “/var/log/httpd/37-error_log”
CustomLog “/var/log/httpd/37-access_log” common
</VirtualHost>
<VirtualHost 172.16.50.38:80>
DocumentRoot “/www/38”
Servername 172.16.50.38
ErrorLog “/var/log/httpd/38-error_log”
CustomLog “/var/log/httpd/38-access_log” common
</VirtualHost>
<VirtualHost 172.16.50.38:443>
DocumentRoot “/www/haha”
Servername www.haha.com
ErrorLog “/var/log/httpd/haha-error_log”
CustomLog “/var/log/httpd/haha-access_log” common
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/haha.crt
SSLCertificateKeyFile /etc/pki/tls/certs/haha.key
</VirtualHost>
<VirtualHost 172.16.50.38:80>
DocumentRoot “/www/xixi”
Servername www.xixi.com
ErrorLog “/var/log/httpd/xixi-error_log”
CustomLog “/var/log/httpd/xix-access_log” common
</VirtualHost>
cd /etc/pki/tls/certs/
[root@localhost certs]# make haha.crt
umask 77 ; \
/usr/bin/openssl genrsa -aes128 2048 > haha.key
Generating RSA private key, 2048 bit long modulus
……………………+++
…….+++
e is 65537 (0x10001)
Enter pass phrase:
Verifying - Enter pass phrase:
umask 77 ; \
/usr/bin/openssl req -utf8 -new -key haha.key -x509 -days 365 -out haha.crt
Enter pass phrase for haha.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
**If you enter ‘.’, the field will be left blank.
—–**
Country Name (2 letter code) [XX]:86
State or Province Name (full name) []:shaanxi
Locality Name (eg, city) [Default City]:xi’an
Organization Name (eg, company) [Default Company Ltd]:openalb
Organizational Unit Name (eg, section) []:ce
Common Name (eg, your name or your server’s hostname) []:cd
Email Address []:haha@qq.com

[root@localhost conf.d]# systemctl restart httpd
Enter SSL pass phrase for www.haha.com:443 (RSA) : **

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值