How to host any website on Amazon Web Server (AWS) and Create a Server install PHP or MySQL?
How can I map my domain to the AWS server? How can I access all server files and edit them through text-editor?
- 11 months ago
Click on Launch Button At the Top right side creates a server as per your requirement and Download PPk file for server connections.
Install PuTTY on your own PC to connect with the server.
Expand SSH and go to Auth>Credentials
Click browse button of Private Key file for Authentication >Browse to your downloaded PPk file and Choose
After choosing go to the left side category List and find a session at the top click on that it will change the view on the Connection page
Enter Host Name or IP Address (Go to Your AWS EC2 Instance page and find Public IPv4 address)
If you want to save connection details for the future > In the PuTTy Configuration and go to saved Session input field and fill connect Name(Any Name) and click the save button
Now click on Open button at the bottom of the screen it will open another terminal window
Terminal asks for login so enter the default login ID which is ec2-user and press enter button
I hope you will successfully log in
Now We need to Install some software to run our PHP Website on AWS
Here are some standard Commands for install
Get the latest bug fixes and security updates by updating the software on your EC2 instance.
sudo su (This command will give you Super User Access)
sudo yum update -y
sudo yum install -y httpd httpd-tools mod_ssl
sudo systemctl start httpd
sudo systemctl enable httpd
sudo amazon-linux-extras install php8.1
To make sure everything is installed and working find Go to you AWZ account > Instance > Select currently working Instance/Server and Reboot the server
Now your server is ready for everything copy your public IPv4 and try to paste in address bar of browser it will be like http://18.104.22.168
A demo page will be visible on the link Called Test Page
How to access AWS Server files through WinSCP?
File Protocol: SFTP
Host Name: ec2-XXX-X-X.ap-south-1.compute.amazonaws.com > You can put Public IPv4 Address or Public IPv4 DNS
User Name: ec2-user (default UserName)
Now go to Advanced Button
Windows will open Advanced Site Settings
Select SSH > Authentication and select your PPk file Private Key File
Click on OK
Your Connection is ready to Connect
Once Reboot server and then check your url or just run
sudo systemctl reload httpd.service
If you try to upload or change in var/www/html/index.php
It says permission denied to use
So you have to change folder permission by running below mentioned command
sudo chown -R ec2-user /var/www/html
sudo chmod -R 755 /var/www/html
Now your server root directory is ready to upload project files here.