AWS Amazon Web Services Cloud computing and PHP (Part 1)
December 1, 2021
aws bash debian devopsAWS Amazon Web Services Cloud computing and PHP
I my quest to learn more about cloud computing especially using PHP, I am spending the cold winter months developing skills. I am going to write blogs about investigating each of these
- EC2 Debian 10 LAMP server by hand
- EC2 Docker Container
- AWS Lambda
- Amazon Lightsail
- Using ansible and terraform to setup a lamp server
- Using the AWS CLI
Using EC2 Debian 10 LAMP stack server by hand.
Setting up an instance is pretty easy - i created a private key, downloaded it and connected the first time using
ssh -i privatekey.pem admin@ec2-13-40-50-116.eu-west-2.compute.amazonaws.com
Note the user is admin, as that is the default for debian
Here is a link to the default usernames for different systems
aws default users for ssh connections to linux distros
To run apt-get you need to use sudo
So to install apache
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2
sudo a2enmod ssl
sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
# install firewall and setup
sudo apt install ufw
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
# to get the https version running
sudo apt install certbot
sudo apt-get install python-certbot-apache
sudo a2ensite default-ssl
sudo systemctl reload apache2
# installing php 8.0 and 8.1
sudo apt-get install lsb-release apt-transport-https ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sudo echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt-get update
sudo apt install -y php8.0-{mysql,cli,common,snmp,ldap,curl,mbstring,zip,tidy,xml,opcache}
sudo apt install -y php8.1-{mysql,cli,common,snmp,ldap,curl,mbstring,zip,tidy,xml,opcache}
sudo update-alternatives --config php
sudo apt-get install php8.0-fpm libapache2-mod-php8.0
sudo apt-get install php8.1-fpm libapache2-mod-php8.1
sudo a2dismod php8.0
sudo a2enmod php8.1
sudo systemctl restart apache2
The default directory for the files is /var/www/html Setting up a simple test.php file with the contents
<?php
phpinfo();
Gives the php info test page.
Next, lets install a mysql database to store some data.
Please visit this repo at github.com/allotmentandy/aws for shell scripts and files to run this code.
If you would like to contact me with this form on londinium.com, ilminster.net or via Twitter @andylondon