Speed up PHP on NFS with turbo_realpath
If you run a website based on PHP, and have your source files on a network file system like NFS, OCFS2, or GlusterFS, and combine it with PHP’s open_basedir protection, you’ll quickly notice that the performance will degrade substantially. Normally, PHP can cache various path locations it learns after processing include_once and require_once calls via the realpath_cache. There’s a bug in PHP that effectively disables the realpath_cache entirely when combined with open_basedir.
Just installed VirtualBox on OS X and need the Extension Pack? This (really long) one-liner will download and install it for you. Run in terminal and enter your password once and you’re off to the races!
"Real-time" Ruby Gem Development
Recently, I’ve been working on adding functionality for Storm on Demand’s API to the excellent fog library. There didn’t seem to be a clear way, that I could find, to work on a Ruby gem in real-time, meaning I save the file in my editor and immediately run some code. Most guides I found tended to advise to create the gem file and install it. Stephen Ball demostrates the use of bundle console which drops you into irb for testing, but I was looking for a way to test my own scripts outside of a shell with my recently-saved gem files.
Usable MAMP on OS X 10.8 Mountain Lion
Install MAMP Download the latest MAMP from http://mamp.info/en/downloads/index.html and run the installer.
Choose APC Cache Open the MAMP app, open Preferences…, click the PHP tab, and change Cache to APC. Click OK to close Preferences and Quit MAMP.
PATH variable Put MAMP binaries, including PHP, in the front of your $PATH (this is a single command):
echo 'export PATH="/Applications/MAMP/bin:/Applications/MAMP/Library/bin:$(find /Applications/MAMP/bin/php -type d -name "php5.4*" | sort | tail -1)/bin:$PATH"' >> ~/.
Apache modules on OS X with Homebrew
I have long been a big fan of Homebrew, a way of adding open-source software to OS X without much of the overhead and systems link MacPorts and Fink introduce. It’s quickly become my favorite way to do PHP-based development on a Mac, and I’ve blogged before about various ways to integrate Homebrew-based software into your workflow.
In preparing new documentation for using Homebrew on 10.7 and 10.8 (coming soon to my EchoDitto blog), I wanted to find a way to run either mod_suexec or mod_fastcgi so I could use the built-in version of Apache without having to change folder ownership in random places where the web server needed to modify files.
Three ways to get Drush on OS X
As I’ve said before, we love drush. It’s hard to imagine doing Drupal work without it. If OS X is your workstation, it’s pretty simple to install with pear, as described on the project page. Let’s review that method and cover two others, git and Homebrew, and how to keep them updated.
All commands listed below are to be executed on the command line with the Terminal application. But if you use Drush regularly then you already knew that!
Never touch your local /etc/hosts file in OS X again
In each of my posts on setting up a local development environment on OS X, it’s mentioned that you need to add your website’s domain, even though it’s local, in your /etc/hosts file. My preferred way to edit the hosts file on OS X is using Gas Mask. If you wanted to create the local virtual host projectx.dev, you would add the line 127.0.0.1 projectx.dev in /etc/hosts or with Gas Mask, and then use that same value in either ServerName in Apache or server_name in Nginx.
Redirect all port 80 requests to port 8080
In my previous post, I walked through how to set up a local environment using Nginx running on port 8080 so as to avoid running anything as root or with sudo. Something that I’ve found incredibly annoying is when I forget to specify the port I get an error in my browser, or Chrome might even suggest something based on a search term. It’s fairly easy though to configure Apache to route everything to another port.
OS X 10.7 Lion Development: Nginx, PHP, MariaDB with Homebrew
Nginx is quickly becoming a popular, low resource alternative to Apache for many websites. This doesn’t come without challenges, such as using PHP as CGI due to not having mod_php available. Nginx also does not use any Apache configuration rules, nor does it use .htaccess or anything like it, so it requires additional configuration regardless of the web application being deployed. A big help in getting Nginx started with Drupal is António P.
Can I get your number? DNS made simple
At EchoDitto, we get a lot of questions about how hosting works, and in particular about changing DNS records for new websites or websites who are moving to new hosting providers. Here’s an old but true analogy to make understanding DNS easier: the IP address of your website is like your phone number (it changes if you move houses - at least, your landline does), and DNS is like the phonebook.