CS 347: Setting Up Project 1

Your project 1 will be a real website with its own Git repository, Apache configuration, and domain name. This guide walks you through getting it all set up and served out via Apache.

Create Local Repository

Follow these steps to set turn the project 1 folder on your local machine into a Git repository.

Your changes are now recorded in your local Git repository.

Create Remote Repository

Follow these steps to create a centralized version of your repository.

Clone on Droplet

Follow these steps to pull the centralized version of your repository down onto your droplet.

We’re not ready to view it in the browser yet. First we need a domain name.

Domain Name

It’s considered bad form to share your web site via its IP address. Instead, we give it a more mnemonic domain name. Follow these steps to get a free domain name that you will use to identify your Digital Ocean droplet.

Apache Virtual Host

You’re ready now to start serving our your project. This new site will be served out on port 80, just like your blog. The ServerName directive will funnel all HTTP requests starting with the subdomain project1 to this site.

  • Log in to your droplet.
  • Run these commands to change into your repository directory and print its absolute path:
    cd ~/YOUR-REPOSITORY-NAME
    pwd
    Observe the path that is printed. You will be entering it in the next step.
  • Create /etc/apache2/sites-available/project1.conf using your favorite command-line text editor and sudo. Fill it with this content, replacing YOUR-DOMAIN-NAME, YOUR-USERNAME, and YOUR-REPOSITORY-NAME with their actual values:
    <VirtualHost *:80>
      ServerAdmin webmaster@localhost
      ServerName project1.YOUR-DOMAIN-NAME
      DocumentRoot /home/YOUR-USERNAME/YOUR-REPOSITORY-NAME
    
      # Allow access to all files.
      <Directory /home/YOUR-USERNAME/YOUR-REPOSITORY-NAME>
        Require all granted
      </Directory>
    
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    
  • Run this command to enable your site:
    sudo a2ensite project1
    sudo service apache2 restart
  • Visit http://project1.YOUR-DOMAIN-NAME in a web browser. You should see your index.html.

HTTPS Certificate

Now that you have a domain name, you are able to encrypt HTTP requests to and from your server with the help of an SSL certificate from Let’s Encrypt. Add a certificate by following these steps:

Comments

Leave a Reply

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