AWS Amazon Web Services Cloud computing and PHP (Part 1) AWS Amazon Web Services Cloud computing and PHP (Part 1)

December 1, 2021

aws bash debian devops

AWS 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

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
sudo echo "deb $(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



Gives the php info test page.

Next, lets install a mysql database to store some data.

Please visit this repo at for shell scripts and files to run this code.

If you would like to contact me you can either use this form on or via Twitter @andylondon