Linux:RHCE之web服务练习

web服务练习

要求:

实现

下载软件

bash 复制代码
[root@server ~]# yum install httpd -y
[root@server ~]# yum install httpd mod_ssl -y

新建网页文件

bash 复制代码
[root@server ~]# mkdir -p /www/openlab
[root@server ~]# mkdir -p /www/openlab/data
[root@server ~]# mkdir -p /www/openlab/student
[root@server ~]# mkdir -p /www/openlab/money

向网页文件中插入内容

bash 复制代码
[root@server ~]# echo "welcome to openlab.com" > /www/openlab/index.html
[root@server ~]# echo "welcome to data" > /www/openlab/data/index.html
[root@server ~]# echo "welcome to student" > /www/openlab/student/index.html
[root@server ~]# echo "welcome to money" > /www/openlab/money/index.html

新建运行登录账户

bash 复制代码
[root@server ~]# useradd song
[root@server ~]# passwd song

[root@server ~]# useradd tian
[root@server ~]# passwd tian

设置网页账户登录密码

bash 复制代码
[root@server ~]# htpasswd -c /etc/httpd/passwd song
New password: 
Re-type new password: 
Adding password for user song
[root@server ~]# htpasswd -c /etc/httpd/passwd tian
New password: 
Re-type new password: 
Adding password for user tian

配置加密https访问

bash 复制代码
# 设置私钥文件
[root@server ~]# openssl genrsa -aes128 2048 > /etc/pki/tls/private/money.key
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:

# 设置数字证书
[root@server cert]# openssl req -utf8 -new -key /etc/pki/tls/private/money.key -x509 -days 365 -out /etc/pki/tls/cert/money.crt

修改主配置文件

bash 复制代码
# 主网站的虚拟主机搭建
<virtualhost 192.168.216.136> 
        documentroot    /www/openlab
        servername      'www.openlab.com'
        <directory /www/openlab>
                allowoverride   none
                require all     granted
        </directory>
</virtualhost>

# data网站的虚拟主机搭建
<virtualhost 192.168.216.136>
        documentroot    /www/openlab/data
        alias   /data   /www/openlab/data
        servername      'www.openlab.com'
        <directory /www/openlab/data>
                allowoverride   none
                require all     granted
        </directory>
</virtualhost>

# student网站的指定用户密码搭建
<directory /www/openlab/student>
        authuserfile    /etc/httpd/passwd
        authname        'student'
        authtype        basic
        require         user    song tian
</directory>

# money网站的https加密搭建
<virtualhost 192.168.216.136:443>
        sslengine on
        SSLCertificateFile      /etc/pki/tls/cert/money.crt
        SSLCertificateKeyFile   /etc/pki/tls/private/money.key
        documentroot    /www/openlab
        alias   /money  /www/openlab/money
        servername      'www.openlab.com'
        <directory /www/openlab/money>
                allowoverride   none
                require all     granted
        </directory>
</virtualhost>

注意:在修改配置文件后一定要重启服务

相关推荐
DC_BLOG28 分钟前
IPv6(四)
运维·服务器·网络·ip
everyStudy33 分钟前
前端五种排序
前端·算法·排序算法
沈艺强34 分钟前
伊犁linux 创建yum 源过程
linux·运维·服务器
拾光师37 分钟前
linux命令行快捷键
linux·运维·服务器
甜兒.2 小时前
鸿蒙小技巧
前端·华为·typescript·harmonyos
Dola_Pan3 小时前
Linux文件IO(二)-文件操作使用详解
java·linux·服务器
wang_book3 小时前
Gitlab学习(007 gitlab项目操作)
java·运维·git·学习·spring·gitlab
prcyang3 小时前
Docker Compose
运维·docker·容器
脚踏实地的大梦想家4 小时前
【Docker】安装全流程与配置完整镜像源(可安装 nginx)
运维·docker·容器
城南云小白4 小时前
Linux网络服务只iptables防火墙工具
linux·服务器·网络