EC2 with VSCode
How to view ec2 instance with vscode?
- Ctrl+Shift+X Extensions → Remote Development → Install
- F1 → Remote-SSH: Open Configuration File → ~/.ssh/config file → Edit file,
Host random_name_for_aws
HostName ip_address
User ubuntu
Identityfile /path/to/aws_linux.pem
- F1 → Remote-SSH: Connect to Host → Select random_name_for_aws → Now you should be connected → Check with /home/ubuntu or terminal
- To disconnect, File → Close Remote Connection
How to view virtualhost in ec2 instance?
- Once vscode has connected to ec2 instance, start your php server.
cd root
php -S localhost:7000 index.php
nmap -p- localhost # view 7000 is opened
- You can use terminal and Ctrl+Click localhost:7000. You should be able to view it in browser 127.0.0.1:7000.
- To kill the process, find pid and use kill command.
ps aux | grep php # e.g. 31599
kill -9 31599
References