具有相同端口的不同 VirtualHost
我需要有两个虚拟主机,它们对于不同的项目具有相同的侦听端口并具有不同的日志。这是我所得到的:
<VirtualHost *:80>
DocumentRoot /home/projects/smk
ErrorLog /var/log/apache2/smk-error.log
RedirectMatch ^/$ /cms
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/projects/smk/cms
ErrorLog /var/log/apache2/smk-cms-error.log
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/projects/smk/deploy
ErrorLog /var/log/apache2/smk-deploy-error.log
</VirtualHost>
I need to have two VirtualHosts with the same listen port for different projects and with different logs. Here's what I've got:
<VirtualHost *:80>
DocumentRoot /home/projects/smk
ErrorLog /var/log/apache2/smk-error.log
RedirectMatch ^/$ /cms
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/projects/smk/cms
ErrorLog /var/log/apache2/smk-cms-error.log
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/projects/smk/deploy
ErrorLog /var/log/apache2/smk-deploy-error.log
</VirtualHost>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在所有虚拟主机中添加不同的 ServerName 指令:
不要忘记在
/etc/hosts 中添加
到dev.localhost
和my-project.localhost
的主机条目127.0.0.1
或您希望它指向的任何 IP。Add different ServerName directive in all virtual hosts:
Don't forget to add host-entries for
dev.localhost
andmy-project.localhost
in/etc/hosts
to127.0.0.1
or whatever ip you want it to point to.服务器名称 my-project.localhost
文档根目录 /home/projects/smk/deploy
ErrorLog /var/log/apache2/smk-deploy-error.log
//尝试添加错误文档
ErrorDocument 404 404.html
需要在您的应用程序中创建反馈。
ServerName my-project.localhost
DocumentRoot /home/projects/smk/deploy
ErrorLog /var/log/apache2/smk-deploy-error.log
//Try adding Error document
ErrorDocument 404 404.html
There is a need to create a feedback in your application.