Main menu

New Website

I've just updated the website to run on Drupal. Some content may still be missing and will be added soon enough.

Set up cakePHP for local testing under Ubuntu

I'm currently working on building an online sports logbook with cakePHP. I wanted to be able to test the software locally, without the whole bother of setting up a real heavy duty server. My setup involves using:

  • Lighttpd as the webserver
  • PHP 5
  • MySQL

I now have a light web server running on my computer permanently, and don't notice any performance issues whatsoever (It uses around 0.1MB Ram and virtually no CPU when idle).

Here's a quick guide to setting this up:

Install the necessary packages:

sudo apt-get install lighttpd php5-cgi mysql-server mysql-client

If you haven't ever used mysql you will be asked to define an admin password, which you should remember.
Next, configure lighhttpd: edit /etc/lighttpd/lighttpd.conf:

My server modules section looks such:

server.modules = (
"mod_alias",
"mod_compress",
"mod_rewrite",
"mod_fastcgi",
"mod_access"
)

I also edited the webroot to be in my home folder (/home/XXX/webroot), however it is necessary to change the owner or group for this folder to "www-data". What I did was:

sudo chgroup -R www-data /home/XXX/webroot/

and also added group read/write permissions to /home/XXX/webroot/

Back to the config file: I added the following section to enable php:

fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php5-fcgi.socket",
"bin-path" => "/usr/bin/php5-cgi"
,"allow-x-send-file" => "enable"
)
)
)

Since I only want local network computers to be able to access the server (127.0.0.1 is localhost, 127.0.1.1 is what you get if you query your hostname -- at least under Ubuntu):

$HTTP["remoteip"] !~ "192.168.1.[0123456789]{1,3}|127.0.1.1|127.0.0.1" {
url.access-deny = ( "" )
}

Lastly, since I installed cake in a folder called cake, I added:

url.rewrite-once = ("/cake/(css|files|img|js|stats)/(.*)" => "/cake/app/webroot/$1/$2",
"^/cake/([^.]+)$" => "/cake/app/webroot/index.php?url=$1" )

This does the same job as the .htaccess files, which lighttpd doesn't support (there's a reason for this lack of "support", it speeds up the server -- hence the name lighttpd).
Once you have modified the configuration, run sudo /etc/init.d/lighttpd restart to restart the server / reload the config.
Now you just need to install cakephp, i.e. unpack it into webroot/cake.

Finally, you will want some databases: install mysql-admin (note: not the same as mysqladmin) with sudo apt-get install mysql-admin (of course, if you are so predisposed, then you can set up your databases using shell commands...). Next run this, and login with the above created password, with username root, host localhost. Create a new database under Catalogues (to add a database go to the bottom left window and right click), then add a user (note the password), and finally edit the user's "Schema-Privileges": select the new database, and add the necessary permissions, I just added all permissions.

Now, follow the cakephp installation instructions, and use the new sql user and database detailed above for the database connection.

In actual fact, you get a lot of bang for your buck with this set up, you now have a proper web server on your computer which doesn't get in the way, yet is remarkably versatile. I've programmed a print-interface meaning any computers on the network can print by entering my (local) IP using their browser, without having to install drivers (There was an issue with one of the netbooks not wanting to accept the HP drivers for our printer -- Windows bugs be thanked...).

FGLRX Video Tearing under Ubuntu 10.10 fixed!

With the open ati drivers my computer can't resume from hibernation, with fglrx I had video tearing... I survived with the latter for a while. But luckily, a solution has been found, read up on:

http://www.ubunturoot.com/2010/08/how-to-fix-video-tearing-with-ati.html

The computer still doesn't wake up from suspend to ram now, but that's a slightly less important issue. Moral of the story is not to get an ATI video card in your computer!

ETH Zurich: Connect to VPN using OpenConnect.

For anyone under *nix wanting to connect to the ETH VPN network, there is (thankfully) an alternative to the rather atrocious official Cisco AnyConnect client, going by the name of OpenConnect:

If you are under Debian (testing/unstable only to date) or Ubuntu you should be able to install openconnect with:

sudo apt-get install openconnect

(You will also need vpnc installed to supply the connection script used below.)

To connect to the eth network you can then type:

sudo openconnect -s /etc/vpnc/vpnc-script sslvpn.ethz.ch --user=USERNAME --authgroup=ETHZ

You will then be asked to enter your password:

Attempting to connect to ###.###.###.###:###
SSL negotiation with sslvpn.ethz.ch
Connected to HTTPS on sslvpn.ethz.ch
GET https://sslvpn.ethz.ch/
SSL negotiation with sslvpn.ethz.ch
Connected to HTTPS on sslvpn.ethz.ch
GET https://sslvpn.ethz.ch/+webvpn+/index.html
Für eine Verbindung in die entsprechende VPN-Gruppe (VPZ)muss beim Feld «Connect to» «sslvpn.ethz.ch/VPZ_NAME» eingegeben werden, beim Feld Benutzername «Benutzername@VPZ_NAME»
Please enter your username and password.
Password:
POST https://sslvpn.ethz.ch/+webvpn+/index.html
Got CONNECT response: HTTP/1.1 200 OK
CSTP connected. DPD 30, Keepalive 30
Connected tun0 as ###.###.###.###, using SSL
Established DTLS connection

To disconnect press ^C.

Notes:

  • OpenConnect by default needs to be run as root. According to its homepage, you can set up your computer to allow running as a local user, but I haven't explored this in detail since this doesn't really bother me particularly much.
  • There is a network-manager plugin for openconnect, as well as one allowing gnome network management to take care of openconnect. I haven't tested this, and myself use kde, where the network management module doesn't (yet) support openconnect. If I find enough time, and remember about it, and [...] then I might add this functionality.
  • I have sudo set up to allow openconnect to run without password entry, to do so add the following to sudoers (using visudo:)

USERNAME ALL = NOPASSWD: /usr/bin/openconnect

Java/Swing: sending an event to a specific component...

While working on the gui for simple rowLog last night I came across the problem of trying to send the keyboard input to a popup-menu to a text entry box. It turned out the dispatchEvent() method of Swing components doesn't do what it says and dispatches the event to the keyboard manager instead of the component itself, which might reroute it somewhere else (if you're unlucky it does an endless loop where the same event keeps getting sent to the same component over and over again, which tries to reroute it, but can't). After fiddling about with reflection and other complicated things, simply in order to get dispatchEvent() to dispatch the event to the component on which the method is called, I discovered the simple solution of using:
KeyboardFocusManager.getCurrentKeyboardFocusManager().redispatchEvent(boatEntry, arg0);

This, it turns out, actually sends the Event (arg0) to where you want it to go (boatEntry), in contrary to the dispatchEvent() method which claims to do this, but doesn't. I.e. the following code DOESN'T work as specified:
boatEntry.dispatchEvent(arg0)

Subscribe to AHunt.org RSS
Return to top ►