Showing posts with label virtual host. Show all posts
Showing posts with label virtual host. Show all posts

Tuesday, November 12, 2019

How to configure virtual host for Laravel on Linux

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

Monday, April 1, 2013

Configure apache virtual host


Make a entry to: C:\Windows\System32\drivers\etc\hosts
-----------------------------------------------------------
127.0.0.1    test.com
127.0.0.1    www.test.com

File Location:
-----------------------------------------------------------
C:\xampp\apache\conf\extra\httpd-vhosts

File Contents:

<VirtualHost 127.0.0.1:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost 127.0.0.1:80>
    ServerAdmin pritomkucse@gmail.com
    DocumentRoot "D:/src/test"
    ServerName test.com
    ServerAlias www.test.com
    ErrorLog "logs/test.error.log"   
    CustomLog "logs/test.custom.log"
    <Directory "D:/src/test">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>