Skip to content

Instantly share code, notes, and snippets.

@jeffbrl
Created March 22, 2023 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffbrl/2e608d82105bcb1a764e00a49ce7fc3f to your computer and use it in GitHub Desktop.
Save jeffbrl/2e608d82105bcb1a764e00a49ce7fc3f to your computer and use it in GitHub Desktop.
User-data for Amazon Linux 2 Apache with Self-Signed Cert
#!/bin/bash -xe
# Use with Amazon Linux 2
# Amazon Linux 2023 doesn't seem to have make-dummy-cert script
yum update -y
yum install -y httpd mod_ssl
systemctl start httpd
systemctl enable httpd
usermod -a -G apache ec2-user
chown -R ec2-user:apache /var/www
chmod 2775 /var/www
find /var/www -type d -exec chmod 2775 {} \;
find /var/www -type f -exec chmod 0664 {} \;
echo `hostname` > /var/www/html/index.html
echo '<br><br>' >> /var/www/html/index.html
# create ~ 12K of random text
base64 /dev/urandom | head -c 1000 >> /var/www/html/index.html
cd /etc/pki/tls/certs
./make-dummy-cert localhost.crt
sed -i 's/^SSLCertificateKeyFile.*$//' /etc/httpd/conf.d/ssl.conf
systemctl restart httpd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment