virtualhost showing as index of /
Posted by: caydee (---.customer.vsm.sh)
Date: January 25, 2021 06:14PM

Hello Folks!

Greetings for 2021!

I am practicing and learning Laravel 8 on windows 10 using VSCode and WAMP. I made the necessary httpd-vhosts.conf and entered it also as a hoststfile.

If I use the php/artisan/serve command it shows the file correctly in the browser, but when I want to see it in Chrome browser as a Virtualhost from WAMP it shows it as Index of / with the various directories.

Any idea how I might correct this?

Caydee

IN ALL THINGS BE MEN
Windows 10 x64 | WAMP 3.3.2 - x64 | Apache 2.4.58 | MySQL 8.2.0 | PHP 8.2.13 | PHPMyAdmin 5.2.0

Options: ReplyQuote
Re: virtualhost showing as index of /
Posted by: RiggsFolly (Moderator)
Date: January 25, 2021 10:33PM

Can we see your VHOST definitions please.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: virtualhost showing as index of /
Posted by: caydee (---.customer.vsm.sh)
Date: January 26, 2021 10:15AM

Thanks RiggsFolly,

<VirtualHost *:80>
ServerAdmin webmaster@venture-wilderness.com
DocumentRoot "C:/websites/lvlproject"
ServerName lvlproject.lh
ServerAlias www.lvlproject.lh
Options Indexes FollowSymLinks
<Directory "C:/websites/lvlproject">
AllowOverride All
#Require all granted
Require local
</Directory>
</VirtualHost>

windows/system/drivers/etc/hosts:
127.0.0.1 lvlproject.lh

Caydee

IN ALL THINGS BE MEN
Windows 10 x64 | WAMP 3.3.2 - x64 | Apache 2.4.58 | MySQL 8.2.0 | PHP 8.2.13 | PHPMyAdmin 5.2.0

Options: ReplyQuote
Re: virtualhost showing as index of /
Posted by: RiggsFolly (Moderator)
Date: January 26, 2021 10:40AM

Right, as expected, your DocumentRoot is very unlikely correct

If you check any Laravel setup guide you will see that the DocumentRoot shoudl be pointing at the `public` folder. That also means changing the Directory to match

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: virtualhost showing as index of /
Posted by: caydee (---.customer.vsm.sh)
Date: January 26, 2021 02:27PM

I have a directory in C:/ called websites.
On GitBash I go into the websites and write the command: laravel new ProjectFolder while Composer/Laravel is globally installed. It installs the latest version of Laravel.
So the Document Root (path) becomes C:/websites/ProjectFolder.
So how else should the DocumentRoot be defined/written in the VirtualHost?

Caydee

IN ALL THINGS BE MEN
Windows 10 x64 | WAMP 3.3.2 - x64 | Apache 2.4.58 | MySQL 8.2.0 | PHP 8.2.13 | PHPMyAdmin 5.2.0

Options: ReplyQuote
Re: virtualhost showing as index of /
Posted by: RiggsFolly (Moderator)
Date: January 26, 2021 03:03PM

The way they describe in the manual. The site lives in the `public` folder so that has to be your DocumentRoot


<VirtualHost *:80>
   ServerAdmin webmaster@venture-wilderness.com
   ServerName lvlproject.lh
   ServerAlias www.lvlproject.lh
   Options Indexes FollowSymLinks
   DocumentRoot "C:/websites/lvlproject/public"
   <Directory "C:/websites/lvlproject/public/">
      Options +Indexes +Includes +FollowSymLinks +MultiViews
      AllowOverride All
      Require local
   </Directory>
</VirtualHost>

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 2 time(s). Last edit at 01/26/2021 03:04PM by RiggsFolly.

Options: ReplyQuote
Re: virtualhost showing as index of /
Posted by: caydee (---.customer.vsm.sh)
Date: January 26, 2021 05:18PM

Hi RiggsFolly,
Thank you very much!
However, on trying it out, I observed, it is not important to enter the trailing "public" in the Directory, but imperative in the DocumentRoot.
I have another (not laravel) site where it was doing the same thing, threw an error when I changed it in the Directory, but works perfectly without it... in laravel sites, works both ways!
Warm regards,

Caydee

IN ALL THINGS BE MEN
Windows 10 x64 | WAMP 3.3.2 - x64 | Apache 2.4.58 | MySQL 8.2.0 | PHP 8.2.13 | PHPMyAdmin 5.2.0

Options: ReplyQuote
Re: virtualhost showing as index of /
Posted by: RiggsFolly (Moderator)
Date: January 26, 2021 05:25PM

Hi

It may not seem like Apache cares and strickly it does not. However if you dont add the public folder to the path in the Directory tag, you are in fact allowing access to all folders below `C:/websites/lvlproject`

That is NOT what Laravel wants, in fact the directory structure is designed as it so to alow you to NOT give access to the universe to any folders other than the public folder!

Its a security thing

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 1 time(s). Last edit at 01/26/2021 05:50PM by RiggsFolly.

Options: ReplyQuote
Re: virtualhost showing as index of /
Posted by: caydee (---.customer.vsm.sh)
Date: January 26, 2021 05:49PM

Thanks again,

That makes sense, so I will add it back to the Directory as well. As always one learns something new from you!

Caydee.

Options: ReplyQuote
Re: virtualhost showing as index of /
Posted by: Otomatic (Moderator)
Date: January 27, 2021 02:43PM

Hi,

Do not forget also that if there is not an index.php or index.html file in the folder pointed by DocumentRoot, the Index of will be systematically displayed.
Unless in the Directory Options of the VirtualHost there is -Indexes

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote


Sorry, only registered users may post in this forum.