1

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.

3 Answers 3

1

Follow below steps to setup existing magento 2 project.

  1. Import Database : Import the database by using this command. mysql -u [username] -p newdatabase < [database name].sql;

  2. Clone/Extract the Source code.

  3. Run Composer Install Or Composer Update Command : Run the composer update command, If composer is not installed then run first composer install & then composer update command. (If you get any memory limit error then run COMPOSER_MEMORY_LIMIT=-1 composer update)

  4. Create env.php file : php bin/magento setup:config:set --db-user="dbusername" --db-password="dbpassword" --db-name="dbname" or add any existing env.php file and update the host, dbname, username & password.

  5. Create config.php file : php bin/magento module:enable --all

  6. Run the following commands one by one :

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento setup:static-content:deploy -f

  1. Change the base url in database : Table name : core_config_data

path : web/unsecure/base_url path : web/secure/base_url

Or you can change by using below commands.

php bin/magento setup:store-config:set --base-url="http://127.0.0.1/magento/"

php bin/magento setup:store-config:set --base-url-secure="http://127.0.0.1/magento/"

Ex: http://127.0.0.1/magento/

  1. Clean and Flush the cache : php bin/magento cache:clean and php bin/magento cache:flush.

  2. Now open url in browser.

0

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="[email protected]" --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.

0

Go to Magento root app/etc/env.php set database

'host' => 'localhost',
    'dbname' => 'yourdatabasename',
    'username' => 'mysqlusername',
    'password' => 'mysqlpassword',
    'active' => '1',
)

also check what is the mode you are 'MAGE_MODE' => 'default'

clear /var/cache , /var/generate, var/page_cache

Enable app/boostrap.php - ini_set('display_errors', 1); check what is 500 error.

Mysql Export via command line.

mysqldump -u username -p database_name > database_name.sql

Mysql import via command line.

mysql u -username -p database_name < database_name.sql

Another important point:

First update both the web/unsecure/base_url and web/secure/base_url URLs in core_config_data

3
  • how to install and import all the tables to the database ? any command or step for that thanks ? Aug 1, 2017 at 7:37
  • i updated the ans. please check it. Aug 1, 2017 at 7:52
  • is there any way to install the db from beginning without export from mysql ? like for example when installing magento from the fresh installation ? Aug 1, 2017 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.