Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Thursday, October 30, 2014

Log in to ubuntu on virtualbox from host

We have been experimenting with different development environment in my startup.


Thursday, October 2, 2014

python+virtualenv on Cygwin

I recently made Linux my platform for development, Firstly ue to the similarity with my production platform. Secondly because most open source programming tool performs optimally in Linux based system.

However, unless I replace my ageing system with a Mac, I will still need Windows OS for my small day to day works. So I have been doing most of my techical jobs on Ubuntu 12, installed ob Oracle VirtualBox.

However, I have been noticing some annoying delay, which prompted me to consider using Cygwin.

After pulling my hair a bit, I managed to figure out how to install python developement tools on Cygwin.
  1. Install Python. 
  2. Download and unzip pip. 
  3. Install by going into the expanded directory and running python setup.py in a command prompt.
  4. Set the %PYTHONHOME% system variable to the python base directory, (i.e. C:\Python27\) and adding the python base directory and script directory (i.e. C:\Python27\Scripts) to your %PATH% system variable.
  5. Install Cygwin WITHOUT Python. The previous step tells Cygwin to use the Windows binary.
  6. Install Cygwin-Virtualenvwrapper using pip install https://bitbucket.org/cliffxuan/virtualenvwrapper-for-cygwin-windows-python/get/tip.tar.gz
  7. Install virtualenvwrapper-win using pip install virtualenvwrapper-win
  8. Make a symlink between Cygwin's virtualenvhome directory and Windows's using ln -s /cygdrive/c/Users/<USER>/Envs/ ~/.virtualenvs
  9. Add the following to Cygwin's .bashrc file: 
  10. export VIRTUALENVWRAPPER_PYTHON="/cygdrive/c/Python27/python.exe"
    export VIRTUALENVWRAPPER_VIRTUALENV="/cygdrive/c/Python27/Scripts/virtualenv.exe"
    source virtualenvwrapper.sh
     
  11. Go to C:\User\<username>\Env (or other %VIRTUALENV_HOME% location) and use virtualenv to start a new environment. Doing this allows virtualenvwrapper-win's workon command to work.


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