Skip to content

Latest commit

 

History

History
54 lines (50 loc) · 2.96 KB

README.md

File metadata and controls

54 lines (50 loc) · 2.96 KB

Host Personal Web on AWS EC2

Launch EC2 instance

  1. Choose Ubuntu Server
  2. Configure security group
    1. ssh: 22
    2. http: 80
    3. https: 443
  3. Create Keypair Personal-Web-KeyPair.pem and Download to local

SSH into the instance and install Apache2

  1. Terminal (local): ssh -i "Personal-Web-KeyPair.pem" [email protected]
  2. Package update: sudo apt-get update
  3. Install apache2: sudo apt-get install apache2
  4. Check status: sudo systemctl status apache2
  5. Restart apache2: sudo systemctl restart apache2
  6. Browser check link: ec2-Public-IPv4-DNS.compute-1.amazonaws.com showing apache2 website

Connect FileZilla to EC2 instance to transfer/upload files

Virtual Hosts in Apache2

  1. Register a domain name guowenbin.com. (I used Namecheap.com personally)
  2. cd /etc/apache2/sites-available/, modify 000-default.conf
    1. <VirtualHost *:80>
      ServerName: guowenbin.com
      ServerAlias www.guowenbin.com

    2. <VirtualHost *:443>
      ServerName: guowenbin.com
      ServerAlias www.guowenbin.com ServerAdmin: emailAddress
      SSLCertificateFile ~/personalWeb.crt
      SSLCertificateKeyFile ~/server.key
      SSLCertificateChainFile ~/personalWeb.ca-bundle

    3. Log directory error: No such file or directory: AH02291: Cannot access directory '/etc/apache2/$/home/ubuntu/log/

      mkdir /var/log/apache2
      chmod 750 /var/log/apache2
      chown root:adm /var/log/apache2
      solution from plesk

  3. cd /var/www/html/, update index.html

Add SSL (https)

  1. Purchase PositiveSSL and issue to the primary domain

  2. openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr to get key and CSR code
    CSR code start with -----BEGIN CERTIFICATE REQUEST-----

  3. SSL certificate: a) active ssl, b) enter CSR code, primary domain, c) DCV method: add CNAME record

  4. Receive an email contains two files: personalWeb.ca-bundle and personalWeb.crt

  5. Setup Advanced DNS

    Type Host Value TTL
    A Record @ IPv4 address 5 min
    CNAME Record www ec2-Public-IPv4-DNS.compute-1.amazonaws.com 5 min
    CNAME Record www guowenbin.com 5 min
    CNAME Record Host from ssl check namecheap tutorial Automatic
    CNAME Record Host.www target from ssl check namecheap tutorial Automatic
    URL Redirect Record @ https://guowenbin.com DO NOT forget this Redirect