- mount /dev/sr0 /mnt/ //先挂载
- yum install httpd -y //下载htppd
- systemctl stop firewalld //关闭防火墙
- setenforce 0
-
这一步比较关键,之前改了接口什么的的建议改回来不然会一直404找不到服务
- [root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf
- [root@localhost ~]# cat /etc/httpd/conf.d/vhost.conf
- <Directory /www/>
- AllowOverride none
- Require all granted
- </Directory>
- <VirtualHost 192.168.171.129:80>
- Servername www.openlab.com
- DocumentRoot /var/www/openlab
- </VirtualHost>
- [root@localhost ~]# mkdir /var/www/openlab
- [root@localhost ~]# echo 1111 > /var/www/openlab/index.html
- [root@localhost conf.d]# vim /etc/hosts
- [root@localhost conf.d]# cat /etc/hosts
- 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
- ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
- 192.168.171.129 www.openlab.com
- [root@localhost ~]# systemctl restart httpd
- [root@localhost ~]# curl www.openlab.com
- 1111 //这里是结果
- [root@localhost ~]#
- [root@localhost ~]# mkdir /var/www/openlab/student
- [root@localhost ~]# mkdir /var/www/openlab/data
- [root@localhost ~]# mkdir /var/www/openlab/money
- [root@localhost ~]# echo 1 > /var/www/openlab/student/index.html
- [root@localhost ~]# echo 2 >/var/www/openlab/data/index.html
- [root@localhost ~]# echo 3 >/var/www/openlab/money/index.html
创建song和tian用户密码都设置成redhat
- [root@localhost ~]# htpasswd -c /etc/httpd/yonghu song
- New password:
- Re-type new password:
- Adding password for user song
- [root@localhost ~]# htpasswd -c /etc/httpd/yonghu tian
- New password:
- Re-type new password:
- Adding password for user tian
- [root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf
- [root@localhost ~]# cat /etc/httpd/conf.d/vhost.conf
- <VirtualHost 192.168.171.129:80>
- Servername www.openlab.com
- DocumentRoot /var/www/openlab
- </VirtualHost>
- <Directory /var/www/openlab>
- AllowOverride none
- Require all granted
- </Directory>
- <directory /var/www/openlab/student>
- allowoverride none
- authtype basic
- authname "please login"
- authuserfile /etc/httpd/yonghu
- require user song tian
- </directory>
- [root@localhost ~]# curl www.openlab.com/student/ -u tian
- Enter host password for user 'tian':
- 1 //这里的运行结果
- [root@localhost ~]#
- [root@localhost ~]# yum install mod_ssl //这里需要下载一个mod_ssl
- [root@server ~]# cd /etc/pki/tls/private/
- [root@server private]# openssl genrsa -aes128 2048 > jiami.key
- [root@localhost certs]# cd /etc/pki/tls/certs/
- [root@localhost certs]# openssl req -utf8 -new -key /etc/pki/tls/private/jiami.key -x509 -days 365 -out jiami.crt