I am a newbie to magento and am trying to install magento 2 using cli. I have encountered the following:

Script "magento" is not defined in this package

php70 /usr/bin/composer run-script -- magento setup:install - was the command I was attempting to use... I was was hoping for some detailed steps on correcting this.

2 Answers 2


You should use 'bin/magento' instead 'magento', because CLI located right there.

And you need to be inside 'web' directory.

php70 command runs script contains php code inside bin/magento.


@Rex It looks like Composer is telling you that it doesn't recognize "magento" as a valid argument. I haven't seen an installation using Composer in the way that you've used it. I've only used Composer to pull in the initial M2 application code and dependencies.

For M2 CLI installation, Please refer to this documentation for details on which parameters are required and a description of what each one does: http://devdocs.magento.com/guides/v2.0/install-gde/install/cli/install-cli-install.html .

Regarding your command, you can simply to php webroot/bin/magento setup:install --params

  • Where "webroot" is the directory in which you've installed your Magento installation.
    • An example could be /var/www/html/magento2 or /var/www/magento (or whatever you're using. This does require you to understand the "web root" directory for your chosen web server, most commonly Apache or Nginx.
  • Where "--params" is the list of parameters you've chosen to use (which are listed in the documentation link I shared with you).

Ways of using the Magento CLI:

  • If your current location is /var/www/magento2/bin , then you can run the command like ./magento your-desired-command

  • If your current location is /var/www/magento2 , then you can run the command like php bin/magento your-desired-command

  • If your current location is /tmp , then you can run the command like php /var/www/magento2/bin/magento your-desired-command

My point is that you either execute the Magento CLI like a regular executable script ./magento (you can experience permissions issues if the execution permissions haven't been set yet, so chmod +x or whatever your Linux distribution uses) or you can have Php run it with the correct path to the executable.

I hope this has helped you more than confused you.

  • For thoroughness, if you're in /var/www/magento2, you can run the command like bin/magento your-desired-command :D.
    – ryanF
    Jun 9, 2016 at 20:15

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.