NEW

Deploy Django to DreamCompute on Ubuntu with Apache – Part 5

In the final part of this tutorial, we’ll talk about how to set up a secure HTTPS connection on Apache with an SSL certificate from Let’s Encrypt.

Deploy Django to DreamCompute on Ubuntu with Apache – Part 4

In the previous part of this tutorial, we set up and configured Django. With everything now set up, it is time to install and configure Apache.

Deploy Django to DreamCompute on Ubuntu with Apache – Part 3

In the previous tutorial we got PuTTY and FileZilla set up. In this tutorial, we’ll be focusing on using the Shell terminal to get Django installed and set up.

Deploy Django to DreamCompute on Ubuntu with Apache – Part 2

In the first part of this tutorial, we set up a DreamCompute Instance. In this part, we’ll walk through connecting to the system Shell and SFTP.

Deploy Django to DreamCompute on Ubuntu with Apache – Part 1

In this five-part tutorial, I’m going to show you how to deploy a Django application to DreamCompute on Ubuntu with Apache and an SSL certificate.

The Google Pop-up Experience

When I've first heard about Google opening up a hardware store in Chicago's Bucktown during mid-October, I was very excited. I've been following Google's development for quite some time now in the industry. I, myself, am a big fan of smart devices and find the concept...

VO Manager Pro – Released

You can now purchase the VO Manager Pro on the Unity Asset Store at http://u3d.as/1ee5 for $14.99!

View My Map

View My Map is an online web application that gathers Facebook user’s checked-in location data and places them on a Google Map. The app also allows the user to export screenshots of their map as well as share them online via a generated link.

Balancing School and Work

It’s no joke when it comes to balancing school and work. It can be difficult, and I have a hard time myself. How do any of us do it? Sheer willpower of course! As true as that may sound, there’s more to it than sheer willpower.

Deploy Django to DreamCompute on Ubuntu with Apache – Part 4

In the previous part of this tutorial, Deploy Django to DreamCompute on Ubuntu with Apache – Part 3, we’ve successfully installed and configured our Django project to run on a virtual environment.

With everything now set up and working correctly with Django, it is time to install and configure Apache to run our site.


First, let’s deactivate our virtual environment. We can do so by running the following:

(env_name) ubuntu@instance_name:~/domain.com/projectname$ deactivate

Next, we want to install Apache alongside a Python 3 WSGI adapter module. This module will help us run Django with Apache. Run the following command to install the packages:

ubuntu@instance_name:~/domain.com/projectname$ sudo apt-get install apache2 libapache2-mod-wsgi-py3

You will be prompted to say Yes or No. Press Y and hit Enter to begin installing the packages.

Once installed, we’d need to configure our virtual host file, so it picks up our Django project and its static directory.

ubuntu@instance_name:~/domain.com/projectname$ sudo nano /etc/apache2/sites-available/000-default.conf

Running the command above will allow you to edit the virtual host file. Go ahead and delete everything within the file. You can then copy the following template, make your edits, and paste it into the terminal then press Ctrl + X, Y, then Enter to save.

<VirtualHost *:80>
	ServerName domain.com
	ServerAdmin name@domain.com

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	Alias /static /home/ubuntu/domain.com/public/static
    	<Directory /home/ubuntu/domain.com/public/static>
        	Require all granted
    	</Directory>

    	<Directory /home/ubuntu/domain.com/projectname/projectname>
        	<Files wsgi.py>
            		Require all granted
        	</Files>
    	</Directory>

    	WSGIDaemonProcess projectname python-path=/home/ubuntu/domain.com/projectname python-home=/home/ubuntu/domain.com/env
    	WSGIProcessGroup projectname
    	WSGIScriptAlias / /home/ubuntu/domain.com/projectname/projectname/wsgi.py
</VirtualHost>

Replace all instances of domain.com with your domain and projectname with your project name.

The last step we would need to do is to restart Apache. We can restart Apache with the following command:

ubuntu@instance_name:~/domain.com/projectname$ sudo systemctl restart apache2

That’s it! Now if we go to our domain, we should see our Django site fully operational.

Note: The configuration we have above only runs on port 80. Port 80 usually is how we would access a site through a non-secure HTTP connection. We’ll talk about SSL certificates and HTTPS in the next part of the tutorial.

Previous

Next

Submit a Comment

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