0

Ok so I am kinda new to drupal (I've only been working with it for a few months at work) and I just got my first freelance client who has a drupal site that he wants to modify its layout.

I am now stuck at trying to duplicate the website and set it up on my machine and I don't want to do changes to the production environment directly. Here's what I did so far:

  1. I got access to the webhost server and downloaded the site's drupal root directory
  2. I exported the site's database and stored it on my machine
  3. Used Acquia Dev Desktop 2 to import a local site -> chose the downloaded drupal site root -> selected the sq database dump file that I exported earlier

When I try to open the site on my local server it runs the drupal installation but when I choose a profile and press "Save and continue" it shows me the following message:

"Drupal already installed. To start over, you must empty your existing database. To install to a different database, edit the appropriate settings.php file in the sites folder."

Now I know that drupal is already installed probably because I cloned the website codebase and database exactly as they are from the webhost server, and I did not change any of the settings.php files. How exactly do I run the website l locally through Acquia Dev Desktop and then push my changes to the host?

Any tips, best practices comments, and advice is highly appreciated!

2 Answers 2

0

Most probably the problem is in your settings.php, what you can do:

  1. Open your settings.php files and search for the folowing code:

    $databases = array 'default' => array ( 'default' => array ( 'database' => 'your-db-name', 'username' => 'your-db-user', 'password' => 'your-db-user-password', 'host' => 'localhost', 'port' => '', 'driver' => 'mysql', 'prefix' => '', ), ),
    );

  2. If you are not sure if you have the correct code for your database, please post your code back in here and i will take a look on it

  3. Last thing, if all you need is making changes to your website using a test website and then push all changes back to the production website, my suggestion is to create a subdomain on your webshost (Ex: dev.yourdomainname.com) and completely clone your entire website from dev.yourdomainname.com so you can work on your dev website without touching your production one.

I can help you with that also but first tell me what your need and answer the following:

_ You have access to Drush console ? _ You have access to the webhost server ?

waiting your response...

Update # 1: Clone your production website for testing purposes on your webhost

1) Create a subdomain for your domain name (ex: dev.yourdomain.com)

2) From your cpanel, create a new empty database (don't forget to prefix your db name at end by _test to distinguish it from the original one) (Ex: db_name_test)

write down the name of the database

3) create a new user for your test database and also (don't forget to prefix your user name at end by _test to distinguish it from the original one)

Write down the name of the user & password

4) Grant the test user all privileges for the new database.

5) goto your production site and do the following manually or by using the drush command:

  • Clear all caches. (drush cc all)
  • Disable clean URLs. (/admin/config/search/clean-urls)(drush vset clean_url 0 --yes)
  • Disable cron job. (/admin/config/system/cron)
  • Put site in maintenance mode. (drush vset maintenance_mode 1 --yes)

6) Copy the entire site's drupal root directory to the new test website root directory and make sure the settings.php file is copied as well.

Manually: Click on the site root directory and choose copy and type the destination path.

drush command:

cp -rp /home/cpanel-user/public_html/your-original-site-root-directory /home/cpanel-user/public_html/your-dev-site-root-directory

7) Goto your phpMyAdmin, Select your original database, Choose operations, under the copy database to section, write down your test database name as it is, make sure the structure and data is selected, and uncheck create database before copying, leave everything else as it is, click Go and wait for the confirmation message.

8) Make sure the permission given to the deb-site root directory is: 0755

9) navigate to your new test website directory, edit settings.php and edit the database settings to fit the new database name, new database user & new user password

10) open new tab browser and navigate to: dev.yourdomain.com

11) Voila, all should be good.

12) goto your dev site and do the following manually or by using the drush command:

  • Clear all caches. (drush cc all)
  • Enable clean URLs. (/admin/config/search/clean-urls)(drush vset clean_url 1 --yes)
  • Enable cron job. (/admin/config/system/cron)
  • Don't remove the site from the maintenance mode since it is a test website.

Note, you can do the exact steps above to have a copy of your website locally, but i will just stick with this method since it is more reliable. easier and faster.

If you insist of cloning your website locally to acquia dev desktop:

1) Get a fresh copy of your prod-site database and file, manually or using drush

drush ard --destination=/home/cpanel-user/create-a-directory-for-backup/choose-a-name.tar.gz

The above command using drush 7, will get you a copy of your database and your files/folders.

2) Download the archive backup folder to your desktop and unzip.

3) Goto Acquia dev desktop, click on + and import local drupal site

4) Choose the local codebase folder from the unzipped folder you just downloaded.

5) choose a local site.

6) leave the create a new database and give it a new name of your choice.

7) when finish importing, visit your website and complete a new fresh installation from your website.

8) when all go good and you will have a fresh new Drupal website up and running, goto your local database (phpMyAdmin), click on Structure, Scroll down to the button, Check all tables, with selected choose drop, make sure there is no any left tables in the database.

9) Goto import, select you .sql database, leave everything as it is, click Go

10) no need to change anything inside the settings.php, just visit your site and voila.

2
  • Thanks for taking the time to guide me through this. To answer your question I do have access to Drush console and the webhost server. My database code in the site's settings.php is as follows: $databases = array ( 'default' => 'default' => array ( 'database' => 'mdezig66', 'username' => 'root', 'password' => 'password', 'host' => 'localhost', 'port' => '8083', 'driver' => 'mysql', 'prefix' => '', ), ), );
    – A.B.E
    Commented Jun 11, 2017 at 15:54
  • Please find the updated section in my answer above
    – user76475
    Commented Jun 11, 2017 at 17:57
0

As you have access to the webhost and downloaded the files and db, follow these steps for Acquia Desktop:

Open the db and empty all the cache_* tables. 2. Rename settings.php to something else, eg settings.php_prod 3. Move the sites filesystem to Acquia Desktop appropriate directory 4. Open Acquia Desktop and press + -> Import Local Drupal Site 5. Select the filesystem and in the database field select Import an sql dump file 6. Select your downloaded db and leave it import it.

You will find out that Acquia Desktop creates a folder with dd suffix which is a shortcut to sites/default. Change paths to uploaded files to sites/default.

When you are done, empty cache tables again, delete Acquia Desktop settings.php (which is different from the production) and rename back settings.php_prod to settings.php.

Upload everything to the webhost and you are done.

3
  • Thank you so much for providing an answer. I've do steps 1 though 6 and the problem of a drupal installation already existing is gone. But before I go on with setting up the site, what do you mean by "Change paths to uploaded files to sites/default."? Where do I change that path?
    – A.B.E
    Commented Jun 11, 2017 at 16:18
  • When you upload eg an image in Acquia Desktop, this image goes to /sites/default/files directory though it is retrieved from <sitename>.dd shortcut. So when you upload the site to the production server you see that the image is missing. If you use the image/file field, delete and re-upload. If you use a wsiwyg editor open image settings and fix the path Commented Jun 11, 2017 at 19:43
  • That is incredibly helpful, I'll bear that in mind. Thanks for your help!
    – A.B.E
    Commented Jun 12, 2017 at 21:56

Your Answer

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

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