Apache2-需要使用相同域名中的域名后使用不同的路径多个项目
我有两个完全不同的项目,我想从相同的域名mysimpledomainname.comIP地址xx.xx.xxx.xx(非本地)
I have 2 completely different projects I would like to host from the same domain name "mysimpledomainname.com" with ip address xx.xx.xxx.xx (not local)
2.项目位于
项目1)在/ var / www / html等/ PROJECT1
项目2)在/ var / www / html等/项目2
The 2 projects are located at Project 1) /var/www/html/project1 Project 2) /var/www/html/project2
我想有2个项目,解决这样的
I would like to have the 2 projects resolve like this
mysimpledomainname.com
mysimpledomainname.com
mysimpledomainname.com/project2
mysimpledomainname.com/project2
我不想使用子域名。这是对我的公共服务器,而不是我的本地机器上的一个项目,所以我不认为更新主机文件将帮助我。
I DO NOT want to use subdomain names. This is for a project on my public server, not my local machine, so I don't think updating the host file will help me.
我已经有来自mysimpledomainname.com第一个项目加载(它已经工作)。
I already have the first project loading from mysimpledomainname.com (it's already working).
在目录网站,提供我与价值观conf文件mysimpledomainname.com.conf:
In the directory sites-available I have the conf file mysimpledomainname.com.conf with values:
<VirtualHost *:80>
ServerAdmin myemail@gmail.com
DocumentRoot /var/www/html/project1
<Directory /var/www/html/project1/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我想我需要在为了做到这一点建立2个不同的conf文件,但围绕搜索后,我一直没能找到解决的办法。
谁能帮助我?而不是给一个简短的回答,你可以张贴正是我需要的2个不同的conf文件?
I think I need to have 2 different conf files set up in order to do this, but after searching around I have not been able to find a solution. Can anyone help me with this? Rather than giving a short answer can you post exactly what I would need for the 2 different conf files?
谢谢,
大卫
您只能有1 虚拟主机
指令,因为这是每个FQDN定义,你只想使用 mysimpledomainname.com 。
You can have only 1 VirtualHost
directive as this is defined per FQDN and you want to use only mysimpledomainname.com
.
您的的 PROJECT1 的配置就可以了。你只需要设置可供其他目录下的路径 /项目2
。要做到这一点,你需要使用 别名
指令。
Your config for Project1 is OK. You just need to make available another directory under path /project2
. To do this, you need to use the Alias
directive.
因此,最终的配置应该是这样的(当然你可以为每个子目录单独的目录
配置,如果你想):
So your final config should be something like this (of course you can have separate Directory
configurations for each subdir if you want):
<VirtualHost *:80>
ServerAdmin myemail@gmail.com
DocumentRoot /var/www/html/project1
Alias /project2 /var/www/html/project2
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>