Archive for the ‘Linux’ Category

Install Django with Postgresql

April 22, 2017 Leave a comment

This post will guide you quickly step-by-step installing django and Postgresql on Linux Mint.

  1. Install Postgresql Server
    $ sudo apt-get install postgresql
  2. Switch account to postgres and create db user for django project (create non superuser that can create db)
    $ sudo -i -u postgres
    $ createuser djangouser -P --interactive
  3. Connect to postgresql server as djangouser and create db for django project
    $ psql -u djangouser -h localhost -d postgres -W
    $ create database django_project_db
  4. Create Django Environment and install postgres db adapter for python
    $ mkvirtualenv django-project
    $ pip install django psycopg2
  5. Create Django Project
    $ django-admin startproject mysite
  6. Change django project db settings
    $ cd mysite
    $ nano mysite/
        'default': {
            'ENGINE': 'django.db.backends.postgresql',
            'NAME': 'django_project_db',
            'USER': 'djangouser',
            'PASSWORD': 'djangouser',
            'HOST': 'localhost',
            'POST': '5432'
  7. Initialize DB data for django project
    $ python migrate
  8. Test by running the server
    $ python runserver


Categories: Django, Linux

Setup Python Virtual Environment

April 17, 2017 Leave a comment

When working on multiple python projects, perhaps we need to isolate package dependencies that needed for each project, so that dependency changes on one project does not make other project stop working.

Here’s example how to setup python virtual environment on linux mint.

$ sudo apt-get install python-pip
$ pip install setuptools virtualenv virtualenvwrapper

Add following code in ~/.profile

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/

Execute following command

$ source ~/.profile

Done! It’s time to test.

  1. Create Virtual Environment for project 1: eg env1 (skip this if env1 already created)
    $ mkvirtualenv env1
  2. Activate virtual anvironment (eg: env1)
    $ workon env1
  3. Install package dependencies to current environment (eg: django)
    (env1)$ pip install django
  4. To get info about installed package:
    (env1)$ pip freeze
  5. Deactivate to exit from current virtual environment
    (env1)$ deactivate
  6. Get available virtual environments
    $ workon
  7. Remove virtual environment
    $ rmvirtualenv env1


Categories: Linux, Python

Simple NGinX Config

January 7, 2015 Leave a comment

Simple configuration to host static file like images and act as proxy to pass php resquest to apache httpd.

NGinX Configuration:

# The default server
server {
    listen       80 default_server;
    server_name  _;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   /var/www/html/some_site/images_folder;
        index  index.html index.htm;

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;

    # proxy the PHP scripts to Apache listening on
    location ~ \.php$ {

    # pass the PHP scripts to FastCGI server listening on
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #location ~ /\.ht {
    #    deny  all;
Categories: Linux

Installing EPEL Repository (CentOS 6.x)

October 20, 2014 Leave a comment

You install the EPEL repository by downloading the appropriate RPM package for your system and installing it.

sudo rpm -Uvh epel-release-6*.rpm

The Remi repository provides newer versions of the software in the core CentOS and Red Hat repositories. The Remi repository depends on the EPEL repository.

sudo rpm -Uvh remi-release-6*.rpm


Categories: Linux

Choosing CentOS Installation

December 21, 2013 Leave a comment

Recently when I wanted to install Centos in my Virtual Machine, I saw several options type of installation. Since it’s about server installation i want to to make sure it secure enough without installing unncessary packages. So I google to find it out. Here is the explanation about Centos Installation, and at last i choose ‘minimal’ :D. I found the explanation here

  • Desktop: base, basic-desktop, core, debugging, desktop-debugging, desktop-platform, directory-client, fonts, general-desktop, graphical-admin-tools, input-methods, internet-applications, internet-browser, java-platform, legacy-x, network-file-system-client, office-suite, print-client, remote-desktop-clients, server-platform, x11
  • Minimal Desktop: base, basic-desktop, core, debugging, desktop-debugging, desktop-platform, directory-client, fonts, input-methods, internet-browser, java-platform, legacy-x, network-file-system-client, print-client, remote-desktop-clients, server-platform, x11
  • Minimal: core
  • Basic Server: base, console-internet, core, debugging, directory-client, hardware-monitoring, java-platform, large-systems, network-file-system-client, performance, perl-runtime, server-platform
  • Database Server: base, console-internet, core, debugging, directory-client, hardware-monitoring, java-platform, large-systems, network-file-system-client, performance, perl-runtime, server-platform, mysql-client, mysql, postgresql-client, postgresql, system-admin-tools
  • Web Server: base, console-internet, core, debugging, directory-client, java-platform, mysql-client, network-file-system-client, performance, perl-runtime, php, postgresql-client, server-platform, turbogears, web-server, web-servlet
  • Virtual Host: base, console-internet, core, debugging, directory-client, hardware-monitoring, java-platform, large-systems, network-file-system-client, performance, perl-runtime, server-platform, virtualization, virtualization-client, virtualization-platform
  • Software Development Workstation: additional-devel, base, basic-desktop, core, debugging, desktop-debugging, desktop-platform, desktop-platform-devel, development, directory-client, eclipse, emacs, fonts, general-desktop, graphical-admin-tools, graphics, input-methods, internet-browser, java-platform, legacy-x, network-file-system-client, performance, perl-runtime, print-client, remote-desktop-clients, server-platform, server-platform-devel, technical-writing, tex, virtualization, virtualization-client, virtualization-platform, x11
Categories: Linux

Installing Subversion in Debian

October 16, 2011 Leave a comment

This article was taken from :

So happens there comes a time when you need to track whos been adding what to your documents, and how to revert back to last Mondays copy of a document. What you need is a software to manage the versions and track the changes done by whomever. What you need is a tool called subversion. I’ve been hunting around for some good document to go through the install step by step but could not find one short of reading an entire book on the subject. So I decided to write a small document on what I did to install my copy of subversion on Debian etch, just using apt… read on…

First you need the following

A. A clean debian 4.0 etch system
B. Tortisesvn :- a subversion client for Windows (Xp or Vista) Get it here
1. First we need to Install ssh server
# apt-get update
# apt-get upgrade
# apt-get install ssh

2. Next we install Apache2
# apt-get install apache2
# apt-get install libapache2-mod-php5

3. Install subversion packages
# apt-get update
# apt-get install subversion
# apt-get install libapache2-svn
4. Create Repository
# mkdir /var/svn/
# svnadmin create –fs-type fsfs /var/svn/myproject

5. Generate Test data in repository
# mkdir ~/TEMP/
# echo “Testing” > ~/TEMP/test.txt
# svn import -m “Testing via ssh+svn” ~/TEMP/ svn+ssh://
# svn co svn+ssh:// testcheckout

6. See if files in repository
# svnlook tree /var/svn/myproject/

7. Changeowner of repository folder to apache user
# chown -R www-data:www-data /var/svn/*
# chmod -R 770 /var/svn/*

8. Make sure svn is running in apache
# a2enmod dav
# a2enmod dav_svn
9. Create user accounts for SVN users, you will be prompted for their passwords
# htpasswd -c /etc/apache2/svn.passwd usera

# htpasswd /etc/apache2/dav_svn.passwd userb
# htpasswd /etc/apache2/dav_svn.passwd userc

10. Input this code into /etc/apache2/mods-available/dav_svn.conf
<Location /myproject_site>
DAV svn
SVNPath /var/svn/myproject
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/svn.passwd
Require valid-user
#SSLRequireSSL <– note this is commented out
11. Reload the apache config then, Test the connection using a browser to http://<repository address>/myproject_site
# /etc/init.d/apache2 force-reload
12. If it works time to add SSL to Apache
#apt-get install openssl ssl-cert

13. Generate a certificate
# openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem

>>ensure you fill up all the details
for the certificate<<

14. Change the permissions on the certificate
# chmod 600 /etc/apache2/apache.pem

15. Modify the /etc/apache2/ports.conf add the following string
Listen 443

16. modify /etc/apache2/sites-available/default
change the default NameVirtualHost * to NameVirtualHost *:80
Add NameVirtualHost *:443
Change <VirtualHost *> to <VirtualHost *:80>

17.Add right at the end of the file

<VirtualHost *:443>
ServerAdmin webmaster@localhost
SSLEngine on
SSLCertificateFile /etc/apache2/apache.pem

18. Uncomment SSL required in /etc/apache2/mods-available/dav_svn.conf
<Location /svn_zen>
DAV svn
SVNPath /var/svn-repos/project_zen
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
SSLRequireSSL       <—HERE


19.Reload the Apache config
# /etc/init.d/apache2 force-reload
20. Ensure mod ssl is loaded
# a2enmod ssl
21. Ensure repository permissions are correct

# chown -R www-data:www-data /var/svn/*
# chmod -R 770 /var/svn/*
22. Test in browser, enter the userid you created and password
https://<address of webserver>/myproject_site
23. Now that all is working with SSL Lets add some granular permissions
, usera and userb has readwrite userc only has read permissions to the repository.
# nano /etc/apache2/svn_ACL

put this in

readwritegrp = usera, userb
readgrp = userc

@readwritegrp = rw
@readgrp = r

@readwritegrp = rw
@readgrp = r

24. Lets tell subversion to use the permissions, Add this in to /etc/apache2/mods-available/dav_svn.conf
<Location /myproject_site>
DAV svn
SVNPath /var/svn/myproject
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/svn.passwd
Require valid-user
AuthzSVNAccessFile /etc/apache2/svn_ACL    <—HERE

25. Reload Apache and Have Fun with your SVN repository!!!
# /etc/init.d/apache2 force-reload
26. Fire up your Tortise SVN I use it in Vista it adds a right click menu which you can use to check in and check out documents. But first up use the repository browser to goto https://<your server address>/myproject_site to make sure all is going well
enter your userid and password created earlier. If all goes well you can start playing around with you TortiseSVN to check out and check in docs. Also you can diff and see the history of
updates. Its Great!!

Categories: Linux, Programming

From Squeeze to Wheezy and Gnome 3

April 30, 2011 4 comments

#Update :1

alternative installing nvidia driver without building with module asistant

sasuke:~$sudo apt-get install nvidia-kernel-2.6.32-5-686 nvidia-glx nvidia-xconfig nvidia-settings
sasuke:~$sudo nvidia-xconfig
sasuke:~$sudo reboot

#end of update

// Old Post

Well I don’t know this is the right method or not, but at least it work for me. This step is how I did :

  1. Install  Debian 6 (Squeeze) base system
  2. Upgrade to the latest kernel with apt-get update, apt-get dist-upgrade, this is my repository list :
    deb wheezy main contrib non-free
    deb wheezy-proposed-updates main contrib non-free
    deb sid main contrib non-free
  3. Reboot and select the new kernel
  4. Install required packages to build my NVIDIA driver and to test the OpenGL
    apt-get install module-assistant nvidia-kernel-source nvidia-xconfig nvidia-common mesa-utils
  5. Build and install Nvidia driver with modul-assistant
  6. Install X, Desktop Environment (Gnome,) Desktop Manager (GDM)
    apt-get install xserver-xorg, xorg, gnome-core, gdm
  7. Test Nvidia Graphics with glxgears, see the fps (mine is around 4000fps)
  8. Setup Xorg configuration File
  9. Add experimental to repository list
    deb experimental main contrib non-free
    deb unstable main contrib non-free
  10. Install Gnome 3
    apt-get update
    apt-get install -t experimental gnome3-session
  11.  Reboot System
  12. Testing

Screenshot (SuperTuxkart, Terminal, Firefox 4)

Categories: Linux