Below is a quick reference on how to setup a free Amazon Web Services (AWS) Linux server and install Apache, MySQL and PHP. Learn more about AWS here.
Requirements:
- Free Amazon Web Services Account
- Basic SSH knowledge
Directions:
- Login to Amazon Web Services.
- Click EC2 icon from dashboard:
- Click Instances from Left Navigation
- Click Launch Instance Button
- Select Amazon Linux AMI
- Select Review & Launch Button
- Select Launch Button
- When Prompted Select "Create a new key pair" and enter "Key pair name"
- Click "Download Key Pair" button to download new key pair file (.pem file)
- Open Terminal on Local Machine and move .pem file to ~/.ssh directory:
mv ./awsdevelopment.pem ~/.ssh/awsdevelopment.pem - Change file permissions on .pem file:
chmod 600 ~/.ssh/awsdevelopment.pem - Add key to ssh to avoid having to specify key everytime you ssh:
ssh-add -K ~/.ssh/awsdevelopment.pem - Go back to AWS instance setup window in web browser and click "Launch Instances" button
- AWS will now build/launch your instance (this may take a few mins).
Click on "View Instances" Button - From Instances Dashboard, Select new Instance and copy Public DNS URL
- Go back to Terminal on Local Machine and SSH into new Instance:
ssh ec2-user@my.public.dns.amazonaws.com
Where: my.public.dns.amazonaws.com is your instance's Public DNS URL - Update and Install Apache, MySQL and PHP:
sudo yum update -y
sudo yum groupinstall -y "Web Server" "MySQL Database" "PHP Support"
sudo yum install -y php-mysql php-devel php-zlib php-gd php-pdo
sudo yum install -y php-mbstring pcre-devel php-pecl-oauth
sudo service httpd start
sudo chkconfig httpd on
sudo groupadd www
sudo usermod -a -G www ec2-user
exit - SSH back into the Instance to continue with new group:
sudo chown -R root:www /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 {} +
sudo -i
sudo echo "extension=oauth.so" >> /etc/php.ini
exit
sudo service httpd restart - Go back to AWS Instances Dashboard and Select on Instance
- Then Select "launch-wizard-1" security group link:
- Click Inbound Tab, Then Click Edit Button to Add new Inbound Rule
- Click Add Rule, Then Select "HTTP", Repeat for "HTTPS", Click Save
- Open a new web browser window and navigate to your Public DNS URL to view default page:
http://my.public.dns.amazonaws.com
Where: my.public.dns.amazonaws.com is your instance's Public DNS URL
Additional Information:
- http.conf is located in /etc/httpd/conf to edit:
sudo vi /etc/httpd/conf/http.conf - how to restart httpd (apache) after editing http.conf file:
sudo service httpd restart