Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AlanSk's avatar

Index of / using apache

Hello,

For fun im just trying to deploy my laravel app to a ubuntu that I have running on a VM. I am using Apache.

I followed this guide from start to finish https://help.clouding.io/hc/es/articles/4406607535634-C%C3%B3mo-Desplegar-Laravel-8-con-Apache-y-Let-s-Encrypt-SSL-en-Ubuntu-20-04 And when I try to enter my app I just get the "Index of /" Instead of the actual welcom page.

I tried googling to try other guides or solutions and the steps on every guide now is the same really, so I dont really know what else to do. Im going to leave here my VirtualHost code as you guys will probably ask for it.

<VirtualHost *:80> ServerAdmin [email protected] ServerName laravel.example.com DocumentRoot /var/www/html/ifp-security/public

<Directory /var/www/html/ifp-security>
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
(a screenshot https://prnt.sc/gj7yF8zSJPBG just in case its easier to read)

Thanks!

0 likes
22 replies
AlanSk's avatar

@Tray2 Hey, first of all, thanks for the help. I just did everything as the guide and I'm still getting an Index of in localhost and accessing the ip of the ubuntu on my windows machine https://prnt.sc/td_5LKB8fXlv I tried to access the folder that you can see in the screenshot and accesing the /public folder and nothing displays... https://prnt.sc/4PbCld5zFEKd

AlanSk's avatar

@jlrdw Hey, just took my time to really review it and I think it is setup correctly. Here is my VirtualHost, but still when accessing it by the browser, I cant display it if I dont go in my public foldar manually https://prnt.sc/duS4V0YE5Dqd

sr57's avatar

@alansk

I followed this guide from start to finish

sure ?

last line : Now, open your website and type the URL https://laravel.example.com

You can chose an other name but it must be defined with "servername" and your dns (or localy via /etc/hosts) must be setup

1 like
AlanSk's avatar

@sr57 Hey, I tried setting the ServerName to localhost and to laravel.dev. Still same result in both with the index of /

sr57's avatar

@alansk

... AND your dns ...

Please show one full example

  • virtualhost setting

  • dsn setting

  • access url

1 like
AlanSk's avatar

@sr57 Here is an example of my Virtual host settings: https://prnt.sc/DkHpg9DHUF4U Im just going to change the ServerName laravel.dev to ServerName localhost to show both examples.

Here is my /etc/hosts file https://prnt.sc/vao1F2dUuoON

Here is the result of accessing the page by this-is-a-test.dev https://prnt.sc/GRjvci9adItx Here is the result of accesing the page by localhost(changing the virtualhost): https://prnt.sc/NP6xkFP-S2H3

And now somehow by accesing the public directory manually im able to see the web: https://prnt.sc/duS4V0YE5Dqd But im pointing to the /public directory

sr57's avatar

@alansk

Have you enabled your virtualhost and restarted apache2?

1 like
sr57's avatar

@alansk

Don't see the problem but difficult to follow with image. Copy/paste in this forum (code between 3 `) , it's easier to read and it'll remain for future reads.

my vh

...

my dns

...

...

1 like
AlanSk's avatar

@sr57 Sorry, you are right

<VirtualHost *:80>
    ServerName this-is-a-test.dev

    ServerAdmin [email protected]
    DocumentRoot /var/www/html/ifp-security/public

    <Directory /var/www/html/ifp-security>
    Options Indexes MultiViews
    AllowOverride None
    Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
127.0.0.1	localhost
127.0.1.1	ifp-vm
192.168.176.135 this-is-a-test.dev
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
AlanSk's avatar

@sr57 I was just watching the index of / page. Below Snapey just told me to run a2ensite and it just started working... Now just the links are broken, but at least now I have something to work with hehe

Really appreciate your help tho

AlanSk's avatar

@sr57 Is a2ensite with out any parameters the same that a2ensite laravel.conf?

To be honest I dont really know..

sr57's avatar

@AlanSk

No, without parameter it asks for the parameter (the vh conf file)

That said,, in your image, the result is "site laravel already enabled" that means that you had still run this cmd before and don't need to do it anymore ( the cmd simply creates a simlink in /etc/apache2/sites-enabled )

Snapey's avatar

Its important to note that virtual hosts are matched by the name of the site you are requesting.

You must be able to route to the server using the chosen domain name

So if your virtual host says laravel.example.com then you MUST be able to access the server using this EXACT name.

If you do not have the domain name laravel.example.com, then you should create a local hosts table entry pointing that domain to the IP of the server.

Otherwise, your virtual hosts configuration will not even be considered.

1 like
Snapey's avatar
Snapey
Best Answer
Level 122

did you run a2ensite so that the conf is symlinked into sites-enabled folder?

2 likes
AlanSk's avatar

@Snapey First of all thanks for both replies, really. I just tried that and now I'm able to access the web by typing the url I defined in the VirtualHost. Now the links are broken but at least I have something to work with!

Please or to participate in this conversation.