How to install magento 2.x.x in a shared hosting

Magento2 e-commerce

There are a couple of guides on how to install Magento 2.X.X when you have a dedicated machine, however, I struggled quite a bit to install it in a shared hosting (where you do not have root privileges).

How to install magento 2.x.x (2.1.0 in this case), with [or without] the sample data, in a shared hosting, using SSH:

  1. Download the archive file from the Magento website with the sample data (or without the sample data, if you don’t want it);
  2. Upload the zipped files to a folder in your shared hosting (ex; ~/magento_zips)
  3. Open up an SSH connection to your shared hosting;
  4. Extract the Magento Sample Data Zip File:
     mkdir -p ~/www/mynewmagento2 && tar -xzvf ~/magento_zips/Magento-CE-2.1.0_sample_data-2016-06-23-02-34-07.tar.gz -C ~/www/mynewmagento2 
  5. Create the database mydbmagento2 and the username mydbmagento2_usr with the password mypassword
    1. This can be done using CPanel;
  6. Grant all previlleges to this user, mydbmagento2_usr, for this database (using CPANEL);
  7. In the ssh command line, go to the magento folder (~/www/mynewmagento2) and run:
     time php -dmemory_limit=6G bin/magento setup:install --base-url=http://yourmagento2url.com/ \ --db-host=localhost --db-name="devavrne_lrv2" --db-user=devavrne_lrv2usr --db-password=Password0 \ --admin-firstname=Magento --admin-lastname=User --admin-email=quakerula@gmail.com \ --admin-user=avr --admin-password=Password0 --language=en_GB \ --currency=GBP --timezone=Europe/Lisbon --use-rewrites=0 
  8. No files were added to the folder pub/static for some reason, so change its permissions running the following:
     
    find ./pub/media -type d -exec chmod 777 {} \; 
    find ./pub/static -type d -exec chmod 777 {} \; 
    
  9. Deploy the static content:
      bin/magento setup:static-content:deploy en_GB 
  10. This one is needed for the admin UI:
     php bin/magento setup:static-content:deploy en_US 

 

This should have done it! If you try to access http://yourmagento2url.com you should be able to access your Magento store with version 2.x.x.

 

Some resources that helped me:

  • https://firebearstudio.com/blog/magento-2-installation-guide.html
  • http://devdocs.magento.com/guides/v2.1/install-gde/install/cli/install-cli.html
  • http://devdocs.magento.com/guides/v2.1/install-gde/install/web/install-web.html