Start and Stop Mongrel with PHP
Recently I was working on building a small application management app for my local server on my MacBook called LAWM and since I’m learning Ruby on Rails I wanted a quick way to start and stop Mongrel instances. It’s really simple to start and stop Mongrel instances using PHP’s exec() function. You probably wouldn’t want to use this code on a production site and leave it for local servers. With exec() you may have to adjust the ownership or permissions on the project’s folder before this will run correctly.
Starting a Mongrel daemon:
exec('cd {project_directory} && mongrel_rails start -d);
Stopping a Mongrel daemon:
exec('cd {project_directory} && mongrel_rails stop);
For more information on PHP’s exec function visit it’s PHP manual page.