Wednesday, August 15, 2007

Apache2 + mysql5 + php5 + Mac OS 10.4 = RAWR!

More precisely: Apache 2.2.4 + MySQL 5.0.45 + PHP 5.2.3 on a Mac Pro running Mac OS 10.4.10
  • The most helpful resource I found was a 05/23/2007 carlmoonan.com blog post. So I updated it for PHP 5.2.3 and bypassed a MySQL bug. I also did some StartupItem research on macdevcenter.com (here, here, and here).

  • This should only be done if you're comfortable with unix and compiling source code.

  • In order to compile source code on your Mac you'll need the latest version of the Xcode Tools which you can find on Apple.com. It contains the Intel gcc (C++ compiler) which you will need to compile anything.

Download, Compile & Install Apache from Source

  1. Copy the following shell (bash) script and paste it into a file named "apacheBuildScript.sh" somewhere you can find it:

    #!/bin/bash

    curl http://www.mirrorservice.org/sites/ftp.apache.org/httpd/httpd-2.2.4.tar.gz > httpd-2.2.4.tar.gz
    tar -zxf httpd-2.2.4.tar.gz
    cd httpd-2.2.4
    ./configure --enable-layout=Apache --prefix=/usr/local/apache/2.2.4 --enable-mods-shared=all --with-ssl=/usr --with-mpm=prefork --enable-ssl --enable-dav --enable-cache --enable-proxy --enable-shared --disable-static --disable-unique-id --disable-ipv6 --enable-logio --enable-deflate --with-ldap --with-ldap-include=/usr/include --with-ldap-lib=/usr/lib --with-included-apr --enable-ldap --enable-auth-ldap --enable-cgi --enable-cgid --enable-suexec

    make
    sudo make install

  2. Make the file executable from the terminal:
    chmod +x apacheBuildScript.sh

    Then run it from the command line. Enter your root password when it asks (sudo).

Download & Install the MySQL Binary

  1. Grab the x86 mysql-5.0.45 binary from dev.mysql.com and run the installer.

  2. Fix the libmysqlclient.15.dylib location bug by entering the following code at the terminal:

    cd /usr/local/mysql/lib
    mkdir mysql
    cp libmysqlclient.15.dylib mysql/libmysqlclient.15.dylib

Download, Compile & Install PHP (and PEAR, a required lib) from Source

  1. Copy the following shell (bash) script and paste it into a file named "phpBuildScript.sh" somewhere you can find it:

    #!/bin/bash

    curl http://go-pear.org > go-pear.php
    sudo php go-pear.php

    curl http://uk3.php.net/distributions/php-5.2.3.tar.gz > php-5.2.3.tar.gz
    tar -zxf php-5.2.3.tar.gz
    cd php-5.2.3
    ./configure --prefix=/usr/local/PHP/5.2.3 --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/etc --with-zlib --with-xml --with-zlib-dir=/usr --with-openssl --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-sockets --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/local/Apache/2.2.4/bin/apxs

    make
    make test
    sudo make install

  2. Make the file executable from the terminal:
    chmod +x phpBuildScript.sh

    Then run it from the command line. Enter your root password when it asks (sudo).


Congratulations, you've got it all installed. But wait.... there's more!



Disable the default Apache installation

  1. Go to System Preferences > Sharing > Services and uncheck Personal Web Sharing.

Configure Apache2 to run PHP files

  1. Open "/usr/local/apache/2.2.4/conf/httpd.conf" and add the following code to the bottom of the file.

    <IfModule php5_module>
    AddType application/x-httpd-php .php .phtml
    AddType application/x-httpd-php-source .phps
    </IfModule>

  2. Also Make sure the installer correctly added "LoadModule php5_module modules/libphp5.so" somewhere else in the file. If not, you're going to need to add it yourself. You can put it anywhere, preferably bellow the other LoadModule's.

  3. Find the "DirectoryIndex" line and add "index.php" to the end

(Optional) Additional Apache2 Configuring

  1. Open "/usr/local/apache/2.2.4/conf/httpd.conf" if it's not already.

  2. Find the line with "DocumentRoot" on it and change it to the following if you want your old Apache site to work:
    DocumentRoot "/Library/WebServer/Documents"
    The DocumentRoot. It is where your web site files will go.

  3. Update and uncomment the "ServerAdmin" line with your email and the "ServerName" line with your url for good measure. Read the comments for details.

  4. NOTE: You can also use Symbolic Links to reference folders elsewhere on your computer. "ln -s origPath newPath" The newPath will link to the origPath ("s" for symbolic) similar to a mac alias. This will require the FollowSymLinks or SymLinksifOwnerMatch Apache options to be enabled for the parent directiry or globally. See the Apache options docs for more information.

