In this tutorial you’ll learn how to setup existing magento 2 project in new domain or locally.
Follow below steps to setup existing magento 2 project.
- Import Database :
Import the database by using this command. mysql -u [username] -p newdatabase < [database name].sql;
- Clone/Extract the Source code.
Clone or extract the source code of magento 2.
- 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
command.)
- Create
env.php
file : Run this command to 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.
- Create
config.php
file : Run this command to create config.php file.
php bin/magento module:enable --all
- 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
- 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/
- Clean and Flush the cache :
php bin/magento cache:clean
and php bin/magento cache:flush
.
- Now open url in browser.
🙂 Happy Coding. Keep Liking & Sharing 💻