How To Configure Apache Virtual Hosts In Ubuntu

First you have to install Apache2 from here: Install Apache2

1. You have to enable some modules. Execute the following commands one by one

$ sudo a2enmod proxy_ajp
$ sudo a2enmod proxy_html
$ sudo a2enmod proxy_http
$ sudo a2enmod headers

2. Execute the following commands:

$ sudo gedit /etc/apache2/sites-available/000-default.conf

Copy and paste the following code with your Virtual Host name:

ServerName toslim.localhost.com
ProxyPreserveHost on
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / http://localhost:8080/

3. Then execute the following commands:

$ sudo gedit /etc/apache2/apache2.conf

Copy and paste the following code:

Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, PUT, DELETE"
Header always set Access-Control-Allow-Headers "access-control-allow-origin, authorization,content-Type,x-requested-with,accept,origin,access-c$

4. Then execute the following commands:

$ sudo gedit /etc/hosts

Add your Virtual Host name:

127.0.0.1 localhost
127.0.1.1 toslim
127.0.1.1 toslim.localhost.com

Leave a comment