Setting up a VPS for website hosting - Part 3

Apache2 Configuration

Apache2 is one open source type of HTTP server. It's essentially a software that will feed specific files that you want to send to your users on your website. It typically does this by designating a document root, or a folder on your server that is accessible to the outside world. I have my folder with apache2 pointing to ~/www/html/, so someone in a web browser would be unable to access anything else in my home directory.

The default folder location for Apache2 is /var/www/html. Personally, I've run into permission issues with this folder directory where the website is inaccessible. So I changed mine to ~/www/html To change this, there are a few files you need to edit.

The three files are:

Look for DocumentRoot and references to /var/www or /var/www/html. In all cases, replace /var/www to /home/cindy/www and all references to /var/www/html to /home/cindy/www/html

An easier way to do this is to run these lines of code, where $USER is your username. Optionally, run

before running these lines of code:

sudo sed -i "s|/var/www/|/home/$USER/www|g" /etc/apache2/apache2.conf
sudo sed -i "s|/var/www/html|/home/$USER/www/html|g"  /etc/apache2/sites-available/000-default.conf
sudo sed -i "s|/var/www/html|/home/$USER/www/html|g" /etc/apache2/sites-enabled/000-default.conf

Next you have to create a configuration file for your website. You can do this with:

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/$WEBSITE.conf
Where $WEBSITE is your website name. Mine is obviously