I tried to activate a module in my Magento2 system, which is on a Hosted environment without a CLI (command line /ssh shell) available. Reading around, I've learned that this could be done by using a php file like this:

//system('php bin/magento deploy:mode:show');
//system('php bin/magento cache:flush');
//system('php bin/magento setup:static-content:deploy');
system('php -f bin/magento setup:upgrade');
//system('php  bin/magento cache:clean');
//system('php bin/magento module:enable Ubertheme_Ubdatamigration');

But when I try to execute this file nothing happens. Why not? In a previous test-set-up I have been able to run this without any problems? What am I doing wrong here? Also tried to use magento/bin instead but did not help either.

  • I think something went wrong, your pasted code is missing. Please update the question with your code. Commented Oct 3, 2016 at 10:58

3 Answers 3


You can try exec instead of system, but I doubt that will work. Normally, if you don't have cli available, you don't have access to system or exec functions.
Magento 2 is not built to work with a shared host that doesn't allow you cli access.
It relies heavily on cli actions.


This will depend a lot on your hosting provider, open a ticket with them and ask about this. Some companies disable specific commands like system() shell_exec() and exec() for security reasons.

In a previous test-set-up I have been able to run this without any problems?

You shouldn't be approaching issues like this, even between servers from the same hosting company things can and might change, not to mention you should (almost) never expect a local environment to be exactly the same as the one you are using for development (thought it's easier to work when you mimic a live environment for development)


Try Something like this.

    $command = 'php bin/magento setup:upgrade';
    echo '<pre>' . shell_exec($command) . '</pre>';

I am not sure, just try it may be it will work.

  • tried this but not working for me. Also with exec instead of system no result. It is on the same server as the trial I did with the same version of Magento2 although that is in its own domain. So I will have a look at the php settings on both of the domains and see what's different.
    – mr_typo3
    Commented Oct 3, 2016 at 11:26
  • It appears that I have two versions of php running the one thats working has 7 and the one that's nog working (having system and exec not allowed) is 5.5 so I will install again with 7 and see what happens
    – mr_typo3
    Commented Oct 3, 2016 at 11:35
  • Have you check first exec function enable from php extension ? Commented Oct 3, 2016 at 11:55
  • No did not do that. I managed to get the module working in a temp. shop on the same php7 server. Now I could import the old products etc. with the ub_data migration module. Than later on I will move the complete shop to the desired shop domain which than will be updated to run on php7 as well. Having a Magento2 shop on a Hosted environment is not funny :) I advise to avoid that if possible.
    – mr_typo3
    Commented Oct 3, 2016 at 13:00

Your Answer

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

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