综合练习:请给openlab搭建web网站

一.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!

  1.

[root@localhost ~]# systemctl stop firewalld     关闭防火墙
[root@localhost ~]# setenforce 0    关闭selinux
[root@localhost ~]# vim /etc/httpd/conf.d/qiqi.conf  更改配置
<Directory /openlab>
 AllowOverride none
 Require all granted
</Directory>

<Directory /openlab/student>
AuthType basic
AuthName "please login"
AuthUserfile /etc/httpd/users
Require user song tian
</Directory>

<VirtualHost 192.168.126.131:80>
 DocumentRoot /openlab
ServerName www.openlab.com
</VirtualHost>
~                

综合练习:请给openlab搭建web网站

 2.根据子配置文件添加用户

[root@localhost ~]# htpasswd -c /etc/httpd/users song  
New password: 
Re-type new password: 
Adding password for user song
[root@localhost ~]# htpasswd /etc/httpd/users tian
New password: 
Re-type new password: 
Adding password for user tian
 
 song和tian可以访问

 3.创建目录

[root@localhost ~]# mkdir /openlab/{student,data,money} -pvmkdir: created directory ‘/openlab‘   根据子配置文件创建目录
mkdir: created directory ‘/openlab/student‘
mkdir: created directory ‘/openlab/data‘
mkdir: created directory ‘/openlab/money‘
[root@localhost ~]# vim /etc/hosts     编辑配置文件 (基于域名访问)

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.126.131    www.openlab.com  手动添加域名

 4.定义网站资源信息

[root@localhost ~]# echo welcome to openlab > /openlab/index.html
[root@localhost ~]# echo student > /openlab/student/index.html
[root@localhost ~]# echo data > /openlab/data/index.html
[root@localhost ~]# echo money > /openlab/money/index.html

[root@localhost conf]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; e
  Drop-In: /usr/lib/systemd/system/httpd.service.d
           └─php-fpm.conf
   Active: active (running) since Fri 2021-08-20 21:08:06 C   
     Docs: man:httpd.service(8)
 Main PID: 5251 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 11159)
   Memory: 17.4M
   CGroup: /system.slice/httpd.service
           ├─5251 /usr/sbin/httpd -DFOREGROUND
           ├─5252 /usr/sbin/httpd -DFOREGROUND
           ├─5253 /usr/sbin/httpd -DFOREGROUND
           ├─5254 /usr/sbin/httpd -DFOREGROUND
           └─5255 /usr/sbin/httpd -DFOREGROUND

Aug 20 21:08:06 localhost.localdomain systemd[1]: Starting 
Aug 20 21:08:06 localhost.localdomain httpd[5251]: AH00558:
Aug 20 21:08:06 localhost.localdomain systemd[1]: Started T
Aug 20 21:08:06 localhost.localdomain httpd[5251]: Server c
lines 1-21/21 (END) 

重启服务器失败时,#vi httpd.conf 查看报错信息

 5. 测试

综合练习:请给openlab搭建web网站

 

 

 综合练习:请给openlab搭建web网站

综合练习:请给openlab搭建web网站

上一篇:使用Go实现并发切片上传和下载文件


下一篇:js indexOf() 检索字符串:检查索引:获取关键字的下标