简体   繁体   English

如何配置虚拟主机在 Xampp 的 htdocs 目录下工作?

[英]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:8000http://127.0.0.1:8000

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用laravel框架时如何在xampp上创建虚拟主机 - How to create virtual hosts on xampp while using laravel framework xampp/etc目录下没有hosts文件? - No hosts file in xampp/etc directory? 如何在xampp中的“ htdocs”文件夹之外启动laravel项目? - How can I start a laravel project outside of “htdocs” folder in xampp? Xampp 上的 Laravel 虚拟主机无法正常工作 - Laravel virtual host on Xampp does not work properly XAMPP-无法访问htdocs中的项目 - XAMPP - projects in htdocs cannot be accessed 如何在 Xampp 上为 Laravel 启用虚拟主机? - How to enable Virtual Host on Xampp for Laravel? file_put_contents(C:\xampp\htdocs\instant\storage\framework/sessions/FF): 无法打开 stream: No such file or directory - file_put_contents(C:\xampp\htdocs\instant\storage\framework/sessions/FF): failed to open stream: No such file or directory 错误:file_put_contents(C:\xampp\htdocs\instant\storage\framework/sessions/FF):无法打开 stream:没有这样的文件或目录 - ERROR: file_put_contents(C:\xampp\htdocs\instant\storage\framework/sessions/FF): failed to open stream: No such file or directory 嗨,我有这个错误 require(F:\xampp\htdocs\Neitland\storage\proxies\__CG__AppEntitiesVilless.php): failed to open stream: No such file or directory - Hi, I have this error require(F:\xampp\htdocs\Neitland\storage\proxies\__CG__AppEntitiesVilless.php): failed to open stream: No such file or directory 如何修复“未定义变量:gambar(查看:C:\xampp\htdocs\apmt\resources\views\upload.blade.php) - How to fix "Undefined variable: gambar (View: C:\xampp\htdocs\apmt\resources\views\upload.blade.php)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM