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>

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

相关推荐
RubyZhang1 分钟前
小程序Canvas动态海报生成方案及性能优化报告
前端
戈壁老孙7 分钟前
使用Nginx实现动态后端服务切换:一套配置管理多环境
运维·nginx
gtr20209 分钟前
Ubuntu24.04 基于 EtherCAT 的 SVD60N 主站
linux·ethercat
weixin_4624462314 分钟前
ubuntu真机安装tljh jupyterhub支持跨域iframe
linux·运维·ubuntu
小码吃趴菜14 分钟前
select/poll/epoll 核心区别
linux
zhelingwang15 分钟前
设计模式笔记
前端
Ghost Face...16 分钟前
深入解析网卡驱动开发与移植
linux·驱动开发
Focus_18 分钟前
如何借助AI在UE5中将图片批量生成3D模型
前端·aigc·游戏开发
a413244728 分钟前
在CentOS系统上挂载硬盘到ESXi虚拟机
linux·运维·centos
MMME~29 分钟前
Linux下的软件管理
linux·运维·服务器