Wolf Paulus

Journal

Navigation Menu

Installing / Updating Python on OS X

Posted by on Jan 28, 2013 in Mac OS X

While Python comes pre-installed on OS X, Apple doesn’t do a good job on keeping the Python runtime environment up to date. Currently, on Mac OS X 10.7.4 “Lion”, entering python -V returns Python 2.7.1. Even worse, Mac OS X 10.6 “Snow Leopard” is still on a Python 2.6 release.
While the latest Python releases are always available on http://www.python.org, updating a Mac isn’t a simple, straight forward process.

Follow along and update your Mac to Python 2.7.3, or 3.3.0 or whatever the newest 2.x and 3.x release might be, when you read this. To update your Mac to something like Python 2.7.3, I assume that

  • your Mac-User account is setup as an “Administrator” account.
  • your Mac already has this folder: /System/Library/Frameworks/Python.framework/Versions/

To read about how to upgrade to Python 3.3, jump to the very bottom of this post.

Read More

Installing Tomcat 7.0.x on OS X

Posted by on Oct 22, 2012 in Mac OS X

Tomcat 7 is the first Apache Tomcat release to support the Servlet 3.0, JSP 2.2, and EL 2.2 specifications. Please note that Tomcat 7 requires Java 1.6 or better, but that shouldn’t be a problem, if you are running OS X 10.5 or 10.6.

On OS X 10.7 and 10.8 (Mnt Lion) however, Java is initially not installed anymore. The easiest way to get Java onto your Mac is probably to open the Terminal app and enter java. You will be asked if you want to install it and OS X takes care of the rest – you would end up with Java 6, or you could install Java 7 directly from Oracle.

Whatever you do, when opening Terminal and running java -version, you should see something like this:

java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)

or this:

java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

sudo is a program for Unix-like operating systems, allowing you to run programs with the security privileges of another user (normally the superuser, or root). Since we are creating directories, outside of your home folder, administrator right are required. I.e., when executing sudo you will be asked to enter your password; and your Mac User account needs to be an ‘Admin’ account.

