apache php

How to restart Apache with PHP

If you ever need to restart Apache via PHP, you’ll notice that the “passthru” command doesn’t quite work out like you thought it would. For those of you who have cpanel and WHM installed, this will be an easy solution.  cpanelmatt at the cpanel forums created an XML-API PHP class to be able to handle situations like this.

First download the XML-API PHP class.

Next, follow the code example below:


$ip = "";
$root_pass = "somepass";

$xmlapi = new xmlapi($ip);


print $xmlapi->restartsrv('httpd');