HostOnNet Blog

PHP execute shell commands with exec

Looking for Linux Server Admin or WordPress Expert? We can help.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.