Here are the easy to follow steps to get it up and running on your Mac

  1. Download a binary distribution of the core module: apache-tomcat-7.0.34.tar.gz from here. I picked the tar.gz in Binary Distributions / Core section.
  2. Opening/unarchiving the archive will create a folder structure in your Downloads folder: (btw, this free Unarchiver app is perfect for all kinds of compressed files and superior to the built-in Archive Utility.app)
    ~/Downloads/apache-tomcat-7.0.34
  3. Open to Terminal app to move the unarchived distribution to /usr/local
    sudo mkdir -p /usr/local
    sudo mv ~/Downloads/apache-tomcat-7.0.34 /usr/local
  4. To make it easy to replace this release with future releases, we are going to create a symbolic link that we are going to use when referring to Tomcat (after removing the old link, you might have from installing a previous version):
    sudo rm -f /Library/Tomcat
    sudo ln -s /usr/local/apache-tomcat-7.0.34 /Library/Tomcat
  5. Change ownership of the /Library/Tomcat folder hierarchy:
    sudo chown -R <your_username> /Library/Tomcat
  6. Make all scripts executable:
    sudo chmod +x /Library/Tomcat/bin/*.sh

Instead of using the start and stop scripts, like so:
Last login: Sun Aug 14 15:20:38 on ttys000
wpbookpro:~ wolf$ /Library/Tomcat/bin/startup.sh
Using CATALINA_BASE: /Library/Tomcat
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME: /Library/Java/Home
Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
wpbookpro:~ wolf$ /Library/Tomcat/bin/shutdown.sh
Using CATALINA_BASE: /Library/Tomcat
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME: /Library/Java/Home
Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
wpbookpro:~ wolf$

you may also want to check out Activata’s Tomcat Controller a tiny freeware app, providing a UI to quickly start/stop Tomcat. It may not say so, but Tomcat Controller works in OS X 10.8.x just fine.

Finally, after your started Tomcat, open your Mac’s Web browser and take a look at the default page: http://localhost:8080

Read More

Installing Tomcat 6.0.20 on OS X

Posted by on Aug 18, 2009 in Mac OS X

Look here for how to install Tomcat 7: http://wolfpaulus.com/journal/mac/tomcat7
  1. Make Java 1.5 (or later) the default JRE
  2. Get the core distribution from http://tomcat.apache.org/ At the time of this writing that would be: apache-tomcat-6.0.20.tar.gz
  3. Unpacking will create a apache-tomcat-6.0.20 folder, probably on your desktop. Move this folder into /usr/local, like this:sudo mv ~/Desktop/apache-tomcat-6.0.20 /usr/local/
  4. To make it easy to replace this release with future releases, we are going to create a symbolic link that we are going to use when referring to Tomcat:sudo ln -s /usr/local/apache-tomcat-6.0.20 /Library/Tomcat
  5. Next step is making Tomcat’s launch and stop scripts executable:
    chmod ug+x /Library/Tomcat/bin/*.sh

Create startup and shutdown scripts:
Startup:
Open TextEdit and create a startTomcat.command file in your home folder …

#!/bin/sh
# ————————————————–
# Start Script for the Tomcat Server
# ————————————————–
export CATALINA_HOME=/Library/Tomcat
export JAVA_HOME=/Library/Java/Home
$CATALINA_HOME/bin/startup.sh

Shutdown:

Open TextEdit and create a stopTomcat.command file in your home folder …

#!/bin/sh
# ————————————————–
# Shutdown Script for the Tomcat Server
# ————————————————–
export CATALINA_HOME=/Library/Tomcat
export JAVA_HOME=/Library/Java/Home
$CATALINA_HOME/bin/shutdown.sh
  1. Open a Terminal and make both scripts executable:
    • chmod ug+x ~/startTomcat.command
    • chmod ug+x ~/stopTomcat.command
  2. Change ownership of the /Libaray/Tomcat folder hierarchy:sudo chown -R your_username /Library/Tomcat
  3. Start Tomcat by simply clicking the startTomcat.command icon in your home folder.
    Test with http://localhost:8080

Instead of using the start and stop scripts, you may also want to check out activata’s Tomcat Controller a tiny freeware app, providing a UI to quickly start/stop Tomcat.

Read More

Installing Maven on OS X

Posted by on Jan 7, 2009 in Mac OS X

While Apache Maven, our favorite software project management and comprehension tool, is already installed on OS X, as with so many other great open source tools on the Mac, they aren’t really kept up to date. However, installing Maven 2.0.9 isn’t a big deal and you even have several options.

wpbook:~ wolf$ mvn -version
Maven version: 2.0.6
wpbook:~ wolf$

One way to get an up-to-date Maven version on your Mac would be to use Mac Ports and Porticus:

  1. Download and install MacPorts
  2. Download and install Porticus
  3. Start Porticus
  4. Search for “maven” in Porticus
  5. Install

Installing Maven without MacPorts is a little bit more involved but can be done in 5 minutes or less.

  1. Download Maven from http://maven.apache.org/download.html.
  2. Unpacking will create a apache-maven-2.0.9 folder, probably on your desktop. Move this folder into /usr/local, like this:

    sudo mv ~/Desktop/apache-maven-2.0.9 /usr/local/

  3. To make it easy to replace this release with future releases, we are going to create a symbolic link that we are going to use when referring to Maven:

    sudo ln -s /usr/local/apache-maven-2.0.9 /Library/Maven

  4. Next step is making Maven executable:

    chmod ug+x /Library/Maven/bin/mvn
    chmod ug+x /Library/Maven/bin/m2

  5. Now we change the ownership of the /Libaray/Maven folder hierarchy:

    sudo chown -R your_username /Library/Maven

  6. Last step is to update ~/.bash_profile and to verify the update:
    Add the following to the bash_profile:

    export M2_HOME=/Library/Maven
    export M2=$M2_HOME/bin
    export JAVA_HOME=/Library/Java/Home/
    export PATH=$PATH:$M2

    and open a Terminal and enter:

    mvn -version

Read More

WWDC 2008

Posted by on Jun 10, 2008 in Mac OS X

Sitting in a hotel, downtown San Fran., after day one of Apple’s WWDC 2008, where some news were announced today.
I guess, when it comes to evaluating today’s day, it all depends on where you stay and what your focus is. If you were looking for a 2nd generation iPhone, then maybe the announced, $199 8GB iPhone 2.0 was the most important news of the day. However, I don’t think you will saving any money. ATT is subsidizing the iPhone even more now, but will also raise your monthly fees to $79 per month.
Since this is a developers conference, the most important news, those that will show there full impact only many months from now, may be hidden in some API that’s not covered by most news portals and syndicators.
On the iPhone side, Apple gave in to developers’ requests for background processes. There will now be a global event queue that applications on the iPhone can subscribe to, to receive events form the service providing server. An application that wants to push an event notification to client application running (or currently being suspend) on an iPhone needs to send the notification to a server that is hosted by Apple. The iPhone keeps a constant connection to that server and will eventually receive the custom notification and dispatch it to the application.
Moreover, David Duncan Davidson and Pinar were roaming the conference rooms, shooting photos left and right. I cannot wait to see their photos on Flickr.
Al Gore was in the audience during the Steve Note and also, Aaron Hillegass, author of ‘Cocoa Programming for Mac OS X’ was in the audience, as was Google’s Java Guru Joshua Bloch.

Read More

Enabling PHP 5.2.5 on Mac OS X 10.5 [Client]

Posted by on Mar 31, 2008 in Mac OS X

Getting the pre-complied PHP Apache Module from Marc Liyanage’s site was always the preferred way to get a fresh PHP distribution on your Mac. However, creating 4-way binaries (32- and 64-bit versions for G4/G5 and Intel CoreDuo / Core-2-Duo processors) seems to be broken and if Apache is running in the more efficient 64-bit mode, installing the PHP module not only doesn’t work, it will also break Apache. However, there is an easier way to get PHP working with your Apache Server on the Mac.

Apache 2.2.8

Starting Apache is as easy as opening System Preferences – Sharing and checking the box next to Web Sharing. After that’s done, open your Web browser and browser to http://127.0.0.1 (or http://localhost, or http://computername.local) to see the global Apache start page or go to http://127.0.0.1/~username (or http://localhost/~username, or http://computername.local/~username) to browse the content of your own site folder (/Users/username/Sites).

PHP 5.2.5

To enable PHP you need to edit Apache’s protected configuration file, which can be done using the terminal or an editor application like the free TextWrangler.

  • Using the Terminal, you want to backup the file before editing:
    sudo cp /etc/apache2/httpd.conf /etc/apache2/httpd.conf.bup
  • Let’s verify that the PHP extension mappings are available:
    sudo cat /etc/apache2/other/php5.conf
  • Finallly, lets edit the httpd.conf file:
    sudo pico /etc/apache2/httpd.conf
    Scroll down to this line:
    #LoadModule php5_module libexec/apache2/libphp5.so
    and remove to ‘#’ character before saving and exiting the editor with ctrl-O following by ctrl-x
  • To read the configuration again, Apache needs the be restarted. Go back into the System Preferences – Sharing and un-check and then re-checkWeb Sharing checkbox.

Apache With PHP

To see it all working, create a new text file in your site folder (/Users/username/Sites) and name it phpinfo.php

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 TRANSITIONAL//EN”>
<html>
<head>
<title>PHP Info</title>
</head>
<body>
<?php echo phpinfo(); ?>
</body>
</html>

.. and browse to http://127.0.0.1/~username/phpinfo.php

Enable PHP Code In HTML

Enabling PHP code interpretation/pre-processing in HTML files, has a minor performance impact on your server, but allows you to write PHP code inside of regular HTML pages (htm or html extension).
To enable this, we simply have to add this line to the PHP extension mappings, whose availability we had checked earlier.

Back in terminal enter:
sudo pico /etc/apache2/other/php5.conf
Before saving with Ctrl-O, the configuration file should look something like this:

<IfModule php5_module>

AddHandler application/x-httpd-php .html .htm

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

<IfModule dir_module>

DirectoryIndex index.html index.php

</IfModule>

</IfModule>

Read More