• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Featured
    • C# Tutorials
      • LinQ Tutorials
      • Facebook C# API Tutorials
    • PHP Tutorials
      • CodeIgniter Tutorials
    • Amazon AWS Tutorials
  • Categories
    • Programming
    • Development
    • Database
    • Web Server
    • Source Control
    • Management
    • Project
  • About
  • Write
  • Contact

CodeSamplez.com

Programming, Web development, Cloud Technologies

You are here: Home / Web Server / Manage Domain On Apache Based Linux Server

Manage Domain On Apache Based Linux Server

April 10, 2013 by Rana Ahsan Leave a Comment

htaccess tutorials

If you are on a shared hosting, you don’t have to worry about it that much, as you get a nice control panel to manage domains easily. Well, if you now move to a VPS or dedicated server, you can still have it easily with help of cpanel or such service. But, here we are talking about to take this control on ourselves. We are here to set up a full LAMP stack development environment on Ubuntu cloud VPS server, without help of other third-party, all by ourselves! Yes! Its fun and you should try it out. This tutorial is being released as a part of AWS tutorials series for developers. Today, we will learn Apache domain name management. If you are on AWS cloud platform, you must should have set up domain with AWS route 53 service, as otherwise you won’t get it completely working. Now, lets start our quest 🙂

Look For Enabled Sites And Available Sites:

Normally, apache is being installed on “/etc/apache2” path. Lets go to this path first:

$cd /etc/apache2

Here’s my apache directory listing looks like:
apche directory on ubuntu
Here, for today, most important directories are ‘sites-enabled’ and ‘sites-available’. ‘sites-enabled’ directory contains the configured all virtual host files for domains, including live sites. The ‘sites-available’ directory contains only the configurations which are currently live. If we configure a new site and keep that file on this directory, it will be automatically available in ‘sites-enabled’ directory too. Also, another thing to remember, these configurations file doesn’t have any extensions. We will edit/create these files using ‘vim'(in short ‘vi’) editor. A default configuration is already provided by apache installation named ‘default’/’000-default’. Lets just copy that for our site:

$sudo cp default mydomain_name.tld
$sudo vi mydomain_name.tld 

The name of the site is totally optional and up to you to what to name, usually its better to name it after the domain name to recognize it easily.

Setting Up The Root Apache Domain Name:

If you open the file we just copied, you will see something like as below. Note the “{*}” parts where we need to change:

<VirtualHost *:80>
        ServerAdmin {myemail@mydomain.tld}
        ServerName {www.mydomain.tld}

        DocumentRoot /home/{path_to_mydomain_root_directory}
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/{path_to_mydomain_root_directory}/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

First one “myemail@mydomain.tld”, is the email address you want to associate. Second one, “www.mydomain.tld”, it’s the most important, to indicate the original server/domain name. Then, “path_to_mydomain_root_directory” is the path where site’s root resides. For easy understanding, on amazon ec2 ubuntu server, we will use “/home/ubuntu/{domain_name}” structure.Besides ‘DocumentRoot’, we will have to mention this path on first ‘Directory’ tag as well.

Now save the file. Restart the apache server as below:

$ sudo service apache2 restart

And we should be fine. You should be able to start accessing your domain on the configured directory on server!

Final Words:

So, this is it. Hope this small Apache domain name management tutorial will be of some help for you. Let me know if you are having any issue while trying the above exercise. Also keep in touch to get the next tutorial on the series 🙂

Share If Liked

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on Pocket (Opens in new window)

You may also like

Filed Under: Web Server Tagged With: apache

About Rana Ahsan

Rana is a passionate software engineer/Technology Enthusiast.
Github: ranacseruet

Reader Interactions

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 3,774 other subscribers

Follow Us

  • Twitter
  • Facebook

Top Posts & Pages

  • How To Work With JSON In Node.js / JavaScript
    How To Work With JSON In Node.js / JavaScript
  • PHP HTML5 Video Streaming Tutorial
    PHP HTML5 Video Streaming Tutorial
  • How To Work With C# Serial Port Communication
    How To Work With C# Serial Port Communication
  • Facebook C# API Tutorials
    Facebook C# API Tutorials
  • Using Supervisord Web Interface And Plugin
    Using Supervisord Web Interface And Plugin
  • Utilizing Config File In C#.NET Application
    Utilizing Config File In C#.NET Application
  • LinQ Query With Like Operator
    LinQ Query With Like Operator
  • Getting Started With UDP Programming in Java
    Getting Started With UDP Programming in Java
  • Generate HTTP Requests using c#
    Generate HTTP Requests using c#
  • How To Use Hotkeys/Keyboard Events In WPF Application Using C#
    How To Use Hotkeys/Keyboard Events In WPF Application Using C#

Recent Posts

  • Building Auth With JWT – Part 2
  • Building Auth With JWT – Part 1
  • Document Your REST API Like A Pro
  • Understanding Golang Error Handling
  • Web Application Case Studies You Must Read

Tags

.net angularjs apache api audio auth authenticatin aws c# cloud server codeigniter deployment docker doctrine facebook git github golang htaccess html5 http javascript jwt linq mysql nodejs oop performance php phpmyadmin plugin process python regular expression scalability server smarty socket.io tfs tips unit-test utility web application wordpress wpf

Footer

Archives

Follow Us

  • Twitter
  • Facebook

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 3,774 other subscribers

Copyright © 2023