web综合

一,基于域名访问www.openlab.com
在文件当中写入IP与域名的映射关系
在windows中写入

 也可以在客户端的/etc/hosts下写入映射关系

web综合_第1张图片

 

创建目录
[root@server ~]# mkdir -pv /www/openlab
 
将所需要的内容写入对应目录当中
[root@server ~]# echo welcome to openlab ! > /www/openlab/index.html
关闭防火墙和selinux
[root@server ~]# systemctl stop firewalld
[root@server ~]# setenforce 0
测试

web综合_第2张图片
二,让song和tian用户可以访问信息网站
首先创建三个目录,并在对应的index.html写入内容
[root@server ~]# mkdir /www/openlab/student
[root@server ~]# mkdir /www/openlab/data
[root@server ~]# mkdir /www/openlab/money
[root@server ~]# echo student > /www/openlab/student/index.html
[root@server ~]# echo data > /www/openlab/data/index.html
[root@server ~]# echo money > /www/openlab/money/index.html
[root@server ~]# cat /www/openlab/student/index.html 
student
 
创建两个用户tian和song
[root@server ~]# htpasswd -c /etc/httpd/user song
New password: 
Re-type new password: 
Adding password for user song
[root@server ~]# htpasswd  /etc/httpd/user tian
New password: 
Re-type new password: 
Adding password for user tian
最后修改主配置文件
[root@server ~]# vim /etc/httpd/conf.d/userdir.conf 

web综合_第3张图片 

 


测试
web综合_第4张图片

 

 三,缴费网站基于https访问
首先安装mod_ssl插件
[root@server ~]# yum install mod_ssl
在/etc/pki/tls/private 目录下生成私钥文件
[root@server ~]# cd /etc/pki/tls/private/
[root@server private]# ll
总用量 0
[root@server private]# openssl genrsa -aes128 2048 > money.key
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
在/etc/pki/tls/certs目录下新建证书
[root@server private]# cd /etc/pki/tls/certs/
[root@server certs]# openssl req -utf8 -new -key /etc/pki/tls/private/money.key -x509 -days 365 -out money.crt
Enter pass phrase for /etc/pki/tls/private/money.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) []:shanxi
Locality Name (eg, city) [Default City]:xi'an
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:RHCE
Common Name (eg, your name or your server's hostname) []:localhost
Email Address []:[email protected]

输入证书信息时,必须一次性写对,不能退格删除

主配置文件的编辑
/etc/httpd/conf.d/ssl.conf在结尾添加以下内容


        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/money.crt
        SSLCertificateKeyFile /etc/pki/tls/private/money.key
        ServerName www.openlab.com
        DocumentRoot /www/openlab/money


        AllowOverride none
        Require all granted

 
最后重启http服务即可
[root@server conf.d]# systemctl restart httpd
 测试

web综合_第5张图片
点击高级,选择进入

 web综合_第6张图片

你可能感兴趣的:(linux,服务器,运维)