Lion comes with Apache and PHP installed. We just need to enable PHP, install MySql and create a database, then download drupal.

Enable PHP

My new laptop which came with Lion has PHP 5.3.15, using the test page we’ll build below you can verify you’ve got a good version of PHP to go with the Drupal you need:

  • Drupal 6: PHP 4.4.0 or higher (5.2 recommended).
  • Drupal 7: PHP 5.2.5 or higher (5.3 recommended).
  • Drupal 8: PHP 5.3.10 or higher.

Commands below use vi (of course, you should use your editor of choice). (thank you stackoverflow)

You’ll need sudo to edit the Apache config file:

 
sudo vi /etc/apache2/httpd.conf

uncomment the following line:

LoadModule php5_module libexec/apache2/libphp5.so

On the following line change _www to the username you log in with:

User _www

By default, Apache only loads index.html, so update that line to:

DirectoryIndex index.html index.php index.htm

Restart apache on the command line

sudo apachectl restart

Now, let’s make a test file:

cd ~/Sites
mkdir php-test
cd php-test/
vi index.php

Then paste in this test file and browse to http://localhost/~yourusername/php-test/

Install MySql

I like to install everything with homebrew which is my favorite package manager for osx. It keeps everything in /usr/local/ by default, and then I don’t have to remember where GUI installers put everything.

 
brew install mysql

I like to have MySql always start up, so I use a Launch Agent, which homebrew describes how to do after the install:

To have launchd start mysql at login:
    ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
    mysql.server start

Now make a database:

mysqladmin -uroot create drupal_dev

The default way this is set up is for a dev environment, so there’s no password and root has full access. You can see this in the mysql console:

mysql -uroot
show databases;
show grants;

Now we need to fix the PHP configuration to refer to mysql correctly so we don’t get PDO errors (thanks Hiraash):

sudo cp /etc/php.ini.default /etc/php.ini
vi /etc/php.ini

replace all instances of /var/mysql/mysql.sock with /tmp/mysql.sock
and restart apache

sudo apachectl restart

Download Drupal

I followed the drupal.org instructions, but you need to go find the right version. As of this writing, 7.22 is the recommended v7 release, which is what I’ll be working with.

cd ~/Sites
wget http://ftp.drupal.org/files/projects/drupal-7.22.tar.gz
tar -xzvf drupal-7.22.tar.gz
rm drupal-7.22.tar.gz

Now, I’ll just rename it to be the same name as the database we set up:

mv drupal-7.22 drupal_dev

browse to http://localhost/~yourusername/drupal-dev and proceed with the install wizard

step through the wizard and drupal sets itself up.

I first met Doug Englebart in late 1997 or very early 1998, when my friend and mentor Harry Chesley and I went down to SRI to hear him speak. I was awed by his early breakthrough work. (If you have not seen “the mother of all demos,” set aside some time to watch it in its entirety — for now, you can checkout some highlights.)

I remember afterwards Doug saying “everyone thinks it is great being a visionary, but the problem with being a visionary is that no one ever knows what you are talking about.” At the time, I was awed that in 1968, Doug had not only foreseen, but had built systems that would gain widespread use 20-30 years later as personal computers became ubiquitous. Of course, Alan Kay is correct in saying that “the best way to predict the future is to invent it.” Doug laid the foundations for the modern graphical user interface. At the time, I thought that was his vision and life’s work. I learned later how wrong and short-sighted I was.

I had the pleasure of meeting Doug Engelbart again in 2002, when Kevin Lynch had the brilliant idea of inviting Doug to attend the launch event of Flash video (then called the Flash Communication Server, later Flash Media Server). The event would be held in New York city and Doug was invited to attend remotely using our two-way video tech.

I eagerly volunteered to stay home and run tech support for Doug. His Augment system predated our efforts by almost 40 years and included more features. It was humbling. As the event began, Kevin had a couple of other items on the agenda before the big finale with Doug. Kevin talked about how we need to be mindful and respectful of our critics. Doug and I were listening in (on mute) from his home in Atherton. Macromedia had made great efforts to address concerns raised most vocally by Jacob Nielson, who had written scathing criticisms of Flash. At which point, Doug said to me: “Jakob never liked my work either.” Mike Chamber, who was there in New York, tells the story of what came next as witnessed by the audience:

