uninstalling video drivers in ubuntu 9.04 from command line
| Bash | | copy code | | ? |
| 1 | sudo dpkg-reconfigure -phigh xserver-xorg |
Sep 30th, 2009 by Vinod Pandey
uninstalling video drivers in ubuntu 9.04 from command line
| Bash | | copy code | | ? |
| 1 | sudo dpkg-reconfigure -phigh xserver-xorg |
$ unzip MySQL_python-1.2.2-py2.5-linux-i686.egg
http://stackoverflow.com/questions/268025/install-mysqldb-for-python-as-non-compressed-egg
Sep 28th, 2009 by Vinod Pandey
Prerequisites:
mod_wsgi configured with apache2 ( Installing and configuring mod_wsgi, Installation Issues)
virtualenv
What?
It is a tool for creaing isolated python environments.
Why?
Prevent dependency and version problems when deploying programs with conflicting library requirement.
How?
Download virtualenv
| Bash | | copy code | | ? |
| 1 | cd $HOME |
| 2 | mkdir downloads |
| 3 | cd downloads |
| 4 | wget http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.3.3.tar.gz |
| 5 | tar xzf virtualenv-1.3.3.tar.gz |
creating a virtual environment
| Bash | | copy code | | ? |
| 1 | cd $HOME |
| 2 | mkdir webapps |
| 3 | cd webapps |
| 4 | python2.5 ~/downloads/virtualenv-1.3.3/virtualenv.py --no-site-packages djangoapp |
The –no-site-packages option prevents it from inheriting packages from global site-packages folder.
What gets created:
Activating virtual environment
| Bash | | copy code | | ? |
| 1 | source bin/activate |
| 2 | (djangoapp)vinod@vinod-laptop:~/webapps/djangoapp$ |
To return to original path
| Bash | | copy code | | ? |
| 1 | deactivate |
Tutorials on virtualenv:
http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
http://pypi.python.org/pypi/virtualenv
Caution:
The version of Python from which the virtual environment is created must be the same version that mod_wsgi was compiled for.
Installing django
| Bash | | copy code | | ? |
| 1 | source bin/activate |
| 2 | cd ~/downloads |
| 3 | wget http://www.djangoproject.com/download/1.1/tarball/ |
| 4 | tar xzvf Django-1.1.tar.gz |
| 5 | cd Django-1.1 |
| 6 | python setup.py install |
Try importing django to check if it worked fine.
Start a project
| Bash | | copy code | | ? |
| 1 | django-admin.py startproject testproject |
| 2 | sudo vi testproject.wsgi |
testproject.wsgi content
| Python | | copy code | | ? |
| 1 | import os, sys |
| 2 | |
| 3 | sys.path = ['/home/vinod/webapps/djangoapp', '/home/vinod/webapps/djangoapp/lib/python2.5/site-packages'] + sys.path |
| 4 | os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings' |
| 5 | os.environ['PYTHON_EGG_CACHE'] = '/home/vinod/webapps/djangoapp/tmp/.python_eggs' |
| 6 | |
| 7 | import django.core.handlers.wsgi |
| 8 | |
| 9 | application = django.core.handlers.wsgi.WSGIHandler() |
create the directory tmp/.python_eggs for python egg cache
make testproject.wsgi executable
| Bash | | copy code | | ? |
| 1 | chmod +x testproject.wsgi |
enabling website in apache
| Bash | | copy code | | ? |
| 1 | cd /etc/apache2/sites-available |
| 2 | sudo vi djangosite |
djangosite content
| Apache configuration | | copy code | | ? |
| 01 | Listen 81 |
| 02 | NameVirtualHost *:81 |
| 03 | |
| 04 | <VirtualHost *:81> |
| 05 | ServerAdmin webmaster@localhost |
| 06 | DocumentRoot /home/vinod/webapps/djangoapp |
| 07 | |
| 08 | <Directory /> |
| 09 | Options FollowSymLinks +ExecCGI |
| 10 | AllowOverride None |
| 11 | </Directory> |
| 12 | |
| 13 | <IfModule mod_alias.c> |
| 14 | Alias /static /home/vinod/webapps/djangoapp/static |
| 15 | </IfModule> |
| 16 | |
| 17 | <IfModule mod_wsgi.c> |
| 18 | # See the link below for an introduction about this mod_wsgi config. |
| 19 | # http://groups.google.com/group/modwsgi/browse_thread/thread/60cb0ec3041ac1bc/2c547b701c4d74aa |
| 20 | |
| 21 | WSGIScriptAlias / /home/vinod/webapps/djangoapp/testproject.wsgi |
| 22 | WSGIDaemonProcess vinod processes=7 threads=1 display-name=%{GROUP} |
| 23 | WSGIProcessGroup vinod |
| 24 | WSGIApplicationGroup %{GLOBAL} |
| 25 | </IfModule> |
| 26 | |
| 27 | ErrorLog /home/vinod/webapps/djangoapp/log/error.log |
| 28 | LogLevel warn |
| 29 | CustomLog /home/vinod/webapps/djangoapp/log/access.log combined |
| 30 | ServerSignature On |
| 31 | </VirtualHost> |
| 32 |
create the folder log and access.log and error.log inside it. We mentioned both of them in ErrorLog and CustomLog in above configuration file
enable website
| Bash | | copy code | | ? |
| 1 | sudo a2ensite djangosite |
http://localhost:81
It worked!
Congratulations on your first Django-powered page.
If the success page is not available, check apache error.log file .
Resources:
http://pypi.python.org/pypi/virtualenv
http://www.danceric.net/2009/03/26/django-virtualenv-and-mod_wsgi/
http://plone.org/documentation/tutorial/install-plone-3-behind-apache-and-mod_wsgi-using-repoze/tutorial-all-pages
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
http://wiki.dreamhost.com/Python
http://wiki.pylonshq.com/display/pylonscookbook/Using+a+Virtualenv+Sandbox
Sep 28th, 2009 by Vinod Pandey
| Apache configuration | | copy code | | ? |
| 01 | Listen 81 |
| 02 | NameVirtualHost *:81 |
| 03 | |
| 04 | <VirtualHost *:81> |
| 05 | ServerAdmin webmaster@localhost |
| 06 | DocumentRoot /home/vinod/webapps/djangoapp |
| 07 | |
| 08 | <Directory /> |
| 09 | Options FollowSymLinks +ExecCGI |
| 10 | AllowOverride None |
| 11 | </Directory> |
| 12 | |
| 13 | <IfModule mod_alias.c> |
| 14 | Alias /static /home/vinod/webapps/djangoapp/static |
| 15 | </IfModule> |
| 16 | |
| 17 | <IfModule mod_wsgi.c> |
| 18 | # See the link below for an introduction about this mod_wsgi config. |
| 19 | # http://groups.google.com/group/modwsgi/browse_thread/thread/60cb0ec3041ac1bc/2c547b701c4d74aa |
| 20 | |
| 21 | WSGIScriptAlias / /home/vinod/webapps/djangoapp/testproject.wsgi |
| 22 | WSGIDaemonProcess vinod processes=7 threads=1 display-name=%{GROUP} |
| 23 | WSGIProcessGroup vinod |
| 24 | WSGIApplicationGroup %{GLOBAL} |
| 25 | </IfModule> |
| 26 | |
| 27 | ErrorLog /home/vinod/webapps/djangoapp/log/error.log |
| 28 | LogLevel warn |
| 29 | CustomLog /home/vinod/webapps/djangoapp/log/access.log combined |
| 30 | ServerSignature On |
| 31 | </VirtualHost> |
Testing developer formatter plugin.
import os, sys
def application(environ, start_response):
status = '503 Service Unavailable'
output = 'Down for maintainance. We will be back soon !'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
Sep 27th, 2009 by Vinod Pandey
In port based virtual hosting, different websites run on different ports. In this is example, we will be running website on port 81 of development server. Not much useful for production server, still I find this useful for development server.
folder structure
————————-
In $home directory, create the folders from where the files will be server.
webapps --djangoapp ----index.html ----log ------error.log ------access.log
cd /etc/apache2/sites-available sudo vi djangoapp
Listen 81 NameVirtualHost *:81 <VirtualHost *:81> ServerAdmin webmaster@localhost DocumentRoot /home/vinod/webapps/djangoapp <Directory /> Options FollowSymLinks +ExecCGI AllowOverride None </Directory> ErrorLog /home/vinod/webapps/djangoapp/log/error.log LogLevel warn CustomLog /home/vinod/webapps/djangoapp/log/access.log combined ServerSignature On </VirtualHost>
sudo a2ensite djangoapp sudo /etc/init.d/apache2 reload
http://localhost:81/ should now server the index.html file in djangoapp folder.
Sep 26th, 2009 by Vinod Pandey
wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz tar fxz Python-2.5.2.tgz cd Python-2.5.2 ./configure make sudo make altinstall
ln -s /usr/local/bin/python2.5 /usr/bin/python2.5
wget http://www.python.org/ftp/python/3.0/Python-3.0.tgz tar fxz Python-3.0.tgz cd Python-3.0 ./configure make make altinstall
ln -s /usr/local/bin/python3.0 /usr/bin/python3.0
Sep 26th, 2009 by Vinod Pandey
Installing ubuntu 9.04 on vaio:
Linux isn’t just Windows with funny colours, and Windows isn’t a poor man’s Linux. Both represent decades of hard work by people with different opinions about the world, and both need to be treated differently if you want to get the most out of them.
Prerequisites:
Download the iso image of Ubuntu 9.04 and burn it to a blank CD. I created a seperate partition for linux installation. Other option is to use free space in existing partition. We will use EasyBCD to modify windows bootloader.
Boot using the Live CD and start the installer.
Step 1:
Select installation language and default language for system.
Step 2:
Select timezone.
Step 3:
Select keyboard layout.
Step 4:
I manually created the partitions.
Step 5:
Little login information
Step 6:
I already have vista installed. It detected the settings and offered for migration.
Step 7:
I installed the boot loader in the same partition where linux is installed. Otherwise, it will rewrite the windows master boot records. We will modify windows bootloader to add entry for Ubuntu. The bootloader option is available on clicking the advanced.. option. partion #8 will be /dev/sda8
Installer will start copying files now.
Once the installation is completed, remove the Live CD and restart in Vista. Ubuntu option is yet to be added in boot records.
Download EasyBCD to modify the windows MBR
Restart and the Ubuntu will be avaliable in boot menu.
Windows drives are available in Ubuntu. But, if you want to access linux partition when in Vista, you need to install Total Commander will ext2/ext3 plugin. I tried installing other softwares, but none of them working as of now for my Vista installation and ext3 partition. Keep in mind, installing a software for accessing linux partition will weaken the security as no linux based access controls are applied here.
pre class="brush:[code-alias]"