HostOnNet Blog

PHP execute shell commands with exec

PHP exec command is used to execute system commands.

I wanted to run “composer install” on a server with out SSH access. I created following script, uploaded to server.

<?php

set_time_limit(0);
error_reporting(E_ALL);
ini_set('display_errors', '1');

$cmd = "chmod -R 755 ushahidi-platform-release-v3.7.1";

$result = exec("$cmd 2>&1", $result2);

echo "<pre>";

print_r($result);
print_r($result2);

phpinfo();


Posted in PHP