How can I migrate a Drupal site to Amazon Web Serv

2019-06-04 02:05发布

问题:

I have a working local Drupal 7 site (with local MySQL Database), but now I'm trying to migrate it to Amazon Web Services (which is currently running a test Drupal site successfully). I have all of my drupal files in a directory mydrupalsite on the EC2 instance server and the database has been added to the remote MySQL, but I don't know what to do now in order to configure apache to show the new site.

What I have tried so far:

  • I added the file in /etc/apche2/sites-available (copied the old instance and changed the directory name where appropriate)
  • I changed the symlinks (deleted the old symlink and added a new one) in /etc/apache2/sites-enabled so that only the new file is pointed to.
  • Then I rebooted the server and navigated to the site, but it's taking me to the install page (as though i were starting over)

Here are the contents of $databases variable in the settings file on my local machine (with username changed but the pw is an empty string)

if (!isset($databases)) {
  $databases = array();
}

$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => 'naicdrpl',
  'username' => 'mylocalsiteusername',
  'password' => '',    //    password is an empty string
  'host' => '127.0.0.1',
  'port' => 33067 );

回答1:

You can use backup&migrate module for migration. It is very easy for using.

  1. Zip all files from your Drupal directory. Copy/unzip that file on new server.
  2. Backup your database in file with backup&migrate module.
  3. Install Drupal site on new server. Run install.php and follow steps - you should probably change settings in /sites/default/settings.php file.
  4. Go on /admin/modules and enable backup and migrate.
  5. Go on /admin/config/system/backup_migrate/restore upload your backup file and click restore button

NOTE 1 (database settings):

For Drupal installation of course you need to have database. You should just create empty DB and set up user for that database. You should also set up password for that DB user and give him full privileges. In settings.php file you then change that data:

if (!isset($databases)) {
  $databases = array();
}

$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => 'nameofyourDB', //here you enter name of new empty database
  'username' => 'mylocalsiteDBusername', //here you enter user name of database user
  'password' => 'yourpassword',    //you should always set up password for database user for security reasons
  'host' => '127.0.0.1', //name of your host (usually is localhost)
  'port' => 33067 ); //default MySql port

Basically here you set up Drupal site on empty database you created on new server. After that you fill that database using backup and migrate module.

NOTE 2 (settings.php file premissions):

When you migrate site and (in your case replace old one with new) you want to change settings.php file there can be a little problem with write permissions of the settings.php file. It is a common case that by default you can't change settings.php so in order to edit/replace that file you need to change permissions of the file and also of the folders where this file is placed. With no write permissions you can end up with new site and old settings.php file (the settings.php file from site you migrate will not overwrite old file).

Hope this helps.



回答2:

You can do it in the GUI with the Backup and Migrate module https://www.drupal.org/project/backup_migrate



回答3:

Okay it appears the issue was that settings.php did not have the needed configuration. Here was the solution that worked for me:

  1. In order to determine what was needed, I created a temporary database in mysql call temp_db
  2. I commented out the database section of settings.php
  3. I navigated to the site which started the install process again
  4. I went through the install process using the new temp_db
  5. After completing this process, I went to settings.php and changed the db name to the correct one.
  6. Went to the EC2 instance again and it worked!

Thank so much to everyone who helped!