Archive for July, 2006

-image-Mollie Ballantine

Mollie Ballantine, originally uploaded by timc3.

The newest member of our family Mollie Ballantine. She went to sleep as soon as she got to her new home, and being a Basset Hound I am sure its a pose that we will get used to!

Shes so cute!


-image-Securing Debian

One thing I do when I have installed Debian is to tighten it down slightly. There are some great scripts to do this, such as bastille and also the securing debian howto but here is my top 10 lockdowns:

  1. Secure users home directories
    chmod -R 700 /home
    vi /etc/adduser.conf
  2. Disable all services not used and make sure that sshd is running on protocol2.
  3. Disable FTP (use ftpd-SSL or scp instead) and telnet (you should be using SSH)
  4. Disable root from accessing sshd, so only a normal user can log on then su.
  5. Configure logcheck to send logs to an outside email address.
    apt-get install logcheck
    vi /etc/logcheck/logcheck.conf
    If you need to change the frequency, edit the cron file here:
    vi /etc/cron.d/logcheck
  6. Get regular updates from your apt sources
  7. Restrict system reboots/shutdown on the console:
    vi /etc/inittab

    ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

    vi /etc/shutdown.allow
    Add your users in that are allowed to shutdown the system when logged in

  8. Edit pam.d security files to match your security policy:
    CD /etc/security
  9. Consider using tripwire to monitor any changes in binaries on your system.
  10. Take a backup of the system. Always a good policy.
    
    

-image-Joining Debian to AD

These are some really good instructions to joining a Debian box to an Active Directory domain using winbind.

http://www.ccs.neu.edu/home/battista/documentation/winbind/

The only step it didn’t say was to create a directory under /home with the name of the AD domain that you are joining so that pam.d can create the user directory when a user logs on for the first time.


-image-django with apache2

One thing that I feel is harder than it should be with django is getting it working with Apache2. Sure the built in webserver is nice for development, but there comes a time when you need to step up and use a webserver for development that you can also deploy the site upon.

I have used Apache a lot in the past, but recently I have decided to move over to installing everything the Debian way, and this will reflect that. I am going to use python2.3, Apache2 and the version of mod_python that is in stable. You can follow the instructions if you have installed Apache2 and mod_python in otherways after this step if you wish.
To get Apache2 on debian with mod_python, simply:

  1. apt-get install apache2
  2. apt-get install libapache2-mod-python

For the rest of the tutorial, I am assuming that you have Django setup correctly, and working with your database. If not, I recommend installing the development version. It is easy to update using SVN and there are some features that are better than the stable version I find. Once you have done this you can start to build your site. From then on you can create your apache virtualhost file:

I have decided to run my django site on a different port, but of course you can run it on different ipaddresses, and with different hostheaders. All you need to do is follow the apache 2 documentation for this. I feel this is already well documented so I will just show how I did it by running on different ports:

  1. Edit the ports file for apache2 to tell it to listen on more than one port:
    vi /etc/apache2/ports.conf
  2. Add this line to tell it to listen on port 8000:
    Listen 8000
  3. Create a new sites file for this new virtual host:
    vi /etc/apache2/sites-available/djangosite
  4. Now we need to put in the configuration details:
    
    
    
    SetHandler mod_python
    PythonHandler django.core.handlers.modpython
    PythonPath “[’/home/tim/dev/projects/’] + sys.path”
    SetEnv DJANGO_SETTINGS_MODULE djangosite.settings
    PythonDebug On
    
    
    Alias /media “/var/www/djangosite/media”
    
    SetHandler None
    
    
    
    SetHandler None
    
    
    
    

    This gives us several things:

    • Sets up a virtualhost to listen on port 8000.
    • For the virtual host use mod_python.
    • PythonHandler is told to use Django.
    • Our PythonPath is updated with our site files, in my case my django projects are located in /home/tim/dev/projects/ so this is what I use. Point this to where your django files are kept.
    • Let django know to use the settings file for this project
    • The we setup an alias to serve the media files, as they don’t need to be served through mod_python we turn the handler off for the /media/ location. I will setup my media files in /var/www/djangosite/media
    • Finally tell apache2 not to use mod_python to serve image files.

  5. Now save this file, and enable the site:
    a2ensite djangosite
  6. Now create the webhosting directory, and the symbolic link for the admin directory, and check the permissions:
    mkdir /var/www/djangosite/
    CD /var/www/djangosite/
    ln -s /usr/lib/python2.3/site-packages/django/contrib/admin/media/
    chmod -R 755 /var/www/djangosite
    
  7. The stop and start apache2 on your server (this is for Debian using init.d scripts, but whatever you do stopping then starting is better than a simple reload).
    /etc/init.d/apache2 stop; /etc/init.d/apache2 start

