Setup a virtual host for a Laravel project
- First, copy the default configuration file and rename it:
$sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/myVhost
- open myVhost.conf file using this command:
$sudo nano /etc/apache2/sites-available/myVhost.conf
- Add the directives:
assuming that the Laravel project is in /var/www/html/
ServerAdmin webmaster@localhost
serverName www.myAwesomeLink.com
DocumentRoot /var/www/html/laravel-app/public
<Directory /var/www/html/laravel-app>
AllowOverride All
</Directory>
so now the file will look something like this:

save and close.
- Now add an entry in the hosts file:
$sudo nano /etc/hosts
add this line:
127.0.0.1 www.myAwesomeLink.com
save and close.
- Enable site and the rewrite mode:
$sudo a2enmod rewrite
$sudo a2ensite myVhost.conf
- Restart the server:
$sudo service apache2 restart
- Serve the Laravel project:
open the project folder
php artisan serve
this will serve on port 8000 by default
you can also specify the port
php artisan serve --port=4200
- Open the browser:
http://www.myAwesomeLink.com:8000
or any other specified port.