Template for making a personal website using django. Instructions given on how to create additional pages and how to serve it from Amazon.
Special feature is an automatically updating publications page that pulls publications from pubmed using the Biopython library. For an example of this page, see: http://www.melissagymrek.com/publications/
Note in the instructions below, any time you should edit part of a command with information specific to your site/computer, it is enclosed by carrots:
<stuff specific to you>
(These instructions assume you are on a fresh machine (e.g. booting up a new Amazon EC2 instance) from which you will serve your site.)
If you are using Amazon:
-
Launch an Amazon EC2 instance running Linux. Micro instances from the free tier are fine. If you don't have a key pair already, create one.
-
Make sure your private key (.pem file) has permissions
chmod 400 <my_key.pem>
- ssh into the instance
ssh -i <my_key.pem> ec2-user@<aws_ec2_instance_dns>
- Run
sudo yum -y update
to make sure all packages are up to date.
- Install MySQL
# Install it
sudo yum -y install mysql mysql-server
# Start MySQL
sudo /etc/init.d/mysqld start
# Configure username and password
mysqladmin -u root password <yourrootsqlpassword>
- Install Apache and mod_python
sudo yum -y install mod_python
- Install django and MySQL-python
sudo yum -y install MySQL-python
sudo yum -y install python-pip
sudo pip install django
- Install Biopython (used to automatically update publications page)
sudo yum -y install python26-devel
sudo yum -y install gcc
sudo pip install biopython
- Install git (so you can clone this repository)
sudo yum -y install git
- Install other apache/httpd required packages
sudo yum -y install httpd-devel
sudo yum -y install mod_wsgi
git clone https://github.com/mgymrek/django-personal-website.git
Update django-personal-website/home/settings.py
- Under "ADMINS" (line 7) update your name and email address.
- Under "DATABASES" update "NAME" (line 16) to be the name of your MySQL database, and "USER" and "PASSWORD" to be your MySQL username and password.
In django-personal-website/templates/index.html
- Change "Your name"
- Add a short description
- Put a .jpg figure you would like on the homepage in django-personal-website/pictures/ (You can upload pictures and other files from your local computer to your instance using scp). Replace "smiley.jpg" in index.html with the filename. An example scp command:
scp -i <my_key.pem> <path-to-my-beautiful-picture.jpg> ec2-user@<aws_ec2_instance_dns>
In django-personal-website/templates/publications/index.html
- Change "Your name"
- Change "My Last name"
In django-personal-website/templates/publications/article.html
- Change "Your name"
In django-personal-website/publications/utils.py:
- Change "your name" to your name. This will search pubmed for publications with your name on them.
In django-personal-website/templates/resources/index.html
- Change "Your name"
- Create the MySQL database
mysql -u root -e "create database <your-database-name>";
- Create tables for each app
cd ~/django-personal-website/
python manage.py sql publications
python manage.py syncdb
- Set up all the static files (docs/pictures/css). You need to do this any time you update any pictures, css, or documents.
python manage.py collectstatic
- Run the server (make sure you have port 80 set up to allow http access)
sudo python manage.py runserver 0.0.0.0:80
Paste your EC2 DNS to your web browser, and you should see your new site!
You can add "resources", and can tie them to publications if you want. For example, if there is supplemental data you want to post that goes along with one of your publications. You can add these through the admin.
First make sure you have a superuser set up:
python manage.py createsuperuser --username=<joe> --email=<[email protected]>
Now, go to the django admin page in your web browser <your-amazon-ec2-dns>/admin. Sign in with the superuser name and password. Here you can manage everything in the database that django draws information from. For instance if you already ran the above steps you should see your publications listed. To add a resource, go to "Add resource".
Information about adding additional pages can be found at https://docs.djangoproject.com.
To change the style, edit the CSS file at django-personal-website/css/djangoweb.css. After you change this, be sure to run "collectstatic" again so you can see the changes.
-
Edit django-personal-website/httpd.conf. Put the DNS of your EC2 instance at line 1015.
-
Copy the original httpd.conf file somwhere in case you screw something up
sudo cp /etc/httpd/conf/httpd.conf old_httpd.conf
- Copy your httpd.conf to where Apache knows to look for it
sudo cp ~/django-personal-website/httpd.conf /etc/httpd/conf/
- Create a logs directory for apache
mkdir /home/ec2-user/django-personal-website/logs
-
Edit django-personal-website/apache/django.wsgi. Change the paths to your django root directory if it is not at /home/ec2-user/django-personal-website.
-
Start httpd
sudo /etc/init.d/httpd restart
- Tie your Amazon EC2 instance's DNS to your domain name, for instance at name.com.