目录
[root@localhost ~]# echo "this is static" >> /var/www/html/index.html
- nmcli connection modify ens33 +ipv4.addresses 192.168.27.100/24
- nmcli connection modify ens33 +ipv4.addresses 192.168.27.200/24
- nmcli connection up ens33
- mkdir -pv /WWW/ip/100
- mkdir -pv /WWW/ip/200
- echo "this is 100" > /WWW/ip/100/index.html
- echo "this is 200" > /WWW/ip/200/index.html
- 配置httpd虚拟主机
- 虚拟主机样例文件是/usr/share/doc/httpd-2.4.6/httpd-vhosts.con
- [root@localhost ~]# find / -name "*vhosts.conf"
- /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf
- [root@localhost ~]# more /etc/httpd/conf.d/vhosts.conf
- <VirtualHost 192.168.27.100:80>
- DocumentRoot /WWW/ip/100
- ServerName 192.168.27.100
- </VirtualHost>
- <VirtualHost 192.168.27.200:80>
- DocumentRoot /WWW/ip/200
- ServerName 192.168.27.200
- </VirtualHost>
- 给目录给予访问权限
- <Directory "/WWW/ip">
- AllowOverride None
- Require all granted
- </Directory>
- listen 81
- listen 82
- <VirtualHost 192.168.27.100:81>
- DocumentRoot /WWW/port/81
- ServerName 192.168.27.100
- </VirtualHost>
- <VirtualHost 192.168.27.100:82>
- DocumentRoot /WWW/port/82
- ServerName 192.168.27.100
- </VirtualHost>
- <Directory "/WWW/port">
- AllowOverride None
- Require all granted
- </Directory>
- htpasswd -c /etc/httpd/mymima xiaoming
- htpasswd -c /etc/httpd/mymima xiaohong
- mkdir /usr/local/mysecret
- echo "this is mysecret" > /usr/local/mysecret/index.html
- [root@localhost ~]# more /etc/httpd/conf.d/vhosts2.conf
- <Directory "/usr/local">
- AuthType Basic
- AuthName "please login"
- AuthUserFile /etc/httpd/mymima
- Require user xiaohong
- </Directory>
- <VirtualHost 192.168.27.100:80>
- DocumentRoot "/usr/local/mysecret"
- ServerName 192.168.27.100
- </VirtualHost>