Saturday, November 30, 2013

Deploying Flask on lighttpd

Deploying Flask seems a lonely taks, becuase of dearth of articles or blogs that explain in. This is even worse when deploying on a shared server.
Most people seems to treat a python deployment as a django deployment. Since, there are cheap and available Flask hsting site, i went with Django host, but confirmed that we can host any other framework.

The good thing is that, there too many similarities, and most packages are already installed on the host.

1. Open putty and log into the hosts server (s17.wservices.ch)
2. Check that the following following packages are installed

    python and python-devel: the Python interpreter and its development package
    lighttpd: The Lighty web server and its development package
    install postgresql postgresql-contrib: The PostgreSQL database server and its development package
    git: source code version control system (we will use it to download and update the application)
    gcc: the C/C++ compiler (needed to compile Python extensions)
    sudo: a tool that helps users run commands as other users.


If not, install them.

sudo apt-get python python-devel lighttpd httpd-devel mysql-server mysql-devel git gcc

3. Configure passwordless login (if needed)
4. Create a directory for the application, and install the application from BitBucket
mkdir app
cd app
git clone git://bitbucket.org/peppe/peppe-ng.git


5. Check User permissions
chmod -R 777 *

6. Setup the database
Go to https://panel.djangoeurope.com/databases/
Login with a username and password, and then create a database and dump the content of the dev db
pg_dump peppedb > ppdbdump.sql

Transfer the file to live host
sftp outfile.sql peppe@s17.wservices.ch

Load the Db on the live host
psql peppedb < ppdbdump.sql

7. Setup the webserver
Paste at the end of this file ~/lighttpd/lighttpd.conf

#Peppe.com
$HTTP["host"] =~ "(^|\.)peppe\.com\.ng$" {
    fastcgi.server = (
        "/flask.fcgi" => (
            "main" => (
                "socket" => env.HOME + "/mysite_project/mysite.sock",
                "check-local" => "disable",
            )
        ),
    )
    alias.url = (
        "/media" => env.HOME + "/mysite_project/media",
    )

    url.rewrite-once = (
        "^(/media.*)$" => "$1",
        "^/favicon\.ico$" => "/media/favicon.ico",
        "^(/.*)$" => "/flask.fcgi$1",
    )
}


Replace mydomain\.com with the name of your domain. Be sure to escape all dots of your website's name (put a backslash before it: \.). Replace your_django_project/media with the path of you media directory (relative to your home directory). Replace mysite_project/mysite.sock with the path to your fastcgi socket file

Now you can launch your lighttpd:

~/init/lighttpd start

Whenever you make changes to the configuration, you can reload the configuration or restart lighttpd:

~/init/lighttpd reload

~/init/lighttpd restart



9. Configure the db and start
10. Install application updates

Sunday, November 3, 2013

Sonar Eclipse, in Lagos

All scientific evidence is that Nigeria will experience sonar eclipse today (2013-11-03).
My brother (an amateur astronomer... kind of), has been checking all kinds of map. He recommends skyeye over Google Skymap. :)

I will be following it on TimeAndDate website, and latter posting pictures.

Lagos @ 2.35 PM

UPDATE: Ended up being a partial eclipse. Next Solar eclipse is 1st Sept 2016. Till then, Stay alive!!!

Saturday, November 2, 2013

Enyimba Footbal Club, 2012/13 Season

Enyimba FC (arguable Nigerian most successful club-side) finished the 2012/13 season as League runners up, and Confederation Cup Winners

But the most telling record is NOT conceding ANY home goal!!!! That is 1710 minutes, without conceeding and goal at the home stadium!!!

WHAT A RECORD!!!

Am proud of the team, and hope the represent Nigeria honourable in continental matches.
The Third CAF Champions Cup is the goal

Nzogbu Nzogbu Enyimba, Enyi!!