Skip to content

Instantly share code, notes, and snippets.

@deadanon
Last active June 6, 2017 20:46
Show Gist options
  • Save deadanon/86e36fdac79182ab65652d5a29fdb6a7 to your computer and use it in GitHub Desktop.
Save deadanon/86e36fdac79182ab65652d5a29fdb6a7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Nginx/PHP-FPM /www on EC2 Userdata
# Sxale - Clint
# Configuration
cur_domain=new.rev-trak.com
# Update System, install gcc & make.
yum update -y
sudo yum install -y gcc make
# Install XFS filesystem & mount EBS at /www
yum install xfsprogs xfsdump -y
mkfs --type xfs /dev/xvdb
mkdir /www
mount /dev/xvdb /www
# Install Nginx and PHP-FPM
yum install -y nginx yum install php56 php56-cli php56-common php56-fpm php56-mysqlnd php56-pdo php56-xml php56-xmlrpc php56-soap php56-xml php56-xmlrpc php56-soap php56-gd
# nginx fixes:
# Own nginx files to ec2-user
chown -R ec2-user.ec2-user /var/log/nginx
# Inject nginx template and fix DOMAIN.com
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.back
rm -rf /etc/nginx/conf.d/*
wget -O /etc/nginx/nginx.conf https://gist.githubusercontent.com/deadanon/8e76b939252d7dd7ce03699ff105a2b5/raw/331894af2949d34b15c8b263120111230b3410d8/nginx.conf
wget -O /etc/nginx/conf.d/default.conf https://gist.githubusercontent.com/deadanon/a9259a93279876ca6b2aa1ba0b4aaec5/raw/193b7f24c53dfe4c32050db02542eedbe6aaa79b/vhost.conf
sed -i -e "s/DOMAIN.com/$cur_domain/g" /etc/nginx/conf.d/default.conf
echo "TS: <?php echo date('m-d-Y');?>" > /www/index.php
# Start NGINX and FPM & add to chk
chkconfig nginx on
chkconfig php-fpm on
service nginx restart
service php-fpm restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment