CentOS 7.x create lightsail wordpress instance

From Notes_Wiki
Revision as of 04:38, 15 March 2019 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb self="Create lightsail wordpress instance">CentOS_7.x_Setup_lightsail_instances|Setup lightsail instances</yambe:breadcrumb> <yambe:breadcrumb self="Create l...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb self="Create lightsail wordpress instance">CentOS_7.x_Setup_lightsail_instances|Setup lightsail instances</yambe:breadcrumb> <yambe:breadcrumb self="Create lightsail wordpress instance">CentOS_7.x_wordpress|Wordpress</yambe:breadcrumb>

CentOS 7.x create lightsail wordpress instance

To create a AWS ligtsail instance with wordpress use following steps:

  1. Create appropriate lightsail instance
  2. For production instances create static IP and attach with instance
  3. Create DNS entry for FQDN mapping to static IP
  4. Allow HTTPS access to server in lightsail instance networking firewall section
  5. Download corresponding regions private key
  6. chmod 400 <private-key>
  7. ssh -i <private-key> centos@<instance-public-ip>
  8. sudo su -
  9. Disable SELinux
  10. yum -y install vim
  11. vim ~/.ssh/authorized_keys
    Add own key, Allow <private-key> direct root aaccess. (First line 155x)
  12. Set hostname
    hostname <desired-fqdn>
    vim /etc/hostname
  13. Exit
  14. ssh directly as root with self public key
  15. Search for bitnami installer URL
  16. yum -y install epel-release
  17. yum -y install wget
  18. wget '<Download-URL>' -O '<Installer-filename>'
  19. yum -y install perl-Data-Dumper
  20. Create appropriate swap space using CentOS 7.x adding swap space using file
  21. chmod +x <Installer-filename>
  22. ./<Installer-filename>
    Give standard answers with simple password and admin username. Email can be configured later.
  23. Setup fail2ban using CentOS 7.x fail2ban including firewalld using CentOS 7.x Basic firewalld configuration
  24. Set correct time zone CentOS 7.x Change system timezone
  25. Configure system to store history date time using Storing date / time along with commands in history
  26. exit and ssh again for history settings to take effect
  27. If site at /wordpresss URL is acceptable then use following to redirect automatically from / to /wordpress
    1. cd /opt/wordpress-<ver>/apache2/htdocs
    2. mv index.html index-old.html
    3. wget sbarjatiya.com for downloading index.html containing HTTP meta refresh for redirection
    4. vim index.html
      Add redirect for /wordpress, Remove google identifier, Set appropriate name
    If instead site is required at / and not at /wordpress refer CentOS 7.x Redirect bitnami wordpress from /wordpress to /
  28. Generate lets-encrypt certificate if public DNS FQDN is set using:
    /opt/wordpress-<ver>/letsencrypt/scripts/generate-certificate.sh -m <admin-email-id> -d <FQDN>
    Run above command again if it fails first time.
    Refer: https://docs.bitnami.com/aws/how-to/generate-install-lets-encrypt-ssl/
  29. 'crontab -e' and update
    0 0 1 * * /opt/wordpress-<version>/letsencrypt/lego
    line to to have first two digit 0 and 0 randomized to minutes between 5 to 55 and hour between 1 to 4
  30. Open site using https://<fqdn> and verify that it is opening properly
  31. For compulsary https access edit /opt/wordress-<ver>/apache2/conf/bitnami/bitnami.conf and under
    DocumentRoot "/opt/wordpress-<ver>/apache2/htdocs"
    Append
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
  32. Edit opt/wordpress-5.0.3-2/apps/wordpress/htdocs/wp-config.php and update WP_SITEURL and WP_HOME to use https URL
  33. /opt/wordpress-<ver>/ctlscript.sh restart apache
  34. Test whether automatic redirection to https is working in private browser
  35. yum -y install bzip2
  36. Open /opt/wordpress-<ver>/apps/wordpress/htdocs/wp-config.php and see DB_NAME, DB_USER, DB_PASSWORD and DB_HOST values
    /opt/wordpress-<ver>/mysql/bin/mysql -u bn_wordpress -p bitnami_wordpress
    with password read in above step
  37. Create /opt/take-database-backup.sh with following contents:
    /opt/wordpress-<ver>/mysql/bin/mysqldump -u bn_wordpress -p<password> bitnami_wordpress | bzip2 > /opt/bitnami_wordpress.sql.bz2
  38. chmod +x above file and test it by running.
  39. Configure backup for /opt folder which executes /opt/take-database-backup.sh before backup.
  40. Install logwatch and set /etc/aliases for root user



<yambe:breadcrumb self="Create lightsail wordpress instance">CentOS_7.x_Setup_lightsail_instances|Setup lightsail instances</yambe:breadcrumb> <yambe:breadcrumb self="Create lightsail wordpress instance">CentOS_7.x_wordpress|Wordpress</yambe:breadcrumb>