1.httpd.conf配置如下:
#Alias /app11 /app1
<Directory "/app1">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /app1
ServerName app1.liuqh.com
ErrorLog logs/156error
CustomLog logs/100access common
</VirtualHost>
#Alias /app22 /app2
<Directory "/app2">
# AuthType Basic
# Authname "This is a private dir"
# AuthUserFile /etc/httpd/password
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
# Require valid-user
</Directory>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /app2
ServerName app2.liuqh.com
ErrorLog logs/157error
CustomLog logs/157access common
</VirtualHost>
2.配置DNS服务器或配置hosts文件----本人用的是VMware,以下两个IP是用桥接的方式加的两张网卡
关掉192.168.0.156网卡:ifconfig eno33554984 down
我在物理机上配置hosts文件,为了在物理机上用浏览器测试
如果在/etc/resolv.conf配置,测试时要在虚拟机的浏览器测试,或用命令行curl app1.liuqh.com测试
[root@localhost etc]# cat hosts
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.157 app1.liuqh.com
192.168.0.157 app2.liuqh.com
虚拟机的浏览器测试如下:
用命令curl 测试如下:
[root@localhost etc]#
[root@localhost etc]# curl app1.liuqh.com
hello app1!!
[root@localhost etc]#
[root@localhost etc]#
[root@localhost etc]# curl app2.liuqh.com
hello app2!!!!
3.service httpd restart
4.setenforce 0
5.测试
app1.liuqh.com
app2.liuqh.com
6.注意点:
httpd默认指定的项目根目录是:/var/www/html