[英]How to configure virtual hosts to work in htdocs directory of Xampp?
I am following a laravel tutorial, where tutor sets up a virtual host to run their app.我正在关注 laravel 教程,其中导师设置了一个虚拟主机来运行他们的应用程序。 The app is located in
/opt/lampp/htdocs/first-app
.该应用程序位于
/opt/lampp/htdocs/first-app
。 My port for running apache is 8000 .我运行 apache 的端口是8000 。 So if I visit
localhost:8000/first-app/public
, I can view my laravel app.所以如果我访问
localhost:8000/first-app/public
,我可以查看我的 Laravel 应用程序。
My httpd-vhosts.conf file looks like this:我的 httpd-vhosts.conf 文件如下所示:
<VirtualHost *:8000>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
ServerAlias www.localhost
</VirtualHost>
<VirtualHost *:8000>
DocumentRoot "/opt/lampp/htdocs/first-app/public"
ServerName app.test
ServerAlias www.app.test
<Directory "/opt/lampp/htdocs/first-app">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
My /etc/hosts file looks like this:我的 /etc/hosts 文件如下所示:
127.0.0.1 localhost app.test
::1 localhost app.test
127.0.1.1 pop-os.localdomain pop-os
127.0.0.1 app.test
I have uncommented httpd.conf like so我像这样取消了 httpd.conf 的注释
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
But I am getting this when I visit app.test但是当我访问 app.test 时我得到了这个
Browser output when app.test is visited访问 app.test 时的浏览器输出
What am I doing wrong?我究竟做错了什么?
Edit: I have discovered, if I visit www.app.test:8000, it works fine编辑:我发现,如果我访问 www.app.test:8000,它工作正常
Just found out that the browser automatically adds port 80. So since I am running apache on port 8000, I need to specify it.刚刚发现浏览器自动添加了80端口,所以由于我在8000端口上运行apache,所以需要指定。
Thus, the settings above actually worked.因此,上面的设置确实有效。 All I had to do was go to
http://localhost:8000
or http://127.0.0.1:8000
我所要做的就是访问
http://localhost:8000
或http://127.0.0.1:8000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.