搭建简单网站

首先关闭防火墙和selinux,创建网页目录并写入本地

[root@server ~]# setenforce 0
setenforce: SELinux is disabled
[root@server ~]# systemctl  stop firewalld
[root@server ~]# yum install  httpd -y
[root@server ~]# 
[root@server ~]# mkdir -p /www/openlab
[root@server ~]# echo 'welcome' > /www/openlab/index.html
[root@server ~]# vim /etc/hosts
[root@server ~]# 
192.168.239.128 www.openlab.com

编辑http的主配置文件,并写入内容,重启。

[root@server ~]# vim /etc/httpd/conf/httpd.conf 


<VirtualHost 192.168.239.128>
        DocumentRoot /www/openlab
        ServerName "www.openlab.com"
        <Directory /www/openlab>
                AllowOverride None
                require all granted
        </Directory>
</VirtualHost>
[root@server ~]# systemctl restart httpd

创建三个子网站:

www.openlab.com/student 网站访问学生信息

www.openlab.com/data网站访问教学资料

www.openlab.com/money 网站访问缴费网站

[root@server conf]# mkdir /www/openlab/data
[root@server conf]# echo 'data' > /www/openlab/data/index.html
[root@server conf]# vim /etc/httpd/conf/httpd.conf 
<VirtualHost 192.168.239.128>
        DocumentRoot /www/openlab
        alias /data /www/openlab/data
        ServerName "www.openlab.com"
</VirtualHost>
<Directory /www/openlab>
        AllowOverride none
        require all granted
</Directory>
<Directory /www/openlab/data>
        AllowOverride none
        require all granted
</Directory>
 
[root@server www]# systemctl restart httpd

 添加用户并增加用户密码访问控制

[root@server ~]# mkdir  /www/openlab/student/
[root@server ~]# echo 'student' > /www/openlab/student/index.html
[root@server ~]# chmod 755 -R /www/openlab/student
[root@server ~]# useradd biexing
[root@server ~]# passwd biexing
更改用户 biexing 的密码 。
新的密码: 
无效的密码: 密码少于 8 个字符
重新输入新的密码: 
passwd:所有的身份验证令牌已经成功更新。
[root@server ~]# htpasswd -c /etc/httpd/passwd biexing
New password: 
Re-type new password: 
Adding password for user biexing
[root@server ~]# vim /etc/httpd/conf/httpd.conf
[root@server ~]# systemctl restart httpd
[root@server ~]# 

<Directory /www/openlab/student>
        Authtype Basic
        AuthName "student"
        AuthUserFile /etc/httpd/passwd
        Require user song tian
</Directory>

 

[root@server ~]# mkdir /www/openlab/money
[root@server ~]# echo 'money' > /www/openlab/money/index.html
[root@server ~]# chmod  755 -R /www/openlab/money
[root@server ~]# yum install mod_ssl -y
[root@server ~]# openssl genrsa  -aes128 2048 > /etc/pki/tls/private/openlab.key
Enter PEM pass phrase:     #123456
Verifying - Enter PEM pass phrase:
[root@server ~]# openssl req -utf8 -new -key /etc/pki/tls/private/openlab.key  -x509 -days 365 -out /etc/pki/tls/certs/openlab.crt
Enter pass phrase for /etc/pki/tls/private/openlab.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 []:2914776784@qq.com
[root@server ~]# 
[root@server ~]# vim  /etc/httpd/conf/httpd.conf 
[root@server ~]# systemctl restart httpd
🔐 Enter TLS private key passphrase for 192.168.239.128:443 (RSA) : #123456                 
[root@server ~]# 


<<'<VirtualHost 192.168.239.128:443>
        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/openlab.crt
        SSLCertificatekeyFile /etc/pki/tls/private/openlab.key
        ServerName 192.168.239.128
        DocumentRoot /www/openlab
        alias /money /www/openlab/money
</VirtualHost>
<Directory /www/openlab/money>
        AllowOverride none
        require all granted
</Directory>'

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

电力小子sp

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值