Sep
11
2009
0

Fix Mac Fusion for Snow Leopard

macfuseI use the really great macFUSE to mount several server directories via SSH on my work computer. One programm that makes this process really easy is Macfusion which offers a menu item and a standalone application to configure your mountpoints and mount/unmount them.

macfusionAfter upgrading to Snow Leopard recently Macfusion & macFUSE stopped working, so I was searching for a solution and luckily found one at Racker Hacker - Fix MacFusion on Snow Leopard.

Now I’m happily developing my PHP projects again in Netbeans with my remote dirs mounted via SSH :)

Written by Florian Beer in: development, mac, server
rel-tag , , , , , , , ,

Sep
20
2007
1

MySecureShell - chrooted SFTP server

Yesterday the wonderful Howtoforge had an article that finally freed me from my beloved/hated scponly. MySecureShell offers all the functionality of a proper SFTP server, easily configurable and very well integrated.

To get it up and running on Debian, just download the latest *.deb version from Sourceforge.
Then install it with the following command:
dpkg -i mysecureshell_0.95_i386.deb

Now for every SFTP user you want on your system just do the following (substitute ‘test’ with your desired username).
Add a normal user to your system:
adduser test
Open the file /etc/passwd and change the user’s shell from /bin/bash to /bin/MySecureShell. The line then should look something like this:
test:1111:1111::/home/test:/bin/MySecureShell
Alas, you have a chrooted SFTP only user, without the clutter of numerous additional directories for the chroot. Simple and elegant :)

The last step is to have a look through the config file in /etc/ssh/sftp_config, it’s pretty well documented!

Written by Florian Beer in: security, server
rel-tag , , , , , , ,

May
30
2007
1

Log4Twitter

Log4Twitter is very similar to an idea Herbert an me had a couple of years ago, to use a Jabber messaging framework to get distributed logging and alerts from several servers/applications.
It is a Java class that allows you to “log” to Twitter. This would easily allow you to set up an application that sends messages to a private Twitter Account that you can subscribe to. Retrieving those messages should then be possible by IM or even SMS, seems like a perfect set up for me.

Using Log4Twitter is as easy as the following:

Setting Classpath
Add log4twitter-1.0.jar to your application’s classpath.
Note that log4twitter-1.0.jar has to be loaded by the same classloader that will load the logging framework.

Setting Logger
Edit your logging framework’s configuration to enable Log4Twitter.
The fully qualified class name of log4twitter is “log4twitter.FRAMEWORK_NAME.TwitterAppender”.

See the Log4Twitter page for some examples.

Now who’s got the time to code a Linux syslogd replacement or supplement, so I can receive important log messages via Twitter? :)

Mar
02
2007
2

Installing eAccelerator on Debian

This is a quick HowTo for installing the eAccelerator PHP cache/optimizer on a Debian system (should be applicable to other Linux distros as well).

  1. Download the latest release from SourceForge.net to your server and extract the sources.
  2. Change to the sources directory and type in the following.
    export PHP_PREFIX="/usr"
    $PHP_PREFIX/bin/phpize
    ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config

    This should set up the environment and compile configuration correctly.
  3. Now compile with make and install with make install (as root) afterwards.
  4. To configure eAccelerator you have to edit your PHP config which resides in /etc/php4/apache2/php.ini on my system.
    Add the following lines at the end: extension="eaccelerator.so"
    eaccelerator.shm_size="16"
    eaccelerator.cache_dir="/tmp/eaccelerator"
    eaccelerator.enable="1"
    eaccelerator.optimizer="1"
    eaccelerator.check_mtime="1"
    eaccelerator.debug="0"
    eaccelerator.filter=""
    eaccelerator.shm_max="0"
    eaccelerator.shm_ttl="0"
    eaccelerator.shm_prune_period="0"
    eaccelerator.shm_only="0"
    eaccelerator.compress="1"
    eaccelerator.compress_level="9"

    The file README in the sources directory gives a pretty good explanation of all those parameters. The only one you should probably alter is the shm.size because 16MB of shared memory might be a little bit too conservative.
  5. Last step is to create the directory where eAccelerator stores the cached scripts which don’t fit into the shared memory. mkdir /tmp/eaccelerator
    chmod 0777 /tmp/eaccelerator

Now you’re done. Further tweaking can be accomplished by altering all the parameters in the php.ini file.

Written by Florian Beer in: linux, server
rel-tag , , , , ,

Jan
26
2007
4

Installing php5-cgi on Debian

For a long time I wanted to be able to run both PHP 4 and PHP 5 on the same server. Now I finally managed to come up with a solution that is easy to install and easy to use.

  1. Add the Debian Backports repository to your /etc/apt/sources.listdeb http://www.backports.org/debian/ sarge-backports main contrib non-free(on one line)
  2. Issue a package update: aptitude update
  3. Install PHP 5 as CGI module: aptitude install php5-cgi
  4. Configure Apache by adding the following lines to your main config file. In my case this was /etc/apache2/apache2.confScriptAlias /php5-cgi /usr/lib/cgi-bin/php5
    Action php5-cgi /php5-cgi

  5. Now find the Virtual Host you want to run on PHP 5 and simply put the following line into the <Directory> directive.AddHandler php5-cgi .php
    This overrides the default handler for files ending in .php which would be the normal PHP 4 module. Whit this directive it is now parsed and executed by the PHP 5 CGI binary.
  6. Reload your webserver config with
    /etc/init.d/apache2 reload
Written by Florian Beer in: linux, server
rel-tag , , , ,

Jan
25
2007
2

Periodically delete files per cronjob

Another entry in my virtual “braindump” category, so I don’t have to look it up somewhere else all the time.

If you want to periodically delete files in a specific directory the unix program find comes to the rescue. In my specific case I needed to delete all the movie files from a surveillance camera that where older than 30 days.

This is the crontab entry to accomplish that:
0 0 * * * /usr/bin/find /videos/ -type f -name '*.avi' -mtime +30 -exec rm {} \;
(everything in one line)

The code runs the program /usr/bin/find every day at midnight (0 0 * * *). It checks the directory called /videos for everything that is a file (-type f), has a name that ends in .avi (-name ‘*.avi’) and is created 30 days ago or before that (-mtime +30).
The command then executes rm (remove) on all those files (-exec rm {} \;).

Written by Florian Beer in: linux, server
rel-tag , , , , , , , , ,