How to set Aliases or VirtualHost to run a laravel project on Apache2

Viewed 3416

I'm starting to learn how to set up a lamp on a vps, and i'm trying to run a laravel project.

This is my 000-default.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    Alias /laravelproject /var/www/laravelproject/public
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

I'm trying to access using the /laravelproject and it works cause i'm redirected to a login page ip/laravelproject/login (like I set using the middleware for not logged users and it works on my local homestead virtual machine). But i got a 404 file not found error. Not a pretty designed laravel one, but a raw and ugly server error

Not Found

The requested URL /laravelproject/login was not found on this server.

Apache/2.4.10 (Ubuntu) Server at '' Port 80

Of course i don't have any laravelproject.com domain to set up, i want to access it simply with my_server_ip/laravelproject.

How can i set up a virtualhost or an alias to run it with all the routes working?

2 Answers

You could also try enabling apache mod-rewrite if not enabled yet.

sudo a2enmod rewrite
sudo systemctl restart apache2
Related