(Optional) Configuring Apache2 to use the existing StartupItem

  1. Replace the old apachectl by renaming it and replacing it with a Symbolic Link to the new one.
    sudo mv /usr/sbin/apachectl /usr/sbin/apachectl.old
    sudo ln -s /usr/local/apache/2.2.4/bin/apachectl /usr/sbin/apachectl
    This way the existing StartupItem [/System/Library/StartupItems/Apache] will run Apache2 instead of the old Apache. This will also allow for starting Apache2 via System Preferences > Sharing > Services > Personal Web Sharing.

  2. If for whatever reason you need to revert to the old Apache you can redirect the symlink:
    sudo ln -sf /usr/sbin/apachectl.old /usr/sbin/apachectl
    The added "f" forces the new link to replace the old one.

  3. Edit "/usr/local/apache/2.2.4/conf/httpd.conf" again by adding the following line to the file. You can put this line anywhere, but I chose to put it after the ServerRoot line, since that's where the comments about PidFile are.
    PidFile "/private/var/run/httpd.pid"
    This will allow System Preferences to be able to detect that the server is running and check the "Personal Web Sharing" box accordingly.

Start the new Apache2 server

  1. If you've done the previous step, all you need to do is check the "Personal Web Sharing" checkbox or select it and push the "Start" button. It should tell you it's starting and grey out then complete and go solid again.

  2. If you was to start Apache2 manually you can run the following at the terminal:
    sudo apachectl start

  3. View the default web page to make sure it works: http://127.0.0.1/

Saturday, July 28, 2007

Blog 2.0

Hey Guys,

Welcome to my new technical blog. I've scrapped the mushy stuff and redesigned the look in hopes to use the site on a more professional level.

Resume will be up soon and I'm thinking of putting up a listing of my WoW addons too, but for now the blog, about and projects pages work.

Any ideas what else I should put in the side bar?

P.S. The site gets eaten alive in IE6, so make sure you're using the latest version of your browser. Upgrades are free downloads (what are you waiting for)!

Friday, July 27, 2007

Windows Vista on my Mac Pro

I've recently put Windows Vista (Business Edition) on my Mac Pro and it seems to work fine.

I obtained a free Vista key from UCI through the "msdn academic alliance" program available to ICS students. The Vista installer from msdn-aa was a downloader that required a previous version of windows. I didn't want to install XP first, so I got a Vista installer dvd disk image from a friend and burned it onto a DVD + R.

Following are some instructions for installing Vista on a MacPro, problems I had and a bit on iTunes library parsing I had to do to rebuild my collection.

Specs: 2.66Ghz, ATI X1900, 2GB RAM (OEM), 20" Cinima Display

Simple steps/instructions for installing onto a 2ndary drive:
  1. Install Boot Camp (on top of a Mac OS X install of course)
  2. Insert the Vista Install DVD
  3. Reboot (either hold 'c' to boot directly from the dvd or hold 'alt/option' and then select the dvd from the drive selection images)
  4. Install Vista (make sure you select the right empty drive to install onto)
  5. Vista will reboot your machine. You probably wont be able to hold down 'alt/option' to select a drive to boot from. So after it boots back into Mac OS X you're going to want to change your boot disk so that you wont boot back to Mac OS X for the rest of the install.
    - System Preferences > Startup Disk > Windows (on Untitled)
    (Once you're done in Vista you can change this back. To boot into Mac OS X you'll have to reboot holding 'alt/option' and select your Mac Hard Drive.)
  6. Reboot (it should launch Vista and continue the installation)
  7. Vista might restart once more.
  8. Vista will automatically download updates (if you chose the default update settings)
  9. Download & Install ATI Catalyst Vista drivers
  10. Reboot to finalize updates and driver installation



Problems:
  • My biggest problem was with hard drives. I have 3 installed, two had mac data on them. For some reason one of the currently in use disks had an "unallocated" part according to the Vista installer and I ended up reformatting my media drive on accident. While this majority sucks it was more my fault than Vistas. Just beware that the drive selection page is pretty confusing with all the small (200mb+) partitions created on each Mac OS Extended (Journaled) drive. What finally worked for me was to install onto an unformatted/unallocated drive. Also note that I was unable to get Vista to work on the drive that came with my Mac Pro (I'm using another drive for OS X booting). For some reason it would say "Drive Error" when I tried to reboot the first time after the installation, but the same steps worked fine on my other 3rd party drive.
  • The Mac XP drivers don't work on Vista so don't bother installing them. For the time being the extra keyboard buttons wont do anything.
  • Also I've heard that the Mighty Mouse doesn't work during install but works afterwards. I was using a Logitech laser mouse the whole time so I can't verify. (I also downloaded mouse drivers after the install, but only for additional mouse button features.)


Notes:
  • I downloaded and installed the C&C3 demo and maxed the settings. It looks and plays pretty fantastically.
  • Vista auto detected my home router network. So getting on the internet was fully transparent.
  • I still had the iTunes Library files, so I was able to reconstruct a list of all my music that was lost on my media drive. Re-ripping/downloading has been a pain tho.


List of iTunes Library Music by Album/Artist:
  1. Opened iTunes normally > File > Export Library...
  2. I found an iTunes XML parser online from http://www.lazycat.org/software.html
  3. I wrote a lib2list.py script that uses the iTunes.py parser to make a list of all albums with more than 1 track and print them to the console. (put both files in the same folder on your hard drive)
  4. Terminal > "python '[path]/lib2list.py' '[path]/iTunes Music Library.xml'"
  5. Copy from the Terminal into a text file if you'd like and save it.