Skip to content

Getting Steam on Debian

The following guide is very straight forward and will get steam on with just a little configuration.

ein-eike.de/2013/12/02/installing-steam-on-debian-wheezy-64-bit-the-easy-way/

Advertisements

Nested elements not displaying right when floating

Okay, so there are some things with web development that really annoy me. One of which is when two nested DIV elements don’t react to one-another. Here is an example: http://www.sitepoint.com/examples/clearing_floats/example1.php just change the Inner DIV to long and you’ll see what I mean.

I found a page that has an explanation of this issue and four ways to solve it. I just used their fourth method which is only a line or two of CSS. All it is, is adding overflow: auto to the outer element. I did, however, need to add height: 100% to the outer element as well. So far it looks like it’s working perfectly.

Read the article here: http://www.sitepoint.com/simple-clearing-of-floats/

Getting Bootstrap on Ruby on Rails

So I’ve been spending a few days struggling with something that should be fairly simple, or at least I think it should be.  After spending several hours trying out tutorial after tutorial to get bootstrap working with Ruby on rails, I finally stumbled upon this youtube video by Amin Meyghani that shows you how to get it all running easily. It’s only a 5 minute process.  Unfortunately, it appears that the glyphicons do not work. 

I found that adding the fonts folder to your /root_project/public/ folder will do the trick.  Unfortunately, I can’t verify that this will work in a production environment or if there are significant disadvantages in using this method.

Removing an ssh key

Again, just a note to self:

ssh-keygen -R hostname

dmesg and getting a Dell Latitude E6400 wifi drivers

I’ve been struggling with this for a while. Finally a message was found using the linux command dmesg which led me to http://wireless.kernel.org/en/users/Drivers/b43#devicefirmware

This is just a little note for my future reference. Hopefully someone else can benefit from it.

Setting up Django with Ubuntu 12.10, SQLite, Gunicorn, and Nginx on a Digital Ocean droplet

Quite the title but I want to be as descriptive as possible.  I have been using the tutorial at https://www.digitalocean.com/community/articles/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn and though its worked, I had some troubles.

First thing you will want to do is follow the tutorial to make sure that your domain is properly linked on your droplet. Follow this tutorial and give it some time to ensure that the DNS is working.  Then you can follow this tutorial which will help you secure your root user and get a normal user setup.  And lastly, we want to make sure that all our packages are up to date.  Under your normal user, run the commands:

sudo apt-get update
sudo apt-get upgrade

Setup virtualenv

As I understand it, the virtual environment is used to store and run many of the programs needed to keep your django server afloat. Most importantly, in your virtualenv you can have the correct versions of the programs installed so you don’t accidentally install an update that breaks how your django app works.  Now we will run two commands. The first installs virtualenv and the second sets up a virtualenv that we will use for django and the other programs it needs.

sudo apt-get install python-virtualenv
sudo virtualenv /opt/myenv

Now you have your virtualenv installed and setup. You could install it anywhere but I simple follow the guide I’ve been using for setting up the virtualenv.  You can activate and deactivate the virtualenv very easily.  The first of the following two commands will activate it, while the second command deactivates it.  You can tell that your virtualenv is activate by checking your prompt. If it starts with (myenv), you have it activated.

source /opt/myenv/bin/activate
deactivate

Install Django and Gunicorn under your virtualenv

We will want to install Django within our virtualenv.  This is where I initially had trouble due to permission issues.  I will touch on this in just a little bit.  First we want to activate our virtualenv, then use pip to install django.  Pip is a tool for installing python packages and it is typically just as easy to use as apt-get.  Run the following commands

source /opt/myenv/bin/activate
pip install django

Now if you got OSError: [Errno 13] Permission denied: you need to change the permisions of the /opt/myenv/ directory so your current user can modify it.  You can use the following command to modify the permissions of the directory and all sub-directories.  Be sure to change user:user to your username “reimus:reimus”

sudo chown -R user:user /opt/myenv/

The command chown changes the ownership of the directory.  The option -R tells the command do run recursively so it changes everything within the directory and all its children.  And user:user is the new ownership.

Gunicorn is the HTTP server used to run your Django apps.  It is intended to be fast and light weight.  We will install it quickly in this step, and work with configuring it later.  Make sure that you still have your virtualenv active.

pip install gunicorn

Install SQLite3 and Nginx

We do not need or want to install SQLite3 under our virtualenv nor Nginx so you can deactivate and use apt-get to install everything that is needed. SQLite will be our database for django.  Nginx is a reverse proxy server which is used to prevent the direct access of files within your server.