Once you have done that, check your site by point a webbrowser to the the machine that you have apache2 running on, but at port 8000 for instance if it is a localhost, tryhttp://127.0.0.1:8000.

One thing that I haven’t talked about is where it is best to place all the files used in creating a django site, and I have yet to read any documentation about this. This is why in the above I am point it to a dev subdirectory from my home directory. I don’t think this is a good idea for a production site, and perhaps it should go in somewhere off /var.

One thing is for sure, creating seperate directories for media and the actual files is a good idea, and you if you follow the django instructions you can take them up on the recommendation of using a seperate lightweight webserver to just serve these files.


-image-Top 30 Django Tutorials and Articles

Here’s a list of 30 helpful tutorials and/or articles on the Django web framework. This was written as an answer to the Top 30 Ruby on Rails tutorials and it is really helpful when you are learning Django. Hopefully this will help it get even more support.

read more | digg story


-image-hellahella on Apache 2

I have been using hellahella using paster serve and I must say the performance was terrible. I don’t think that it is mean’t to be run for any length of time which is at odds with hellahella, the web interface to hellanzb, which is.

I have documented before that I am using hellanzb to manage my nzb files, and hellahella makes it even easier and with integration with http://www.newzbin.com it is even better (how about one click downloads, unrar, par, and ready to view - yes I have it!)

So I wanted to run hellahella using Apache2 on my Debian box. Luckly just as I wanted to do this a new FAQ was put up on the Pylons web site on how to achieve this using mod_python (which I also wanted to use). Pylons is a web framework for python and it seems quite good too and I got alot of help from the very helpful pylons-discuss group on groups.google.com.
So I setup Apache2 or rather Debian did using apt-get, and I got a fairly normal install. If you haven’t used version2 of apache before the configuration has changed somewhat and all the config files are now split. At the same time I also installed mod_python using apt-get and as this is rather well documented I am not going to write it down here. Now all we need do is follow the first part of the instructions on the Pylons site:

  1. Install hellahella (I assume you are running hellanzb already otherwise go and download and install it) and make sure it works with paster serve hella.ini
  2. Make sure mod_python is installed and enabled.
  3. Save the http://projects.amor.org/misc/svn/modpython_gateway.py script as wsgi.py in your mod_python python directory which is /usr/lib/python2.3/site-packages/mod_python/ on my system.
  4. Create a project directory. I used /www/hellahella
  5. Create startup.py file in this directory with the following information:from paste.deploy import loadapp
    app = loadapp(”config:/www/hellahella/hella.ini”)
  6. Create a link to your hella.ini file: ln -s /etc/hella.ini hella.ini
  7. Go into your apache2 sites directory: CD /etc/apache2/sites-available/
  8. Create a new site: vi hellahellaSite
  9. And input the following information:

    VirtualHost 127.0.0.1
    ServerAdmin tim@timc3.com
    DocumentRoot /www/hellahella/
    SetHandler mod_python
    PythonHandler mod_python.wsgi
    PythonPath "['/www/hellahella/'] + sys.path"
    PythonOption wsgi.application startup::app
    PythonOption SCRIPT_NAME /
    ErrorLog /var/log/apache2/error.log
    Alias /stylesheets/ "/www/hellahellaMedia/stylesheets/"
    Alias /javascripts/ "/www/hellahellaMedia/javascripts/"
    Alias /images/ "/www/hellahellaMedia/images/"
    LogLevel warn
    CustomLog /var/log/apache2/access.log combined
    /VirtualHost
  10. Remember to change the ipaddress 127.0.0.1 to whatever ipaddress or domain name you need.
  11. The to a level above your doc root: CD /www
  12. Then create a link from the public media files for hellahella to a directory here: ln -s /usr/lib/python2.3/site-packages/hellahella-0.1dev_r782-py2.3.egg/hellahella/public
  13. Rename public: mv public hellahellaMedia
  14. You might need to chgrp and chown the files under this directory.
  15. Then enable this site: a2ensite hellahellaSite
  16. Restart apache2: /etc/init.d/apache2 stop; /etc/init.d/apache2 start
  17. Then test.
  18. And it should work aslong as hellanzb.py is running and hellahella is setup correctly.

