EC2 with VSCode


How to view ec2 instance with vscode?

  1. Ctrl+Shift+X Extensions → Remote Development → Install
  2. F1 → Remote-SSH: Open Configuration File → ~/.ssh/config file → Edit file,
  3. 
    Host random_name_for_aws
        HostName ip_address
        User ubuntu
        Identityfile /path/to/aws_linux.pem
        
  4. F1 → Remote-SSH: Connect to Host → Select random_name_for_aws → Now you should be connected → Check with /home/ubuntu or terminal
  5. To disconnect, File → Close Remote Connection

How to view virtualhost in ec2 instance?

  1. Once vscode has connected to ec2 instance, start your php server.
  2. 
    cd root
    php -S localhost:7000 index.php
    nmap -p- localhost # view 7000 is opened
        
  3. You can use terminal and Ctrl+Click localhost:7000. You should be able to view it in browser 127.0.0.1:7000.
  4. To kill the process, find pid and use kill command.
  5. 
    ps aux | grep php # e.g. 31599
    kill -9 31599
        

References