Skip to content

Instantly share code, notes, and snippets.

@phfilly
Last active April 21, 2021 15:09
Show Gist options
  • Save phfilly/2dbc6e9c00d534f5a3b42bcba787d66e to your computer and use it in GitHub Desktop.
Save phfilly/2dbc6e9c00d534f5a3b42bcba787d66e to your computer and use it in GitHub Desktop.
server setup
# Extra information
# Install a LAMP web server on the Amazon Linux AMI https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html
sudo yum update -y
sudo yum update -y aws-cfn-bootstrap
sudo yum install -y aws-cli
sudo yum install -y amazon-linux-extras
sudo yum install -y httpd24 php74
sudo yum install -y docker
sudo yum install -y php-redis
echo "Docker and Apache finished..."
sudo amazon-linux-extras enable php7.4
sudo yum clean metadata
sudo yum install -y php php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap}
sudo usermod -a -G apache ec2-user
sudo chown -R ec2-user:apache /var/www
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {}
find /var/www -type f -exec sudo chmod 0664 {}
cd /home/ec2-user/
aws s3 cp 's3://aws-codedeploy-eu-west-1/latest/codedeploy-agent.noarch.rpm' . || error_exit 'Failed to download AWS CodeDeploy Agent.'
sudo yum -y install codedeploy-agent.noarch.rpm || error_exit 'Failed to install AWS CodeDeploy Agent.'
sudo systemctl httpd start
sudo chkconfig httpd on
sudo chkconfig docker on
echo "Installing SSL configuration"
sudo yum install -y make gcc openssl-devel
sudo yum install -y mod_ssl
cd /etc/php.d/
echo '; Enable redis extension module' > /etc/php.d/30-redis.ini
echo 'extension=redis' >> /etc/php.d/30-redis.ini
systemctl restart php-fpm
# cd /etc/php.d/
# echo '; Enable mongodb extension module' > /etc/php.d/30-mongodb.ini
# echo 'extension=redis' >> /etc/php.d/30-redis.ini
# systemctl restart php-fpm
sudo pecl install swoole
sudo pecl install redis
sudo docker run --name redis -d -p 6379:6379 redis redis-server --requirepass "19ffc202e07b029"
# To run the script file
chmod u+x script.sh
chmod 744 script.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment