Question Detail

How to host Website Over the AWS EC2 Web Server?

1 years ago Views 583 Visit Post Reply

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?

Thread Reply

Hemant Haritash

- 1 years ago

Click on Launch Button At the Top right side creates a server as per your requirement and Download PPk file for server connections.

  1. Install PuTTY on your own PC to connect with the server.

  2. PuTTY

    1. Category List

    2. Expand SSH and go to Auth>Credentials

    3. Click browse button of Private Key file for Authentication >Browse to your downloaded PPk file and Choose

    4. 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

    5. Enter Host Name or IP Address (Go to Your AWS EC2 Instance page and find Public IPv4 address)

    6. 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

    7. Now click on Open button at the bottom of the screen it will open another terminal window

    8. Terminal asks for login so enter the default login ID which is ec2-user and press enter button

    9. I hope you will successfully log in

  3. Now We need to Install some software to run our PHP Website on AWS

  4. Here are some standard Commands for install

    1. Get the latest bug fixes and security updates by updating the software on your EC2 instance.

      1. sudo su (This command will give you Super User Access)

      2. sudo yum update -y

      3. sudo yum install -y httpd httpd-tools mod_ssl

      4. sudo systemctl start httpd

      5. sudo systemctl enable httpd

      6. sudo amazon-linux-extras install php8.1

      7. Click Y

      8. To make sure everything is installed and working find Go to you AWZ account > Instance > Select currently working Instance/Server and Reboot the server

    2. Now your server is ready for everything copy your public IPv4 and try to paste in address bar of browser it will be like

    3. A demo page will be visible on the link Called Test Page

  5. How to access AWS Server files through WinSCP?

    1. File Protocol: SFTP

    2. Host Name: > You can put Public IPv4 Address or Public IPv4 DNS

    3. User Name: ec2-user (default UserName)

    4. Now go to Advanced Button

    5. Windows will open Advanced Site Settings

      1. Select SSH > Authentication and select your PPk file Private Key File

      2. Click on OK

    6. Your Connection is ready to Connect

    7. Start Login

    8. Once Reboot server and then check your url or just run

    9. 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.

Hemant Haritash

- 1 years ago

See desired PHP versions installed:

amazon-linux-extras list | grep php