Published in


Transferring local php application to an Amazon EC2 instance

Launch an EC2 instance with Amazon Linux 2 AMI. Make sure your security group has an inbound rule to enable SSH.

  • SSH into the instance.

Transfer local php application to the Apache document Root:

  • The Amazon Linux Apache document root is /var/www/html, which by default is owned by root. In order to transfer the php code on your machine to the EC2 instance, you’ll need to allow the ec2-user account to manipulate files in the apache document root.
pscp -r -i <path to local private key file> <path to local application code> ec2-user@<EC2 public ip address>:/var/www/html/
  • Use scp command for Linux.

If you want to automate this process. You can pass the commands as “user data” while launching the EC2 instance. The script will automatically be executed and your instance will be ready to run php applications.



Moving away from local everything to cloud everything. Discovering what’s safe, easy, cheap, conviniet.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store