Virtual Host for Laravel with apache2

Virtual Host for Laravel with apache2

Table of contents

No heading

No headings in the article.

You have new Linux PC with fresh apache2 installation. Now you don't know how to point to your Laravel site? Let's follow the below steps.

Add your desired domain name in /etc/hosts (example: myblog.test you can give anything here and you should put it exact same in the virtual host config ServerName option)    myblog.test

apache2 virtual host config. Add this to /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
    ServerName myblog.test
    DocumentRoot "path/to/laravel/public"

    <Directory "path/to/laravel/public">
        AllowOverride Al
        Order allow,deny
        allow from all

Replace this path (path/to/laravel/public) with your project path

Enable mod_rewrite if not enabled

sudo a2enmod rewrite

Now restart the apache2 server

sudo service apache2 restart