And I must say it is looking good!


-image-What have I been doing

Well it seems to me like quite alot, so much so that I haven’t made much time to put updates in here so I will probably have more posts to follow this one when the time is right. But here is a quick list:

  • Spring cleaning the house - better late than never I support
  • Learning more about Django and getting it setup on 3 servers..
  • Setting up hellanzb in a daemon
  • Setting up the hellahella interface in Apache.
  • Creating a DVD and the associated movie of my holiday using the Apple iLife tools
  • Getting my proper visa from the Norwegian Police (finally!)
  • At work doing lots of work, and learning Oracle at the same time.
  • Installing ActiveCollab to hold my personal projects in one place.
  • Setting up subversion on Dreamhost.
  • Upgrading XBMC to the latest version - and its fantastic.

All in all seems like I have been quite busy, and I still haven’t managed to tackle most of the sites on my list that I wanted to finish by the end of the year. Still there is plenty of time left at the moment, even with adding more to the list!


-image-Django setup

Over the last few days I have been playing with Django quite alot, installing it on a couple of machines and on Dreamhost. The Dreamhost configuration is now well documented by Jeff Croft in his post: http://www2.jeffcroft.com/2006/may/11/django-dreamhost/ and the on Dreamhost Wiki here: http://wiki.dreamhost.com/index.php/Django

I did seem to use a few different settings on the file:

django.fcgi:
#!/usr/bin/env python import sys sys.path += ['/home/timc3/django/django_src'] sys.path += ['/home/timc3/django/django_projects'] from fcgi import WSGIServer from django.core.handlers.wsgi import WSGIHandler import os os.environ['DJANGO_SETTINGS_MODULE'] = 'drunkonpetrol.settings' WSGIServer(WSGIHandler()).run()

Which seemed to help no end in getting it working.

On my own development machines I have had to set the PYTHONPATH environmental variable in .profile which is what python uses to search along when doing its imports. This is also set when using Mod_Python in the VirtualHost settings of Apache.

DJANGO_SETTINGS_MODULE is another env var that can be set this time for django itself. I haven’t yet configured it on my machines at the moment but I will do no doubt.

The base configuration that django gives via its admin tools is very good, but it has been extended by this project: Nesh DjangoUtils , which helps when setting up a djangoproject to do everything from creating the directories to creating the fcgi and modpython entries.  I haven’t needed to use it yet as I already started my django project before using it, but it is one to try in the future for sure.

So far I am finding django quite rapid in development, but I am spending alot of time looking for documentation on things, but the IRC channel is proving invaluable for help.  I will be putting up alot more articles as I go forward.


-image-SSH tricks

The article describes in a human language some of the powerful, yet very useful (even for total newbies) capabilities of OpenSSH, such as passwordless login, automatic execution of commands on a remote system or even mounting a remote folder using SSH.

read more | digg story


-image-Infrared Photo Gallery!

Seen this gallery a couple of times before but thought as I keep going back to it, why not blog it straight from Digg. He says in the comments field that he is using a Filter to get these images, and with a long exposure time it is possible with a Digital Camera, so I might be getting a Hoya R72 for my Nikon D50 quite soon!

read more | digg story


Bad Behavior has blocked 369 access attempts in the last 7 days.