Skip to content

Initial AWS configuration

Chen Hui Jing edited this page Jan 12, 2024 · 2 revisions

Again, if the site is already set up, you will not have to do this. But if you do have to set up a new AWS instance to run Drupal, maybe this can help you.

Source: https://aws.amazon.com/getting-started/hands-on/deploy-drupal-with-amazon-rds

  1. Create RDS instance, MariaDB engine 20GB storage on general purpose SSD
  2. Create EC2 instance, Amazon Linux 2023 image, 30GB storage on general purpose SSD
    1. Install mariadb105-server

    2. Set MySQL host name

      export MYSQL_HOST=RDS_END_POINT
    3. Login to RDS instance from EC2 with (RDS password is in 1Password)

      mysql -P DB_PORT -u RDS_USER_NAME -p DB_NAME
    4. Create new database user

      CREATE USER 'DB_USER_NAME' IDENTIFIED BY PASSWORD_IN_1PASSWORD;
      GRANT ALL PRIVILEGES ON DB_NAME.* TO DB_USER_NAME;
      FLUSH PRIVILEGES;
      Exit
    5. Install Apache on EC2 (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateWebServer.html)

      sudo dnf install -y httpd php php-mysqli
      sudo nano /etc/httpd/conf/httpd.conf
    6. Install Git on EC2

      sudo dnf install git
    7. Adjust folder permissions (https://askubuntu.com/a/767534)

      sudo chgrp -R apache /PATH_TO_DOCUMENT_ROOT
      sudo find /PATH_TO_DOCUMENT_ROOT -type d -exec chmod g+rx {} +
      sudo find /PATH_TO_DOCUMENT_ROOT -type f -exec chmod g+r {} +
      sudo chown -R ec2-user /PATH_TO_DOCUMENT_ROOT
      sudo find /PATH_TO_DOCUMENT_ROOT -type d -exec chmod u+rwx {} +
      sudo find /PATH_TO_DOCUMENT_ROOT -type f -exec chmod u+rw {} +
    8. Test if you can create a simple index.php file to display [php.info](http://php.info), for example

    9. Git clone repository

      git clone https://github.com/interledger/interledger.org-v4.git
    10. Move all files and folder out into the /var/www/html folder and delete the original folder

      mv -f /PATH_TO_DOCUMENT_ROOT/interledger.org-v4/{.,}* /PATH_TO_DOCUMENT_ROOT
      rm -rf interledger.org-v4/
    11. Test database connection from EC2 (password in 1Password)

      mysql DB_NAME -u admin -h RDS_END_POINT
    12. Connect DB to Drupal instance

      mkdir sites
      cd sites
      mkdir default
      cd default
      touch settings.php
    13. Check connection is successful using drush

      ./vendor/bin/drush status
    14. Upload database from latest local dump

      scp -i "PATH_TO_PEM_FILE" DB_DUMP.sql ec2-user@EC2_PUBLIC_DNS:/PATH_TO_DOCUMENT_ROOT
    15. Restore database with drush

      ./vendor/bin/drush sql-cli < DB_DUMP.sql
    16. Check site is running at http://EC2_PUBLIC_DNS/ or http://EC2_IP_ADDRESS/ (Note: Must be http at this point)

    17. Upload the files folder backup (should clean out the OS files first)

      scp -i "PATH_TO_PEM_FILE" files.zip ec2-user@EC2_PUBLIC_DNS:/PATH_TO_DOCUMENT_ROOT/web/sites/default
    18. Unzip files folder and cleanup

      unzip files.zip
    19. Update permissions so Apache can access the files (run at web folder)

      sudo chown -R ec2-user:apache .
    20. Check the Status Report page and resolve all errors displayed