Thursday 21 August 2014

Apache does not start when using Virtual Host on BITNAMI WAMP Stack

Updated on 19.12.2014

If you are using the Bitnami WAMP Stack, be careful while you setup the virtual host for your site (on local machine, Amazon EC2 or other Cloud).

First Steps:
  1. Open the /wampstack/apache2/conf/httpd.conf
  2. Search for [ conf/extra/httpd-vhosts.conf ] and uncomment that line (normally it should be line > 492 under the # Virtual hosts )
 Also, you may need to change port to 8080 or to 80 depends on your system requirement.

-------------------------------------------------------------------------------------------------------

If you are using the Bitnami WAMP Stack, be careful while you setup the virtual host for your site (on local machine, Amazon EC2 or other Cloud).

Firstly, wamp_intall_folder/apache2/conf/extra/http-vhosts.conf doesn't work anymore if you using Bitnami WAMP Stack. Instead, it uses wamp_intall_folder/apache2/conf/bitnami/bitnami-apps-vhosts.conf

1. Then, add the following content to setup of the Virtual host.
< VirtualHost *:80 >
 ServerName dev.testapp
 DocumentRoot "wamp_intall_folder/apache2/htdocs/testapp"
 
 Include "wamp_intall_folder/apps/testapp/conf/httpd-app.conf"
< /VirtualHost >


And, rest of configruation is exactly same for both.

OR Alternatevly,
you can configure same thing in a slightly different way, they rather Include the vhost.conf file and setup separately for each application.

I. First, create new folder on apps/ folder, in this case I am creating testapp/:
  wamp_intall_folder/apps/testapp

II. Then, create conf/ inside the above testapp/ folder.
  wamp_intall_folder/apps/testapp/conf


III. Then, create httpd-vhosts.conf file inside the above /conf folder;
  wamp_intall_folder/apps/testapp/conf/httpd-vhosts.conf

Then, add the below content on httpd-vhosts.conf file

< VirtualHost *:80 >
 ServerName dev.testapp
 DocumentRoot "wamp_intall_folder/apache2/htdocs/testapp"
 
 Include "wamp_intall_folder/apps/testapp/conf/httpd-app.conf"
< /VirtualHost >

IV. Further, create httpd-app.conf file inside the above /conf folder with the below content.
  wamp_intall_folder/apps/testapp/conf

 Then, add the below content on httpd-app.conf file

 < Directory "wamp_intall_folder/apache2/htdocs/testapp" >
  Options Indexes MultiViews
  AllowOverride All
  
  < IfVersion < 2.3 >
   Order allow,deny
   Allow from all
  < /IfVersion >
  
  < IfVersion >= 2.3 >
   Require all granted
  < /IfVersion >
  
 < /Directory >
 
On above steps 3 & 4, the wamp_intall_folder/apache2/htdocs/testapp is the folder where your actual project or app folder where all the php files are placed.

V. Now, lets go to the wamp_intall_folder/apache2/conf/bitnami/bitnami-apps-vhosts.conf file and add the below line
# Bitnami applications installed in a Virtual Host
Include "wamp_intall_folder/apps/testapp/conf/httpd-vhosts.conf"

2. One more step,  open the hosts file from the C:\Windows\System32\drivers\etc\hosts, in case of lixux or EC2 Server, it can be different location, please check before you add the below line.
Add the below line and save the file.
 127.0.0.1       dev.testapp

3. Finally, you have to restart the Apache server, if you browse by
http://dev.testapp/

Enjoy!

If anything, please let me know.

No comments:

Post a Comment

Please post any queries and comments here.