Magento2 – How to Setup Magento 2.1 from Existing Project

environment-emulationmagento2

I have an existing project from my personal project repository. What I would like to do is clone this repository and setup the environment, and this is what I have done :

  • Installing php 7.0 and all the require extension.
  • Install mysql
  • install apache2
  • Set the sites-available for magento 2. and restart the apache2

now I have the project in my dir /var/www/html/myproject/.
But I don't know where to go from this like, where is the setup for mysql credential ? and other setup to make the project up and running in my local environtment.

Right now when I got to my localhost I got HTTP ERROR 500 ? any help would be appreciated.

Best Answer

For some reason I'm able to do this on my own so here is the steps Note I'm using Ubuntu 16.04 for my local env :

  1. Make sure all the file permission is your user : sudo chown -R you-user:your-user .
  2. Create your database schema. You can do this via cli or mysqlbranch.
  3. Edit your app/etc/env.php and find these file :

    array (
    'host' => 'localhost',
    'dbname' => 'yourdatabase',
    'username' => 'root',
    'password' => 'root',
    'model' => 'mysql4',
    'engine' => 'innodb',
    'initStatements' => 'SET NAMES utf8;',
    'active' => '1',
    )
    
  4. Now make bin/magento executable sudo chmod +x bin/magento

  5. This is IMPORTANT STEP : disable your additional module first, and there will only magento original module only to feed and setup the database. You can first move all your module first out of the app/code and app/design.

  6. run bin/magento setup:install --admin-user="gujarat" --admin-password="wkwkwkw" --admin-email="gujarat@balala.com" --admin-firstname="gujarat" --admin-lastname="santana". This will take forever to install.

  7. bin/magento setup:upgrade. If you have trouble in this step, this is more likely because of your custom module move all your custom module first to another directory and run this command again.

  8. bin/magento setup:di:compile

  9. Set appropriate permission files and folder.

You should see your sites now, but don't forget to move all your custum module to its respected directory. And run the upgrade and compile command from 7 & 8 step.