“Kevin then talked about some of the pioneering work done in computers in the 50’s and 60’s, and introduced a clip of a presentation by Doug Engelbart, and his famous 1968 video of distributed collaboration and real-time video in a graphical computer.
It is really hard to describe the excitement and electricity in the audience while viewing the clips…
We showed the introduction to the presentation, and Doug typing on the screen, and then a clip where he was collaborating with someone remotely (using text and video!).
Kevin then opened up a Flash Communication Server application, which linked him and Flash Forward to Palo Alto, California and Doug Engelbart. When he came through on the video, the audience gave the loudest and longest applause of the morning.
Doug talked about how after he got engaged, he realized he didn’t have any long term goals. He decided that he should dedicate himself to making a positive difference to humankind, and that one way to do that would be to figure out a way to make communication and collaboration easier. Doug, who has actually used director in the past, said that he would like to see applications that make it simple to connect users via video, and then archive and search that video (as easy as searching and indexing text on the web).”
Mike Chambers blog, July 2002

Doug had been a radar operator during World War II and it struck him that these new machines had phenomenal power to collect data, and foresaw that our ability to collect information would surpass our ability to understand and make good decisions based on that information. The goal of the system that he designed and implemented was to “augment human intellect.”

Later, when I went down to Atherton to pick up some things we had left at Doug’s house, I brought Jonathan Gay, who had built the original Flash Player and who I worked for when I led the Flash video team. Flash video was Jon’s inspiration — he coded the first prototype with Slavik Lozben. Like Doug, Jon had the ability to envision the future and write the code to get there.

Jon asked Doug whether he still had the first mouse. At which point, Doug brought us into his study, where he had an Augment system still running. It had been ported over the years and was running emulated on a PDP11 or something similarly archaic to my modern experience. An old personal computer ran as a client desktop. The mouse was designed to be used by one hand, and there was a chorded keyboard which allowed him to type with a single hand as well. The system supported full version control of all documents and links between them. An email could link to a source code file or written report, and the recipient could jump directly to the reference in the correct version of the file.

Doug told us that all of the innovations that he had built and subsequently inspired were merely the tools that he had needed to begin his work. He had barely scratched the surface of what would be required. Then he looked at us and said. I won’t finish this in my lifetime. It’s on you now.

Doug inspired me to pay attention to my visions of the future that might seem outlandish or unattainable. Although I might not get there in my lifetime, it is worth pursuing the larger goal of turning our technology into truly powerful tools for human’s to solve the very real and urgent problems of our world. I set out to learn how to reverse engineer my crazy visions — to connect the dots from the hypothetical sci-fi future to the primitive tools we have today.

Somehow we must find a way to do more than make data and compute power available. We must create the tools that allow people to use that data effectively, to learn, to understand, to collaborate and solve real problems — to turn data into knowledge, and from that knowledge gain wisdom.

When learning a new web technology, I believe it is important to have hands-on experience from development to deployment. I chose Open Shift, one of the recommended cloud deployment options for Drupal 7. It’s free for 3 small instances, which seems perfect for experimentation.

I used the very simple web UI to create a Drupal 7 instance:

Note: Just like Heroku, you can’t write to the file system with open shift, so by default the Drupal install is “not scalable.” However, there’s documentation about how to configure it so that it would be scalable if you don’t need file upload — not sure why they wouldn’t just do that by default.

Next there’s a screen that provide credentials for the app, and a link to my new instance:

Woo hoo! I can log in with the default credentials (admin / openshift_changeme ) and see the default Drupal admin UI:

If you go to “People,” you can find your admin user and change the password. Of course, I’ve done this on my instance, so you can’t log in — you should go make your own!

Dev Setup?

I already had an account that I had experimented with for Ruby, but it was some time ago, so I needed to reinstall the local tools and setup:

1. requires git and ruby (since its “rhc” tool is a gem) — I’m using rvm with ruby 1.9.2
2. to setup client tools, as well as ssh key and a token locally for automagic auth:

rhc setup 

3. clone the repo

git clone ssh://51d..183@drupal7-ultrasaurus.rhcloud.com/~/git/drupal7.git/ openshift-drupal7
cd openshift-drupal7 

Not clear what to do from here. The OpenShift forums provides the hint that I can take a snapshot of files with

rhc snapshot save -a {appname}

but that doesn’t hint at a dev workflow.

I do want to figure out a nice workflow to develop locally and deploy on a free cloud. I’ve played with Acquia Desktop. MAMP has been recommended. I’d be more comfortable with “brew install …”

I will post this for now, in case any of you readers can clue me in or point me to some good install docs. I’ll update this post once I figure out something I like. Thanks in advance.