[Drupal] What all configuration changes had to be handled while setting up a drupal site in local machine

Zyxware default image4

Consider that you are working on a Drupal website. It is not possible to work on the live website because it will result in crashing of the site if we make some mistake. So the best way to avoid this problem is by setting up the same site in the local machine and after that working on it. The following steps have to be performed if you want to setup a Drupal site in your local machine.

Initial changes required

1. Go to .htaccess file > Uncomment: RewriteBase /~<user>/<project-folder-name>/

2. Import DB dump to local m/c via phpmyadmin Or MySQL Query Browser

Export database via terminal:


mysqldump -u mysqlusername -p db_name > dbfilename
Eg:mysqldump -u username -p database > database.sql

Export database with extension 'sql.gz'


mysqldump -u mysqlusername -p db_name | gzip > dbfilename.sql.gz
Eg:mysqldump -u username -p database | gzip > database.sql.gz

Import database via terminal:


mysql -u mysqlusername -p db_name 

Import database with extension 'sql.gz'


zcat dbfilename.sql.gz | mysql -u mysqlusername -p db_name
Eg:zcat database.sql.gz | mysql -u username -p database

3. Update Local DB Credentials to sites/all/default/settings.php:

Set - $db_url = 'mysql://username:[email protected]/databasename';

Comment - # $base_url = 'https://www.sitename.com';

4. Clear 'cache_' tables from the database

5. Set Write permission to 'files' folder

chmod permissionsettings dirname -R

    Eg: sudo chmod 777 files