赞
踩
1.基于域名www.openlab.com可以访问网站内容为welcome to openlab
关闭selinux和防火墙;创建网页目录,并写入内容;并在linux下的hosts文件内写入域名与本机ip地址的映射
- [root@server ~]# setenforce 0
- setenforce: SELinux is disabled
- [root@server ~]# systemctl stop firewalld
- [root@server ~]# yum install httpd -y
-
- [root@server ~]# mkdir -p /www/openlab
- [root@server ~]# ehco 'welcom to openlab' > /www/openlab/index.html
-
-
- [root@server ~]# vim /etc/hosts
编辑httpd的主配置文件,并写入虚拟主机内容,重启服务
- [root@server conf]# vim /etc/httpd/conf/httpd.conf
- <VirtualHost 192.168.95.131>
- DocumentRoot /www/openlab
- ServerName "www.openlab.com"
- <Directory /www/openlab>
- AllowOverride None
- require all granted
- </Directory>
- </VirtualHost>
- [root@server conf]# systemctl restart httpd
在windows下的host文件内写入域名与ip地址的映射
测试:
2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于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.95.131>
- 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 data]# curl www.openlab.com/data/
- data
添加用户,增加密码访问控制
- [root@server ~]# mkdir /www/openlab/student/
- [root@server ~]# echo 'student' > /www/openlab/student/index.html
- [root@server data]# chmod 755 -R /www/openlab/student
-
- [root@server data]# useradd song
- [root@server data]# passwa song
- [root@server data]# useradd tian
- [root@server data]# passwd tian
-
- [root@server student]# htpasswd -c /etc/httpd/passwd song
- [root@server student]# htpasswd /etc/httpd/passwd tian
- [root@server student]# vim /etc/httpd/conf/httpd.conf
- <Directory /www/openlab/student>
- Authtype Basic
- AuthName "student"
- AuthUserFile /etc/httpd/passwd
- Require user song tian
- </Directory>
- [root@server student]# systemctl restart httpd
测试:
- [root@server student]# mkdir /www/openlab/money
- [root@server student]# echo 'money' > /www/openlab/money/index.html
- [root@server student]# chmod 755 -R /www/openlab/money
- [root@server student]# yum install mod_ssl -y
-
-
- [root@server student]# openssl genrsa -aes128 2048 > /etc/pki/tls/private/openlab.key
- Enter PEM pass phrase:
- Verifying - Enter PEM pass phrase:
- [root@server student]# 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 []:1617995042@qq.com
- [root@server student]# vim /etc/httpd/conf/httpd.conf
- <VirtualHost 192.168.95.131:443>
- SSLEngine on
- SSLCertificateFile /etc/pki/tls/certs/openlab.crt
- SSLCertificatekeyFile /etc/pki/tls/private/openlab.key
- ServerName 192.168.95.131
- DocumentRoot /www/openlab
- alias /money /www/openlab/money
- </VirtualHost>
- <Directory /www/openlab/money>
- AllowOverride none
- require all granted
- </Directory>
- [root@server student]# systemctl restart httpd
- 声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/871923推荐阅读
相关标签
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。