With PHP 5.4+ we get a built-in webserver, http://php.net/manual/en/features.commandline.webserver.php

Has anyone had luck setting this up with Craft? It seems like it could be pretty straightforward, but I am not sure how to wire up a mysql database.

In particular I am hoping to run this with Gulp/BrowserSync so that I can just fire up a livereload instance of Craft quick and easily.

On a very basic pass-through I just did, it seems to kind of work - except it just has 404 pages and a "Craft can’t connect to the database" error.

Here is my gulpfile.js for reference:

gulp.task('php', function() {
    php.server({ base: 'public', port: 8010, keepalive: true});

gulp.task('serve', ['php'], function() {
        notify: false,
        reloadOnRestart: true,
        open: false,
        proxy: ''
    gulp.watch('*.js').on('change', reload);
    gulp.watch("*.html").on('change', reload);
    gulp.watch("*.php").on('change', reload);

gulp.task('default', ['serve']);

Edit: I connected to mysql without much problem (installed using Homebrew, and connecting with, but now I am getting:

Your server doesn’t meet the following requirements to run Craft:

Mcrypt is required.

2 Answers 2


Brad Bell mentions this about Craft:

Being a self-hosted PHP web application is a hard life. Your parents try to raise you correctly and equip you with the tools necessary to successfully go out into the world and live on some stranger's unknown, unfriendly and oftentimes hostile server environment so you can serve up web pages, but things are stacked against you.

It's a great read.

I hate to be that guy, but any reason why you don't want to run something more common like MAMP? I haven't used PHP's built in server but there might be little things here and there that you'll pull your hair out over as to why your installation is functioning weirdly and it ends up being a little "quirk" with the PHP web server performing oddly with Yii or something else.

Unless you're just fooling around, it's ideal to run the same software locally as you do on a "live" web server. Some people go so far as to clone the environment they're in (like Vagrant or some other virtual machine), but MAMP works well.

I've used Home Brew and I've even compiled PHP/MySQL/Apache manually on a Mac. It's a great exercise in dependency management, using the command line, and seeing what other packages all go into PHP—there's a ton!—but that's really where it ends. The web server stack is just a tool and MAMP gives me all of that in a simple download that you can easily move/remove. If you have more than one computer, you're going to have to repeat those home brew commands on every Mac you want to test on; MAMP is 3 clicks and I have the stack.


Mcrypt is a requirement for Craft to run.

There are some general Mcrypt installation instructions and a few posts specifically about installing it for Craft.

  • I just yesterday installed mcrypt on OS X 10.10.3 with homebrew. It went completely smoothly: $ brew install mcrypt; $ brew install php55-mcrypt;. Other times it has been a nightmare, but at the moment I have everything cleanly installed with homebrew (php55, mysql, mcrypt, imagemagick, php55-imagick, php55-mcrypt) Jul 4, 2015 at 1:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.