Mac OS X strives to better itself than most in application and operating system simplicity. Updating some of the more basic management systems for OS X server can still boast troublesome for an environment built on coupling open source applications. Below is a recent walk through to install a clean PHP, MySQL & Subversion environment for Tiger Server.
PHP 5
PHP was a relatively painless installation, thanks largely in part to Marc Liyanage’s Entropy:PHP Package InstallerFriends at Apple admit that even they forgo the stress of compiling PHP for Entropy’s installer. The upside is you get a DMG installation method that allows customization of packages on click – the downfall is that it’s missing a few beneficial extension of PHP that, like me, find a necessity (PSPell is the most obvious as I refuse to use Google’s Spelling system on a web app. Opening a hole through my secure application to google smells and feels like an unnecessary weakness. PSPell allows integration of dictionary/spelling services within your application in realtime; such as checking spelling for people automatically on submit, ajax spell checker, etc). Regardless, the ease of update and future benefits outweigh the negatives. Installation and/or update is as follows:
- Download the installer for your version of Apache - current OS X Tiger runs with 1.3 as it’s default, though 2 is a large improvement and I look forward to migrating in the near future (slated for leopard). You should NOT use a version of PHP lower than 5.1.4 because of significant bugs in 5.1.3 and down – the current version is 5.2.x so you should be just fine unless you specifically choose an older file for some reason that I couldn’t fathom. As a pre warning, some code may not run fine from 4 to 5 and you should be ready to adjust your code if needed (though if you were using good habits, it shouldn’t be a problem). Smart tag features are also off by default, but you can turn it on in the php.ini files later (why no smart tags? Since multiple languages use the same smart tags, you’re setting yourself up for future issues with script compatibility – besides, you’re not a lazy coder are you?).
- Stop the Web Server. Do a backup. While the PHP installation shouldn’t be an issue, this is always a good fail safe just in case, but do I even have to warn you server admins about that, now did I?
-
Disable PHP 4.
It’s simple to do this in the GUI; open Server Admin, select Services, Web, Settings, Modules – uncheck php4_module, save it. You can also do this in the Apache config files by commenting out the PHP 4 module. Go to Private/etc/httpd/, open up the httpd.conf file, comment out the PHP line:
LoadModule php4_module libexec/httpd/libphp4.so
You comment these lines out using a #:#LoadModule php4_module libexec/httpd/libphp4.so
You can also delete the line, but it’s good measure to keep it around just in case. - Run the installer as you would any disk image, clicking options to check or uncheck any necessary packages to include in your version of PHP (if you don’t know, selecting them all is probably fine with the exception of ‘commercial’ labeled extensions). This will automatically create the new folder for PHP in usr/local/php5. Adjustments to your PHP preferences are then in usr/local/php5/lib/php.ini
You may now start the mail server if you want to verify and you’re done here. To test your version of
PHP, add a test.php file to any website you have hosted and put in the following code:<?php php_info() ?>
More on extras to that command here:http://us2.php.net/php_infoIf you have issues connecting to your
MySQL
system right off the bat, you may fall victim to missing location for your mysql.sock file. This install tutorial, though for 10.4.8, is exact to mine above but with a workaround for your mysql issues:Entropy User forum installation for 10.4You’ve got
PHP
5. Let’s move on to MySQL where things are slightly more cryptic.
MySQL
In an effort to show their love for the community, MySQL has spent much of their time developing quality tutorials and installers for just about every flavor; but it’s definitely geek speak. You can download the installer for your version of OS at:MySQL packaged installers5.1 is in Beta, 6.0 is in Alpha. Not recommended for a production server. Directions provided by MySQL for OS X are available at:Mac OS X installation
- Download the installer for your OS and MySQL
- Stop the Web Server.
-
Export all your MyQSL Databases in one full swoop (assuming you have databases, if not, skip these export/import steps)Log into terminal’s mysqldump and export all databases:
mysqldump --all-databases > all_databases.sql
change the ‘all_databases.sql’ to the location and file name you want, it could also be:mysqldump --all-databases > Users/bradyjfrey/Desktop/bradysmysqlfile.sql
If you receive a rejection or general error… you’ve most likely password protected your MySQL like every good administrator should! Don’t worry, we’ll walk through defining a master password later, but for this tutorial on I assume you have password protected MySQL. The first command with request for user and password:mysqldump -u root -p --all-databases > all_databases.sql
- Stop Mac OS X’s default MySQL installation (if you don’t wish to use command line, use the Applications > Utilities > MySQL Manager). Do a backup if you already haven’t… and you’re paranoid. This is a good time to turn off the auto start for the OS X version of MySQL right in that manager too. You’ll not use this application again, so feel free to quit and undock if you prefer.
- Run the MySQL installer for your version and operating system previously downloaded.
-
Start your new MySQL automatically from now on:
/Library/StartupItems/MySQLCOM/MySQLCOM start
That is assuming you installed the startup item like they, and I, recommend in the System Preferences pane - Turn on MySQL using the preference pane
-
Give your root mysql user a secure password:
mysqladmin -u root password "brady4ever"
-
Import BACK all your databases in one full swoop:
mysql -u root -p < Users/bradyjfrey/Desktop/bradysmysqlfile.sql
-
Check your Databases for migration errors. Some old school MySQL 4 code won’t fly on MySQL 5 – luckily, there’s a command to both check everything and autorepair if need be. This is again assuming you’re logging into your mysql as root and you have a password. First, let’s check without repair:
mysqlcheck --user=root --password --all-databases;
It should run through all the databases and note any unusual errors or issues after prompting you for a password. If you feel comfortable that these are minor issues which don’t require personal care, you can have it repair itself:mysqlcheck --user=root --password --all-databases --auto-repair
Troubleshooting your databases
For the most part, everything is exported/imported back with your
MySQLdump… except users and/or user preferences. MySQL does not offer a clean upgrade service, so every fresh installation of MySQL will require the above steps – if you can’t connect to your databases via ‘localhost’ or ’127.0.1.1′ or any other IP/DNS you use to connect to databases, it maybe that you didn’t add your users back to MySQL.Users for the most part can be added with limited access to specific databases per your choice during, or after the creation of a database. If I wanted to add ‘brady’ as a user to my database ‘maccentricsolutions’, I would:grant all privileges on maccentricsolutions.* to 'brady' identified by 'brady4ever' with grant option;
It’s also just as acceptable for the average MySQL user addition via:grant all privileges on maccentricsolutions.* to 'brady' identified by 'brady4ever';
Follow up any user command with:flush privileges;
If, like me, you have
many
databases and don’t want to go through the task of defining a user for each one, feel free to apply a global application of the user privilege. This is done by replacing the database name and using an asterisk (similar to a wildcard DNS):grant all privileges on *.* to 'brady' identified by 'brady4ever' with grant option;
For shortcut information in terminal, and other startup information, read:Mac OS X Installation via MySQLMySQL‘s done.
Subversion
is a cake walk.
Subversion (or commonly nicknamed SVN)
Subversionis a blessing for designers who know code or coders who know nothing of design. It allows development collaboration with easy tracking and migration of changes (and with Trac, it’s even easier). Installation can be done in a few ways, and you’ll need to install the current version of Xcode should you choose the terminal route ( Xcode is beneficial to install for other developments regardless of your installation method for Subversion). The current version is 1.4.3 – but a commonly used version is 1.3.x. It’s important to note that 1.3 DOES NOT work with 1.4, it’ll lock you into that version and future migration will be difficult, albeit it is still stable and very powerful. 1.4 provides back/forward compatibility, so it is recommended. Your options:
- You can download an old 1.3.1 package installer from:http://metissian.com/projects/macosx/subversion/Similar to Entropy’s installers, but there’s no 1.4 version installer as of this writing
- Use Fink:http://pdb.finkproject.org/pdb/package.php/svn
- Command line, baby, via Hivelogic
And to tell you the truth, the command line is such an easy thing to do here, I’d suggest it for even entry level command line geeks:
-
As
Hivelogic
easy peasy tutorial notes, define your installation path for the root user in the secure usr/local folder if you haven’t already. He notes you can use textmate for in command line via
mate ~/.bash_login
you can also usepico ~/.bash_login
orvi ~/.bash_login
orbbedit ~/.bash_login
Web developers may also SFTP into their web server as root, and can open the file up in your favorite editor so long as you have invisibles, well, visible. -
add:
export PATH="/usr/local/bin:/usr/local/sbin:$PATH" to your .bash_login
-
download Subversion:
curl -O http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gz
-
download it’s extras:
curl -O http://subversion.tigris.org/downloads/subversion-deps-1.4.3.tar.gz
-
unpack (or ungzip tar) them:
tar xzvf subversion-1.4.3.tar.gz
tar xzvf subversion-deps-1.4.3.tar.gz
-
get in that subversion folder:
cd subversion-1.4.3
-
Configure the installation (here’s where you should have had xcode installed prior)
./configure --prefix=/usr/local --with-openssl --with-ssl --with-zlib
-
Put it together:
make
- Install it:sudo make install
-
get back to the root folder if you’d like:
cd ..
You’re done, enjoy your update! If you have any questions, contact Brady at your convenience!