# Set magento deployment mode to production fails

I've installed a new Magento 2 installation with Softaculous on my hostingserver. After installation I would change the default deployment mode to production but I have the following error (using SSH):

foo@en07-phx [~/public_html/m2test/bin]# php magento deploy:mode:show
Current application mode: default.
foo@en07-phx [~/public_html/m2test/bin]# php magento deploy:mode:set production
Enabled maintenance mode
Static content deployment start
Command returned non-zero exit code:
php -f /home/foo/public_html/m2test/bin/magento setup:static-content:deploy en_US 2>&1


Anyone knows what could be wrong? Because I'm using v2.0.0.0, this might be fixed already in a newer version on Github but I'm not able to install that using softaculous and I have no clue on how to use Composer from my hostingprovider.

Edit1: Following the suggestion of @Silvan (by running the command seperately), I get the following output:

=== frontend -> Magento/blank -> en_US ===
Successful: 1965 files; errors: 0
=== frontend -> Magento/luma -> en_US ===
Successful: 1965 files; errors: 0
=== adminhtml -> Magento/backend -> en_US ===
Successful: 1843 files; errors: 0
=== Minify templates ===
Successful: 845 files modified


Edit2: This is independent of Softaculous installer because I have the same problem with a manual installation of the latest github code as of today (2016/01/12).

Edit3: Raised a github issue. https://github.com/magento/magento2/issues/2972

• Have you set file permissions as recommended? devdocs.magento.com/guides/v2.0/install-gde/prereq/… – Maddy Jan 11 '16 at 15:40
• This output looks normal. – Steve Johnson Jan 11 '16 at 18:51
• @SteveJohnson The output "Command returned non-zero exit code"? Or the single test output. I got the deployment statement running without problems on my local machine and the end output of a successful deployment is way different. – emp Jan 12 '16 at 16:12
• The test output looks normal. – Steve Johnson Jan 13 '16 at 16:27

Setting the php memory limit to 512M solved the issue.

• It is better if you set memory limit temporarily instead of change setting in php.ini. Try php -dmemory_limit=1G namespace:command – Toan Nguyen Apr 14 '16 at 8:59

Apparently something goes wrong in the statement:

php -f /home/foo/public_html/m2test/bin/magento setup:static-content:deploy en_US 2>&1


The real error is not shown (Command returned non-zero exit code). Try to execute that statement manually to see what the real error is:

php -f /home/foo/public_html/m2test/bin/magento setup:static-content:deploy en_US

• See my updated answer for results – emp Jan 10 '16 at 15:12

I had a very similar issue trying to change back to production mode.

It turned out to be because I had multiple versions of php available and where apache was configured to use v7 and I had been prefixing other commands with the correct path the magento deploy used the system version. Setting the correct path in the environment variable fixed the issue.