Thursday, 24 November 2016

Creating Virtual host in LAMP in Ubuntu

Creating a Virtual host in Ubuntu LAMP with default port 80 for Magento

1) cp /etc/apache2/sites-available/000-default.conf /   /etc/apache2/sites-available/mysite.com.conf

2) sudo vim mysite.com.conf

     <VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  #ServerAdmin webmaster@example.com
  ServerName  mysite.com
  ServerAlias www.
mysite.com.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/html/Project_folder
  <Directory /var/www/html/
Project_folder>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride all
      Order allow,deny
      allow from all
 </Directory>
  # Log file locations
 </VirtualHost>


3) sudo service a2ensite mysite.com.conf

4) sudo service apache reload

5) sudo /etc/init.d/apache2 restart

Notice the symlinked file of mysite.com.conf in /etc/apache2/sites-enabled folder.

5)  Go to /etc/hosts:
    
      By default we have as below:
   
      127.0.0.1    localhost

     Add your host name to map the localhost as:

     127.0.0.1    mysite.com


6) In C:\Windows\System32\drivers\etc\hosts

     Add VPN's IP along with host name as :

    127.0.0.1       localhost
    11.11.11.111        mysite.com

7)  Change the value of custom sitename in core_config_data table.


                                                Make sure:

In etc\apache2\apache2.conf configurations for / root directory is as follows

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/html>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>



and Virtual host configuration setting is enabled.

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf