content top

Installing Tomcat 7.0.x on OS X

Installing Tomcat 7.0.x on 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 (Lion) however, Java is initially not installed anymore. You can find the installer on Apple’s support side here or follow this installation guide, provided by Adobe. Whatever you do, when opening Terminal and running java -version, you should see something like this.

java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-383-11A511)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-383, mixed mode)

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

Read More

Installing Tomcat 6.0.20 on OS X

Installing Tomcat 6.0.20 on OS X
  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

Installing Maven on 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

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]

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

Running MySQL 5.1 on Mac OS X Client

Running MySQL 5.1 on Mac OS X Client

Mac OS X 10.5 Server comes with the MySQL pre-installed. However, the database server doesn’t ship with the client version of OS X 10.5 Leopard, which most of us Mac users run. Here are the notes I took, putting MySQL 5.1 on a 2 GHz Intel Core Duo based iMac (none 64 bit) running OS X 10.5.2 (Client)

Installing MySQL 5.1 On OS X 10.5 (Leopard) Client

Download the pre-compiled module package in form of a diskimage (dmg), available at http://dev.mysql.com/downloads/mysql/ For the 2 GHz Intel Core Duo based iMac, I downloaded the 32-bit version mysql-5.1.23-rc-osx10.5-x86.dmg. Newer Macs, featuring a Core-2-Duo processor should work best with the 64-bit version.
Open (double-click) the dmg file, followed by running (double-click) the mysql-5.1.23-rc-osx10.5-x86.pkg package installer.

The package installer will install the mysql into /usr/local/mysql-5.1.23-rc-osx10.5-x86 and also create this shortcut /usr/local/mysql/

Installing the Preferences Pane won’t do us any good, it does not work anymore with OS X 10.5. Instead, the launchd mysql.plist file needs to be created and stored in /Library/LaunchDaemons/ and also given ownership to root:

sudo chown root:wheel /Library/LaunchDaemons/mysql.plist

mysql.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>GroupName</key>
<string>mysql</string>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>Program</key>
<string>/usr/local/mysql/bin/mysqld_safe</string>
<key>UserName</key>
<string>mysql</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

This command line can now be used to start MySQL:

sudo launchctl load /Library/LaunchDaemons/mysql.plist

and to stop it:

sudo launchctl stop mysql
sudo launchctl unload /Library/LaunchDaemons/mysql.plist

From now on, the MySQL Server will be started at boot time and (re-)starting should not be necessary anymore. Here, a check was done with the ActivityMonior, showing MySQL running:

Entering this command line after starting the server, /usr/local/mysql/bin/mysql should produce an output something like this:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.23-rc MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

.profile

Adding /usr/local/mysql/bin to the ~/.profile provides easier access to all of MySQL’s tools.
E.g. use pico ~/.profile to insert this line into your shell profile:
PATH=${PATH}:/usr/local/mysql/bin

Setting root user’s password and creating more users

Since the MySQL’s root password is not set by default, this is one of the 1st things that need to be done like so:
mysqladmin -u root password myPassWord
Instead of using the command line, more users can now be added using a GUI tool like DbVisualizer

Using MySQL with PHP

PHP on OS X 10.5 is looking for mysql.sock at /var/mysq/mysql.sock. However, the mysql installer puts it at /tmp/mysql.sock. Creating the directory and a symlink, seem to be the best way to work around:

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Read More
content top