Virtual Host for Laravel with apache2
Sohag Hasan
1 min read
Table of contents
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)
127.0.0.1 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
</Directory>
</VirtualHost>
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
0
Subscribe to my newsletter
Read articles from Sohag Hasan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Sohag Hasan
Sohag Hasan
WhoAmI => notes.sohag.pro/author