MySQL

Drupal on Mountain Lion (OS X 10.8)

The instructions still need some work. I'd did some updating but haven't tried using it with a clean install yet. After reading this it sounds like there's some bigger changes. I've also been trying to switch from macports to homebrew so that'll also mean some changes to this.

Install XCode

Install XCode from the App Store. Run Xcode and open its Preferences (⌘+,) select the Downloads tab and then the Components sub-tab. Click the Install button on the Command Line Tools component.

Install MacPorts

Follow the directions to install Mac Ports.

Become root

To follow these instructions you need to be running as the root user using the default sh shell. If you've got administrator permissions you can open up a Terminal window and switch users using the sudo command then provide your password.

amorton@minivac:~% sudo su
Password:
sh-3.2#

Install MySQL

Use port to install MySQL:

/opt/local/bin/port install mysql55-server

You'll need to create the databases:

sudo -u _mysql /opt/local/lib/mysql55/bin/mysql_install_db

Let launchd know it should start MySQL at startup.

/opt/local/bin/port load mysql55-server

Secure the server and set a new admin password:

/opt/local/lib/mysql55/bin/mysql_secure_installation

Create a configuration file:

cp /opt/local/share/mysql55/support-files/my-large.cnf /etc/my.cnf

Edit /etc/my.cnf using your editor of choice and make the following changes to the [mysqld]:

  • Change the maximum packet size to 16M:

    max_allowed_packet = 16M

Drupal on Lion (OS X 10.7)

I was half way done adding some info how to setup pecl/pear to my guide to running Drupal 6 on OS X 10.6 before I realized I'd been running Lion for almost nine months. So it seemed like a good excuse to update it for Lion. These might be a little wonky since I did an upgrade rather than a clean install so if you notice anything please drop me a line.

Note:I'll save you the trouble of commenting, I am familiar with MAMP but would rather punch myself myself in the face than use it. If you'd like to, go right, but I'm going to continue to compile my own so I know where everything ends up.

Setup Drupal 6

The station's website will be build using Drupal an extremely powerful, open source content managment system written in PHP.

Drupal uses some PHP functions that require the installation of additional ports. You'll need:

  • devel/php5-pcre - Perl regular expressions.
  • textproc/php5-xml - XML parsing.
  • textproc/php5-simplexml - Simple XML.
  • databases/php5-mysqli - MySQL support for PHP.
  • www/php5-session - Session support.
  • ftp/php5-curl - cURL support.
  • graphics/php5-gd - Image handing. Optional, some modules need it.
  • converters/php5-mbstring - Unicode support. Optional, but Drupal prefers that it be installed.

Drupal 6 on OS X 10.6

Running Drupal on OS X 10.5 was a pretty huge pain in the ass. It's much easier in in 10.6 since it includes PHP 5.3 with GD and the PDO out of the box. And Drupal 6.14 resolves the PHP 5.3 incompatibilities.

In this guide I'll walk through the process I used for reinstalling OS X, then installing MacPorts and using it to install MySQL.

Note: I've shortened this up a bunch since it was first posted (originally it was using PHP 5.2 from MacPorts). I also want to make it clear that I am familiar with MAMP but would rather punch myself myself in the face than use it. If you'd like to, go right ahead since it's probably easier—and as evidenced by the commenters below—you're in good company. But I'm going to continue to compile my own so I know where everything ends up.

Getting PHP + GD + pdo_mysql working on OSX 10.5 (aka recompiling everything)

This guide walks through the steps necessary to setup PHP on Leopard in order to run the HEAD version of Drupal. The basic steps are installing several prerequisites then recompiling Apache and PHP from source. It could totally bork your system, I'm just writing it down so the next time I need to do this I can remember what I did. I wish I could give credit to all the places I stole bits from but I didn't do a good job of keeping notes early on.

Every time Apple releases a security update it seems to end up overwriting PHP or Apache and I end up revisiting these instructions. Since it's my personal guide I'm continually modifying it to match my current needs. For example, the last big change was adding in old mysql extension and the new PDO-mysql extension. The upside for you, kind reader, is that this keeps the instructions up-to-date. The down side is that when you come back in two months and try to repeat one part of this it may not work because I've changed some of the earlier steps.

Last Updated: August 26, 2009

Sorting numeric values stored in character fields with views.module

I spent a good chunk of time this morning trying to figure out how to get the views module to sort a character field with numeric data correctly. The audio module has a normalized table of meta-data meaning that there's one column for the tag name and one for the value. The value is stored as a character string which causes problem when sorting numeric data like the track numbers or years. If you've got a SELECT value FROM audio_metadata ORDER BY value that returns the range of numbers 1...13 it ends up sorted as 1,10,11,12,13,2,3...9. The trick as I discovered is to add zero to the field to coerce it to a numeric value: SELECT value + 0 AS v FROM audio_metadata ORDER BY v.

The problem then is to figure out how to get the views module to generate this bit SQL to get the sorting right. The solution I came upon is when defining the field set 'notafield' to TRUE and provide a 'query_handler' to generate the correct SQL. I've included the relevant parts of the audio module below to demonstrate how it works. You can see the complete code here.

Installing MySQL Server on Windows

Download

The first step is to download the MySQL Server "Windows Essentials" binaries from the MySQL website at http://dev.mysql.com/downloads/mysql/. At the time this was written last updated, 5.1.46 was the latest, stable release. The file was named: mysql-essential-5.1.46-win32.msi. Make sure you save the file to a location on your hard drive where you can locate it.

Setup Apache and MySQL

To run the website, we'll install a database, webserver and scripting language. You'll need to install the following ports and their dependencies:

  • databases/mysql51-server - MySQL server
  • www/apache22 - Webserver
  • lang/php5 - PHP

Setup Drupal 5

The station's website will be build using Drupal an extremely powerful, open source content managment system written in PHP.

Drupal uses some PHP functions that require the installation of additional ports. You'll need:

  • textproc/php5-xml - XML parsing.
  • databases/php5-mysqli - MySQL support for PHP.
  • www/php5-session - Session support.
  • graphics/php5-gd - Image handing. Optional, some modules need it.
  • converters/php5-mbstring - Unicode support. Optional, but Drupal prefers that it be installed.
  • www/drush - Drupal command line tool that helps automate many common tasks.

HOWTO: A FreeBSD radio station web server

This HOWTO walks you through the process of building a FreeBSD server to put a radio station on the internet. When you're finished you'll have a:

This is the setup pioneered for use by KPSU, a college radio station in Portland Oregon, to stream and archive our broadcasts on the internet. I've released the code as the Drupal Audio and Station modules. You can find a list of some of the websites using the Station module.

All the software is free and open source. The only thing you've got to pay for is your time and hosting. While the details are FreeBSD specific, the general setup can be used for any UNIX like OS.

First, setup FreeBSD, use the handbook for that. Sorry to be so vague on details but that part of the setup is going to vary greatly depending on your hardware. The handbook will do a better job of explaining it than I could hope to do.

Once you've got a running server, start making your way through the following pages:

Syndicate content