一、作业要求
二、作业内容
1、需求1
[root@localhost ~]# rpm -ql httpd-core | grep host
/usr/share/doc/httpd-core/httpd-vhosts.conf
[root@localhost ~]# rpm -ql httpd-core | grep etc
[root@localhost ~]# cd /etc/httpd/conf.d
[root@localhost conf.d]# cp /usr/share/doc/httpd-core/httpd-vhosts.conf ./zuoye.conf
将该文件复制到当前目录下创建zuoye.conf
[root@localhost conf.d]# vim zuoye.conf
<VirtualHost 192.168.226.60:80>
DocumentRoot /www/zuoye/
ServerName www.openlab.com
ErrorLog "/var/log/httpd/openlab-error_log"
CustomLog "/var/log/httpd/openlab-access_log" common
</VirtualHost>
<directory /www/zuoye>
allowoverride none
require all granted
</directory>
[root@localhost conf.d]# mkdir /www/zuoye -p
创建目录
[root@localhost conf.d]# echo "welcome to openlab" > /www/zuoye/index.html
创建网页文件
[root@localhost conf.d]# systemctl status firewalld
查看防火墙是否关闭
[root@localhost conf.d]# setenforce 0
[root@localhost conf.d]# getenforce
Permissive
[root@localhost conf.d]# systemctl restart httpd
重启服务
测试:
[root@localhost conf.d]# curl 192.168.226.60
welcome to openlab
[root@localhost conf.d]# vim /etc/hosts
192.168.226.60 www.openlab.com
[root@localhost conf.d]# ping www.openlab.com
PING www.openlab.com (192.168.226.60) 56(84) bytes of data.
64 bytes from www.openlab.com (192.168.226.60): icmp_seq=1 ttl=64 time=0.032 ms
[root@localhost conf.d]# curl www.openlab.com
welcome to openlab
2、需求2
给公司创建三个子页面
[root@localhost conf.d]# cd /www/zuoye
[root@localhost zuoye]# mkdir student data money
在/www/zuoye下创建这三个目录
[root@localhost zuoye]# echo money > ./money/index.html
[root@localhost zuoye]# echo student > ./student/index.html
[root@localhost zuoye]# echo data > ./data/index.html
[root@localhost zuoye]# curl 192.168.226.60/student
[root@localhost zuoye]# curl 192.168.226.60/student -L
student
测试
[root@localhost zuoye]# curl http://www.openlab.com/data/
data
[root@localhost zuoye]# curl http://www.openlab.com/student/
student
[root@localhost zuoye]# curl http://www.openlab.com/money/
money
3、要求
创建用户 指定用户名及密码
[root@localhost ~]# htpasswd -c /etc/httpd/userfile song
New password:
Re-type new password:
Adding password for user song
[root@server ~]# htpasswd /etc/httpd/userfile tian
New password:
Re-type new password:
Adding password for user tian
创建网页文件根目录
[root@server ~]# mkdir /www/openlab/student
重启httpd服务
[root@server ~]# systemctl restart httpd