Learnosity Logo
Learnosity Banner Image

HOWTO find files that are not world readable

I ran across some permissions errors on content that some users uploaded to a website. The files uploaded were not world readable so were coming up as forbidden:

This simple find command shows the offending files:

/usr/bin/find . -type f ! -perm -004

A quickie but a goodie.

Cheers, Mark

Installing Railo on Tomcat via Apache on Leopard - Step by Step

After a bit of fiddling and head scratching I managed to install Railo on Tomcat via Apache on my laptop running on OS X 10.5.6.

Tomcat

Firstly, download Tomcat 6

extract content:

tar xvzf apache-tomcat-6.0.18.tar.gz

Move Tomcat to a more secure place:

sudo mv apache-tomcat-6.0.18 /usr/local/tomcat

Railo

Download Railo custom version

extract and move into Tomcat lib directory:

tar zxvf railo-3.0.2.001-jars.tar.gz
sudo mv railo-3.0.2.001-jars/* /usr/local/tomcat/lib

Make Tomcat and Railo work together by modifying the web config file:

sudo nano /usr/local/tomcat/conf/web.xml

add the following inside the <web-app> element:

<servlet>
<servlet-name>CFMLServlet</servlet-name>
<servlet-class>railo.loader.servlet.CFMLServlet</servlet-class>
<init-param>
<param-name>configuration</param-name>
<param-value>{web-root-directory}/WEB-INF/railo/</param-value>
<description>Configuraton directory</description>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfc</url-pattern>
</servlet-mapping>

add the following inside <welcome-file-list> element:

<welcome-file>index.cfm</welcome-file>
<welcome-file>index.cfml</welcome-file>

Apache

Leopard OS comes with Apache 2, so you don't have to worry about installing it. However, you need to download The Apache Tomcat Connector source code.

Next you need to compile the source so that the resulting binary file is compatible with your Intel Mac architecture. I got this from Eric Rank's blog

cd into tomcat source:

cd tomcat-connectors-1.2.27-src/native

Edit the apache-2.0/Makefile.apxs.in file.

Replace

mod_jk.la:
$(APXS) -c -o $@ -Wc,"${APXSCFLAGS} ${JK_INCL}" "${JAVA_INCL}" "${APXSLDFLAGS}" mod_jk.c ${APACHE_OBJECTS}

with:

mod_jk.la:
$(APXS) -c -o $@ -Wc,"${APXSCFLAGS} -arch x86_64 ${JK_INCL}" "${JAVA_INCL}" "${APXSLDFLAGS} -arch x86_64 " mod_jk.c ${APACHE_OBJECTS}

configure the build files:

./configure --with-apxs=/usr/sbin/apxs

now go into apache-2.0 directory and build:

cd apache-2.0
make -f Makefile.apxs

Finally install

sudo make install

Now specify the connection between Apache and Tomcat. To do this you need to create workers.properties file. I created mine in /etc/apache2.

sudo nano /etc/apache2/workers.properties

Paste the following:

worker.list=default

worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1

Now we need to modify the Apache httpd.conf file:

sudo nano /etc/apache2/httpd.conf

Enable The Apache Tomcat Connector:

LoadModule jk_module libexec/apache2/mod_jk.so

Underneath that tell Apache where your workers.properties file is located and add some logging info (could be useful):

# Mod_jk settings
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel debug
DirectoryIndex index.html index.htm index.cfm index.cfml

Back to Tomcat

To test our Railo installation, let's create a test site by adding a new virtual host in both Tomcat and Apache. We do this by modifying Tomcat server.xml file (/usr/local/tomcat/conf/server.xml )
<Host name="railo.local" appBase="/Users/marko/Sites/railo/www">
<Context path="" docBase=""/>
</Host>

Apache

Now we need to create a virtual host entry in Apache as well:
<VirtualHost *:80>
JkMount /*.cfm default
ServerName railo.local
DirectoryIndex index.cfm
</VirtualHost>

JkMount /*.cfm default
Tells mod_jk to use the connector specified in your workers.properties file when it encounters a .cfm extension.

Important

Notice that in my Apache VirtualHost entry there is no DocumentRoot. I originally had it in there and it was breaking my Apache-Tomcat connection. It was driving me mad. It's probably because document root is already specified in /usr/local/tomcat/conf/server.xml.

One last thing, to start your Tomcat server type in this command:

/usr/local/tomcat/bin/startup.sh

shut down

/usr/local/tomcat/bin/shutdown.sh

My assumption is that the above steps would be very similar on other operating systems as long as you use the correct file paths.

Good luck :-)

Marko

Loading MySQL timezone info on Linux and Macs

MySQL has some really useful functions that make timezone support a bit easier as described in a previous blog post..

However, you need to do a tiny bit of setup work before you can use the functions. You need to load the timezone info from your system into the mysql db.

Thankfully, the MySQL Developers have included a very handy script that will do just that from a zoneinfo files which are used on Linux and on Mac's.

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

Obviously change the mysql params or add a -p if you have a password or are connecting to a remote server.

Check out the MySQL developer site for full details on MySQL timezone support

Cheers, Mark

Convert Mac Line endings to Linux

I was cleaning up some source code yesterday and wanted to print it all out, however the Mac line endings (we use Mac's and Ubuntu mostly) were messing up the printout on my Ubuntu machine.

A quick google later and I found the solution, a program called 'tr', posting here for next time:

tr "\r" "\n" < filewithmaclineendings.txt > filewithunixlineendings.txt

Obviously you could convert from Unix to Mac by reversing it.

tr "\n" "\r" < filewithunixlineendings.txt > filewithmaclineendings.txt

Cheers, Mark

DVD to iPod conversion - Linux, Mac & Windows

I've been looking for a while for a way to convert DVD's and other movies that I have into iPod format and have been failing miserably. That is until today, when I came across the unusually named HandBrake.

It does exactly what is says on the tin and makes it very easy to copy dvd's. Initially I used it from my Mac and it worked flawlessly.

I also tried the Linux version on Ubuntu Hardy (8.04) which has no GUI but it is pretty simple when you get the hang of it.

Here's a typical command line:

HandBrakeCLI --preset="iPod Low-Rez" -i /media/cdrom -o myvideo.mp4 -t 2

This reads from /dev/cdrom and uses the handy "iPod Low-Rez" preset which fixes it all up nicely for the iPod.

And here's one that takes the second title:

HandBrakeCLI --preset="iPod Low-Rez" -i /media/cdrom -o myvideo.mp4 -t 2

The wiki has more information on command line usage.

Happy iPodding.

Cheers, Mark

Gmail, Docs, Calendar and Analytics standalone with Prism

I came across Mozilla Prism the other day and while I'm still deciding if it's going to be a permanent addition to my machine so far so good.

Screenshot of Prism Gmail Prism is a cut down version of Mozilla which is designed to run single sites from icon - what's the use of that you may ask? Well it allows you to have an icon on your desktop for Gmail or Google Calendar or docs or analytics and get to it nice and quickly.

It also free's up some much needed screen real-estate as all the other toolbars relevant for a web-developers browser can get in the way and are not used when you are using you email and calendar.

Additionally - as web developer I tend to restart firefox more often than some - and having my email seperated from that is nice.

Give it a try and see if you like it. On Ubuntu Hardy you can do the following to install it:

#install calendar
sudo apt-get install prism-google-calendar
#install google docs
sudo apt-get install prism-google-docs
#install gmail
sudo apt-get install prism-google-mail
#install analytics
sudo apt-get install prism-google-analytics

On other platforms (windows,mac or other linux versions) you can go to the Prism site and download it.

For the different applications check out the Bundles section or the User contributed bundles section.

Obviously this shares a lot of similarities with the adobe AIR platform albeit not as full featured. It will be interesting to see what further development plans there are for the prism platform.

Cheers, Mark

Pretty network diagrams and flow charts with Open Source software.

I had been using Dia for all my charts and diagrams, and it does a very good job. The only downside is that it doesn't produce very pretty charts of the like of Omnigraffle.

However, inspired by this article, I'm starting to use a new solution, Inkscape, that fulfills my criteria that works on Linux, Mac and Windows.

Dia Omnigraffle Inkscape
Can create pretty pictures No Yes Yes
Cross Platform (Linux, Mac, Windows) Yes No - Mac only Yes
Open Source Yes No Yes
Open file format (to work with version control) No - Binary No - Binary Yes - SVG
Export to PNG Yes Yes Yes

Now you may argue that Inkscape is not a diagraming tool but a generic drawing tool. This is true, but with the addition of a few templates of pre-drawn items it become a very good diagramming tool.

I've created a few simple flow chart elements which I use and also scoured the net for some SVG icons for network based diagrams which were sourced from Gnome (via Ubuntu) and from Quantum Bits.

Templates Previews

Flow chart diagram preview

Computing devices preview

Download

Download the svg templates (right click - Save As):

Give it a try - it's very easy.

OS X Leopard and Ubuntu Screen sharing - HOWTO

I just go a nice shiny new Mac Mini today to use as a testing machine.

To make my life easy I want to be able to connect to it remotely from my Ubuntu (Gutsy 7.10) laptop. Luckily with Leopard's new screen sharing and a bit of googling it's easy to connect both ways.

Ubuntu to OS X

The Apple screen sharing uses a version of VNC - but the default VNC client on Ubuntu won't work with it - however thanks to this post I discovered the xtightvncviewer will work.

You need to configure your Mac to allow it with the following settings:

  • Open "System Preferences"
  • Select "Sharing"
  • Ensure "Screen Sharing" is on
  • Select "Computer Settings" on the Screen sharing page
  • Tick both boxes - "Anyone my request..." and "VNC viewers may control..." and add a password.

Note the address of your machine also - eg: vnc://192.168.0.55 or similar

Then over to the ubuntu machine and install xtightvncviewer:

$ sudo apt-get install xtightvncviewer

Then connect to the machine with: (change the ip address as relevant)

$ xtightvncviewer 192.168.0.55
You will then get a prompt - enter the password and you should be good to go.

OS X to Ubuntu

Once I had that working I was keen to see if I could get it working the other way:

You need to enable remote desktop sharing in Ubuntu:

  • Select "System->Preferences->Remote Desktop" from the menu
  • Tick the following boxes: "Allow others to view...", "Allow others to control...", and "Require ... password" and enter a password.

Then open up safari and type in the the address of you Ubuntu machine with vnc:// in front of it. eg:

It will give a warning about the vnc server not supporting "Keystroke encryption" but it will work (albeit not as securely as a Mac to Mac connection) - but good enough for your local network.

That's it - I did notice that it also showed up in Finder->Shared which I presume it found via Avahi/Bonjour - which is nice.

Hope it helps. Cheers, Mark

Update:

Note that on Ubuntu Intrepid 8.10 the standard Vinagre remote desktop viewer now works perfectly with OSX 10.5. The version I am using is 2.24.1. The authentication works a treat and it even picks it up with Avahi/Bonjour.