Fork me on GitHub

Create Virtual Host on Ubuntu

Suppose, You want to create a virtual host for your laravel project like To create a virtual host for a project, you need to follow the steps below:

For Ubuntu LAMP, Open /ete/apache2/sites-available/00-default.conf and add this:

Or, create a new file i.e. /etc/apache2/sites-available/ and insert the snippet:

<VirtualHost *:80>
    DocumentRoot /var/www/html/project/public

    <Directory /var/www/html/project/public>
          Options Indexes FollowSymLinks
         AllowOverride All
          Require all granted

Then open /etc/hosts file, and add this line under localhost line:

If you create a new file in /etc/apache2/sites-available directory, then you need to enable the conf file by:

sudo a2ensite

By the way, if you didn’t enable rewrite mode for using htaccess in apache yet, then:

sudo a2enmod rewrite