Room 118 Solutions - Web Application Development & Programming

Running Apache alongside Pow on OSX

Starting with v0.4.0 of Pow, you can proxy virtual hosts to different ports. We can take advantage of this such that my-php-app.dev can point to Apache while Pow handles your Rack/Rails apps normally.

Apache Setup

We need to get Apache listening on a port other than 80, as Pow uses port 80, and then tell Apache how to map our domain names (my-php-app.dev) to the folder that holds that app.

Create a new file /etc/apache2/other/pow.conf and give it the following contents:

Listen 8080
NameVirtualHost *:8080

<VirtualHost *:8080>
  ServerName *.dev
  VirtualDocumentRoot "/Users/your-user-name/Sites/%-2"
</VirtualHost>

Note: You may need to use sudo to save the file.

First we’re telling Apache to listen on port 8080 too. Pow uses port 80, so we have to pick another port that Apache can listen on and have Pow proxy to.

Next, we tell Apache we want to use name-based virtual hosts for our new port.

Finally we tell Apache how to turn a domain name into the folder that stores our application. If you store your applications in a different folder, just change the path given in the VirtualDocumentRoot directive to match your setup.

Now you can restart Apache with:

sudo apachectl graceful

Apache is now ready to serve requests proxied by Pow.

Pow Setup

To add your application to Pow, rather than creating a symbolic link like you would for a Rack/Rails app, we need to create a file with the port that Pow needs to proxy to for Apache.

If the folder that holds your application is named my-php-app, just create a file in ~/.pow named my-php-app and the port number we chose above (8080) as the contents:

echo 8080 > ~/.pow/my-php-app

You should now be able to open http://my-php-app.dev in your browser and see your application!

Repeat the Pow steps for each application you would like to have Pow support.

Chris Gunther

About Chris Gunther

Chris has been developing for the web for over four years, but began tinkering with PHP and Visual Basic long before. Originally getting his start in PHP, he's now rediscovered his passion for programming with Ruby on Rails. His dreams are sometimes haunted by the semantics of his latest markup.

When he's not coding, Chris can be found taking in a Yankees game, cheering on the Jets, learning new chords on the guitar, or cycling all around town.

View all posts by Chris Gunther →