Apache2 quick config

Here's a quick example of how to configure your Apache2 web server for use in this tutorial. We'll be using the primary Linode you created. The process assumes you haven't modified the LAMP stack that was installed through the Marketplace.

How long will this take? Approximately 15-20 minutes

Update your DNS, add your domain to your Apache2 web server, and test access to it.

1. Get your public IP

You'll need the public IP address for your primary Linode. If you don't know it, you can quickly get it:

  1. From Cloud Manager, select Linodes ().

  2. Locate your primary Linode.

  3. Make note of the IPv4 version address listed under IP Addresses. (You can also mouse-over the public IP and click to copy it.)

2. Create a DNS entry

You need your domain to point to the IP address of your primary Linode. To do this, you need to update your DNS with an A record entry. For example, if you were using a domain provider like Google Domains, you would log into your DNS control panel and add a new custom record:

3. Update Apache2

Now, make a few changes to the default Apache2 web server installation to set it up for your domain.

  1. Back in Cloud Manager, click Launch LISH console for your primary Linode.
  1. At the prompt, enter root for the login and the Root Password you set when creating the primary.

  2. Navigate to the default directory Apache2 uses to store website files:

    cd /var/www
  3. Create a new directory for your site, using your domain name to make it easy to recognize, and then navigate into it. (We'll be using our example domain docasssociates throughout this tutorial.)

    mkdir docassociates.com
    cd docsassociates.com
  4. Create a new index.html file to serve as your site's root page.

    nano index.html
  5. In the nano editor that launches, create a simple HTML layout for use. Later, you can overwrite this page with your site's actual index.html home page.

      <h1>Welcome to Documentation Associates!</h1>
  6. Press Ctrl + X, followed by Y then Enter to save and exit nano.

  7. Navigate to the directory where sites are managed in Apache2:

    cd /etc/apache2/sites-available
  8. Create a new configuration file for your domain:

    nano docasassociates.com.conf
  9. In the nano editor, set up the configuration file like the sample below. Replace ServerAdmin with the email address of the person serving as your web site admin, and ensure that your domain is set in place of docsassociates.com, where applicable.

    <VirtualHost *:80>
            ServerAdmin jdoe@docsassociates.com
            DocumentRoot /var/www/docsassociates.com
            <Directory /var/www/docsassociates.com>
                Options Indexes FollowSymlinks
                AllowOverride All
                Require all granted
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
            <IfModule mod_dir.c>
                DirectoryIndex index.html index.php
  10. Press Ctrl + X, followed by Y then Enter to save and exit nano.

  11. Activate the site using the config file you just created:

    a2ensite docsassociates.com.conf


    You'll see a message stating that you need to restart apache2. Don't do this just yet.

  12. Run ls to view all of the config files in \sites-available. You'll probably see results like this:

    000-default.conf                                     default-ssl.conf
    123.456.789.01.ip.linodeusercontent.com.conf         docsassociates.com.conf
  13. You need to make sure that all the *.conf files, except for the new one you just created are deactivated from Apache2. Run the a2dissite command for each one:

    a2dissite 000-default.conf
    a2dissite default-ssl.conf
    a2dissite 123.456.789.01.ip.linodeusercontent.com.conf
    a2dissite 123.456.789.01.ip.linodeusercontent.com-le-ssl.conf


    Some of these files may return a message of Site <name> already disabled. This is OK.

  14. Run this command to restart Apache2, to apply your updates:

    systemctl reload apache2

4. Test it

Launch a browser and enter your domain in the search bar. If you did everything correctly, you should see the simple home page you set up!


I got a 404

If you don't see your page, it might be because your DNS entry hasn't processed yet. Give it a few minutes and try again. If it still doesn't work, make sure that you set up your A record entry with the right domain and IP address for your primary Linode.