To build resilience, let's shut down and start up the web server to make sure that MySQL and Apache automatically start with the operating system. We first define the CURRENT_INSTANCE variable to make our commands easier, as follows:
CURRENT_INSTANCE=$(aws ec2 describe-instances --query 'Reservations[*].Instances[*].InstanceId' --filter 'Name=tag:Name,Values=WebServer' --output text)
aws ec2 reboot-instances --instance-ids $CURRENT_INSTANCE
Again, check phpinfo.php, to verify that it is still working. Now, issue a stop instance command, wait a few seconds, and start the instance again, as follows:
aws ec2 stop-instances --instance-id $CURRENT_INSTANCE
aws ec2 start-instances --instance-id $CURRENT_INSTANCE
If you try to reach the informational web page, 54.172.31.74/phpinfo.php, it will probably no longer be there. Why did this happen? Every time...