sudo apt-get install sqlite3 libsqlite3-dev
sudo apt-get install nginx

I will touch on the configuration of Nginx later.

Setup a Django project

Now that we’ve established the groundwork for Django we will create a Django project, initialize our SQLite database, and configure the project to run under Gunicorn. We need to make sure that our virtualenv is active and change our working directory to the root of that virtualenv then use Django to create our project.

source /opt/myenv/bin/activate
cd /opt/myenv
django-admin.py startproject myproject

The third command above will create a new Django project named myproject in your current working directory.  run ls and you should see the new folder in /opt/myenv/.  Now a lot has happened with that command.  There are two essential files you will contantly be interacting with.  ./myproject/manage.py and ./myproject/myproject/settings.py.  The former will be used to run your Django app and the former contains essential settings that are used to properly run your project.

We will want to modify the settings.py file so it knows that we want to use our SQLite database and also that we want to use Gunicorn.  Open the settings fille with a text editor like nano and modify some of the text describted below.

nano ./myproject/myproject/settings.py
import os

BASE_DIR = '/absolute/path/to/myproject'    # This points to the directory where manage.py is
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', '$
        'NAME': os.path.join(BASE_DIR, 'database.db'),                      # Or path to database file if using sql$
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                      # Empty for localhost through domain so$
        'PORT': '',                      # Set to empty string for default.
    }
}

And now we want to add Gunicorn as an installed app.  Find the INSTALLED_APPS tuple in your settings.py file and add in gunicorn like so (Remember to add the comma).

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',   
    'django.contrib.messages',   
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    # 'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'gunicorn',
)

Now down the road we will want a place to store our static files, we will have to let Django know where those files are by changing STATIC_ROOT in settings.py.

STATIC_ROOT = '/opt/myenv/static/'

With the settings file updated we can use Djangos manage.py to create our database.db. After running the command, it will ask you if you would like to create a superuser for Django’s auth system. I’ve opted not to for the moment. Change your working directory to /opt/myenv/myproject/ and run the syncdb command.

cd ./myproject
python manage.py syncdb

If you run ls you should now see a database.db file.

Confugure Nginx

We are almost done.  We need to setup a configuration file for Nginx.  This configuration file is located in /etc/nginx/sites-available/myproject and we will make a symbolic link in /etc/nginx/sites-enabled/ which will point to the configuration file.

sudo nano /etc/nginx/sites-available/myproject

Now add in this text. Be sure to alter the red text when needed.  Changing the server name is required.

server {
    listen 80;
    server_name example.org;
    access_log /var/log/nginx/example.log;

    location /static/ { 
        alias /opt/myenv/static/; 
    }

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

And run these commands to create the symbolic link.

cd /etc/nginx/sites-enabled
sudo ln -s ../sites-available/myproject

Now you can start the Nginx service.  Keep in mind that if you alter the configuration file you must restart Nginx for the changes to take effect. Both commands are given below.

sudo service nginx start
sudo service nginx restart

Starting your Django server

There you have it, the configuration is done.  In order to get your server running you must have yoru virtualenv activated, your working directory should be at your projects root, and you run the run_gunicorn command through manage.py.  Keep in mind that Nginx needs to be running which was done above.

source /opt/myenv/bin/activate
cd /opt/myenv/myproject
python manage.py run_gunicorn --workers=1

Now you should be able open your website in a webbrowser and see Djangos welcome screen.  You can follow this tutorial to use supervisor to run your django app automatically and get it to run in the background.

Updating Fedora

Unfortunately Fedora doesn’t really come with too many of the programs and utilities I like. I need a few things added to my system straight from the get-go like Sublime text and the gst library for python:

To get Sublime Text 2 easily:

Just make sure that you update the download string with the correct version. Copy that into a .sh file and run it in a terminal using sudo bash filename.sh

PulseAudio:
Not quite sure yet. Yum says its installed by I can’t pull up the program. I need this so I can easily adjust volume for individual applications as well as switch applications to different audio devices.

github:
Setup github -> https://help.github.com/articles/set-up-git
Add an ssh key -> https://github.com/settings/ssh
Clone your repos -> http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository#Cloning-an-Existing-Repository

gst:
sudo yum install gstreamer-python

eyeD3 (For one of my own projects):
yum install python-pip
pip install eyeD3

Misc updates and enhancements:
http://linuxmotion.com/tutorials/96-top-things-to-do-after-installing-fedora-19-post-installation
Note: This website seems to only have the x86 version of adobe flash. Find another guide to install it.