In this article we will discuss How to configure virtual host for Laravel with Apache server as web server (I installed lampp on my linux machine, which contains apache server installed). It would be very helpful to be able to manage many site on the same host specially when we work with api and specially when want feel like project is running on a real server like my_laravel.com. |
At first we need to enable virtual host, below is the command to edit httpd.conf: sudo gedit /opt/lampp/etc/httpd.conf Now locate # Virtual hosts #Include etc/extra/httpd-vhosts.conf and comment out the following line: Include etc/extra/httpd-vhosts.conf |
Next step is to put and entry to system host file (execute below command): sudo gedit /etc/hosts And add entry 127.0.0.1 my_laravel.com to the end of the file |
Next step is to modify file httpd-vhosts.conf, execute below command to modify: sudo gedit /opt/lampp/etc/extra/httpd-vhosts.conf |
<VirtualHost *:80> DocumentRoot "/opt/lampp/htdocs" ServerName localhost </VirtualHost> <VirtualHost my_laravel.com:80> DocumentRoot "/home/pritom/codes/laravel_test_success/public" ServerName my_laravel.com ErrorLog "logs/my_laravel.com-error.log" CustomLog "logs/my_laravel.com-access.log" combined <Directory "/home/pritom/codes/laravel_test_success/"> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all Require all granted </Directory> </VirtualHost> |
Finally restart apache server using command sudo /opt/lampp/lampp restart and browse my_laravel.com from browser |
Tuesday, November 12, 2019
How to configure virtual host for Laravel on Linux
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment