Home > Back-end >  How setup Apache Virtual Host to Laravel on Ubuntu Server 20.04?
How setup Apache Virtual Host to Laravel on Ubuntu Server 20.04?

Time:09-16

I have a server running Ubuntu 20.04 and Apache 2 that I use as a webserver. I made a configuration of a virtual host to point to a Laravel application, as you can see in the configuration file below.

<VirtualHost laravel-8.test>
    DocumentRoot /var/www/laravel-8/public
    ServerName laravel-8.test
    <Directory "/var/www/laravel-8/public">
        allow from all
        Options None
        Require all granted
    </Directory>
</VirtualHost>

And everything works perfectly on the server, but when I try to access the address laravel-8.test from another machine on the network, it goes to the Apache page. I even added in the Ubuntu hosts file to inform the address.

127.0.0.1   laravel-8.test

And I did the same on the workstation (Windows 10 Pro), I added the line

192.168.0.112    laravel-8.test

What am I doing wrong? I have the necessary Apache modules for Laravel to work (rewrite)

CodePudding user response:

If you want to connect from another PC, you need to write an external IP.

CodePudding user response:

change your v-host config to something like this...

<VirtualHost *:80>
    DocumentRoot /var/www/laravel-8/public
    ServerName laravel-8.test
    <Directory "/var/www/laravel-8/public">
        allow from all
        Options None
        Require all granted
    </Directory>
</VirtualHost>
  • Related