PHP development server

kamal's picture

One thing that I like in various Python frameworks such as Django etc, they come with built-in development server that allow you to start developing the application without worrying much about properly setting up apache and all sort of things regarding deployment. Though personally, I'd prefer developer to have some knowledge in configuring apache (at least in their local environment) having some sort of development server still being useful even for myself. Everytime I need to start working on new applications, I have to create new apache virtual hosts, edit my /etc/hosts to short circuit the domain until at certain point demotivate me from working on new things.

One way to avoid this is to just use UserDir directive in apache and put all stuff under that directory. I'm not a fan of this. UserDir does not really simulate the real environment once the apps need to be deployed. Most of the time problems related to path would popping up when you start deploying that things.

At first I try to look into WPHP which I've used in the past to run Dokuwiki locally on my laptop. The idea is to start a simple python webserver which would start a PHP process running as FastCGI server and then passed all .php files to that instance for processing. But the fact that it require certain modules from Paste make it not a good fit for my need. I need more lean solution, if possible in just single module so it easy to be dropped in any project that need it.

At the end, inspired by Webfaction apache stack, I just created a simple script that start another apache process for that particular app. Apache is very limited when it come to the number of command line options that you can pass to httpd executable so I have to generate a config file when starting the server. Unlike Webfaction setup which copied everything to the user's directory and changed the ServerRoot directive, I still used the system wide apache stuffs.

I've kept that script in my BitBucket wiki for references:-

http://bitbucket.org/k4ml/notes/wiki/php/DevelopmentServer

Comments

angch's picture

Ditto PostgreSQL.

If you find you need to test several versions of PostgreSQL, pg_control can and should be used to start a local copy of pgsql running on a different port. This allows you to start your own db server when and only when you need it, allowing you to tune several different parameters. As a bonus, mutually incompatible postgresql server settings, e.g. fsync = on|off can be implemented on the same server.

In this case, your application can and should create it's own instance of postgreSQL master with it's own authentication and table spaces, and can be started and shutdown for maintenance (backup along with your application may be a good idea), without affecting other instances on the same machine.