Ubuntu Optimized LAMP on AWS

Set up EC2 Server

StepDetailNote
1Start instance AMI
2Set necessary firewall ruleper use-case

Set up Linux Ubuntu, require FTP, SSH connection

StepDetailNote
1Go to SSH
2Secure MySQL: mysql_secure_installationLink
3Create and grant user’s privileges:
- mysql -u root -p [password]
- CREATE USER ‘remote‘@’localhost’ IDENTIFIED BY ‘[password]’;
- GRANT ALL PRIVILEGES ON . TO ‘remote‘@’localhost’;
4Edit vhost at: /jet/etc/apache/extra/
5Remove file .gitkeep in default folder /jet/app/www/default/:
- cd /jet/app/www/default/
- rm .gitkeep
6aInstall SSL certbot:
- sudo wget https://dl.eff.org/certbot-auto -O /usr/sbin/certbot-auto
- sudo chmod a+x /usr/sbin/certbot-auto
- sudo certbot-auto -d [domain_name] -d [domain_name_alias] –manual –preferred-challenges dns certonly
(need to add DNS TXT record and wait for 5~10min each time adding new record)
6bInstall SSL certbot:
- sudo apt install certbot
- sudo certbot –apache Change /etc/letsencrypt/live & archive has correct permission 755:
- sudo chmod 2755 /etc/letsencrypt/live/
- find /etc/letsencrypt/live -type d -exec sudo chmod 2755 {} ;
- sudo chmod 2755 /etc/letsencrypt/archive/ - find /etc/letsencrypt/archive -type d -exec sudo chmod 2755 {} ;
Link
7Check SSL: sudo cat /etc/letsencrypt/live/[domain_name]/fullchain.pem
8aTest renew:
- sudo certbot renew –dry-run
Set auto renew certbot:
- 0 0 1 * * root /usr/sbin/certbot-auto renew –quiet
8bTest renew:
- sudo /usr/sbin/certbot-auto renew –dry-run
Set auto renew certbot:
- 0 0 1 * * /usr/sbin/certbot-auto renew
8cUser certbot renew with hooks:
- certbot renew –pre-hook “service nginx stop” –post-hook “service nginx start”
9Reboot to test
10Check Apache Log:
- sudo tail -n 20 /jet/log/apache/error_log

Set up Cloudflare & Domain

StepDetailNote
12Cloudflare CDN / HTTPS redirect

Set up Varnish Cache (Optional)

StepDetailNote
1Install varnish
2Config files:
- sudo vi /etc/varnish/default.vcl
- sudo vi /etc/sysconfig/varnish
3Test: curl -I http://localhost

Benchmark Apache (Testing)

StepDetailNote
1Install apache benchmark
2Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
-t timelimit Seconds to max. wait for responses
-v verbosity How much troubleshooting info to print
-f protocol Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)
Link

Benchmark Siege (Testing)

StepDetailNote
1Usage:
siege -i -c 50 -b -t 20S –no-parser -f [text_url_list.txt]