Showing posts with label digital ocean. Show all posts
Showing posts with label digital ocean. Show all posts

Thursday, September 25, 2014

Lessons From Building My First Website

I made my first website at http://searchgovernmentjobs.org/ a few days ago - it's at a thin wrapper around a government API that I found at http;//digitalgov.gov. It allows you to search the government API for jobs using queries, examples of which I've included on the search page. The results are all from http://usajobs.gov.

My original intention was to just get something out there on the internet. In doing so, I learned some valuable lessons:
  • I learned about DigitalOcean (disclaimer: referral link), based on a question I had asked on HackerNews
  • I learned at least the basics of navigating the default Django stack that comes on a DigitalOcean Django droplet. See my post here for one such lesson that I learned. 
  • I learned how to buy a domain name at 1and1.com. (disclaimer: referral link)
    • Fun Fact: I had originally intended to name the site: searchgovernmentjobs.us - but it turns out that using the .us TLD forbids you from using the privacy coverage provided your hostname provider. It has to do with the rules of the organization that administers the .us TLD. 
  • I learned how to configure the 1and1 DNS record to point to the nameservers at DigitalOcean
  • I learned that there are Adsense alternatives. I'm using Chitika for the moment. (disclaimer: referral link)
Now that I have the site up, I'm going to look and see if I can do some SEO to get it up the ranks in search engine pages. Ideally, I would like the site to be self-sustaining in that it should pay for hosting and domain fees out of its own ad revenue, but I don't anticipate being very successful in this regard. The Jobs spaces is pretty filled up with SEO optimized sites and the keywords are very crowded. Nonetheless, I shall try, and in doing so, I may learn something about SEO.

Sunday, September 14, 2014

Modifying the DigitalOcean django one-click project to use a custom directory

Hi all,

I recently gave DigitalOcean a shot on the recommendation of someone at HackerNews. DigitalOcean has a lot of custom droplets, which are basically Virtual Machines, that you can use to set up a cloud server on which to host your website.

I had been building a Django website that I wanted to put up, and while setting it up on DigitalOcean, I ran into the following problem: The default Django droplet uses a base Django project located in the 'home' directory of the UNIX installation DigitalOcean sets up for you. I wanted it to point to a custom directory in the /opt folder that I had set up.

In order to do this, remote into the DigitalOcean droplet. Once there, run the following command:

    sudo nano /etc/init/gunicorn.conf

In this file, change 'chdir /home/django' to point to the directory that contains your django project. In my case, I changed it to '/opt/venv'.

Change the 'name' field to refer to the folder that contains your 'wsgi' file. In my case, I changed it to 'name=jobs'.

Change the 'pythonpath' field to refer to folder that contains your 'manage.py' file. In my case, I changed it to 'pythonpath=search-jobs'.

In 'django_project.wsgi:application' change 'django_project' to the name of your Django app (ie. what you changed your 'name' field to).

Now run the following command:

    sudo nano /etc/nginx/sites-enabled/django

In this file, change the media and static locations to point to where you need them to point to. In my case I changed:

    alias /home/django/django_project/django_project/media;

to:

    alias /opt/venv/search-jobs/media;

and:

    alias /home/django/django_project/django_project/static;

to:

    alias /opt/venv/search-federal-jobs/staticfiles;


That should set up the default nginx and gunicorn to serve your django project located in your custom path properly!

If you have any feedback on this post, or if it helped, drop me a comment and let me know.