Sometimes (especially on shared hosting) Magento 2 web install just isn’t work – there is a plenty of reasons, but this post will not cover this topic, it’s about how to install Magento 2 via command line. So here is a simple shell script and hints to add some tuning to your install.
Prerequisites
First of all you need to set correct file permissions. Per Magento recommendation change directory to you magento2 install root, then change ownership and file permissions:
1 |
chown -R :www-data . |
1 |
find . -type d -exec chmod 770 {} \; && find . -type f -exec chmod 660 {} \; && chmod u+x bin/magento |
Install
Now it’s time to install magento:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
php -f bin/magento setup:install \ --db-host=localhost \ --db-name=dbname \ --db-user=dbuser \ --db-password=dbpassword \ --backend-frontname=admin \ --admin-user=admin \ --admin-password=password \ --admin-email=admin@yourhost.com \ --admin-firstname=Firstname \ --admin-lastname=Lastname \ --base-url=http://youhost.com/ \ --base-url-secure=https://youhost.com/ \ --language=en_US \ --currency=USD \ --use-rewrites=1 \ --use-secure=0 \ --use-secure-admin=0 \ --timezone=America/Los_Angeles \ --cleanup-database |
Tune your installation
If you’re using xdebug there is a known issue, so you want to change installer first line just like this:
1 |
php -d xdebug.max_nesting_level=500 -f bin/magento setup:install \ |
If you have any special chars in db password – make sure to escape them:
1 |
--db-password=\!p4ssw0rd\! \ |
If you want to use secure URL on backend – just add next option:
1 |
--use-secure-admin=1 \ |
If you using a sample data just add this:
1 |
--use-sample-data \ |
Full list of install options could be found in Magento 2 devdocs. Hope that helps.