{"id":18637996,"url":"https://github.com/baponkar/aws-ubuntu-nginx-server-host","last_synced_at":"2026-05-09T14:07:01.716Z","repository":{"id":241575790,"uuid":"807085694","full_name":"baponkar/aws-ubuntu-nginx-server-host","owner":"baponkar","description":"Hosting a Ubuntu Nginx Server in AWS","archived":false,"fork":false,"pushed_at":"2024-05-29T16:31:41.000Z","size":2698,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T06:42:58.827Z","etag":null,"topics":["aws","bash","nginx","server","ubuntu"],"latest_commit_sha":null,"homepage":"https://github.com/baponkar/aws-ubuntu-nginx-server-host","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baponkar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-28T13:04:37.000Z","updated_at":"2024-05-29T16:31:44.000Z","dependencies_parsed_at":"2024-05-29T04:45:17.389Z","dependency_job_id":null,"html_url":"https://github.com/baponkar/aws-ubuntu-nginx-server-host","commit_stats":null,"previous_names":["baponkar/aws-ubuntu-nginx-server-host"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baponkar%2Faws-ubuntu-nginx-server-host","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baponkar%2Faws-ubuntu-nginx-server-host/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baponkar%2Faws-ubuntu-nginx-server-host/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baponkar%2Faws-ubuntu-nginx-server-host/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baponkar","download_url":"https://codeload.github.com/baponkar/aws-ubuntu-nginx-server-host/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239433908,"owners_count":19637806,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","bash","nginx","server","ubuntu"],"created_at":"2024-11-07T05:38:36.653Z","updated_at":"2025-11-04T14:30:40.905Z","avatar_url":"https://github.com/baponkar.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Static Badge](https://img.shields.io/badge/aws-tutorial?logo=amazon\u0026labelColor=black\u0026color=black)\n](https://aws.amazon.com/)\n![Static Badge](https://img.shields.io/badge/Ubuntu-24.04%20LTS-maker?logo=ubuntu\u0026color=blue\u0026cacheSeconds=https%3A%2F%2Fubuntu.com%2Fdesktop%2Fwsl)\n![Static Badge](https://img.shields.io/badge/Windows-11-maker?logo=windows\u0026color=blue\u0026cacheSeconds=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fwindows%2Fwsl%2Finstall)\n![Static Badge](https://img.shields.io/badge/nginx-server-maker?logo=nginx\u0026color=blue\u0026cacheSeconds=https%3A%2F%2Fnginx.org%2Fen%2F)\n\n\n\n\n# Host a Website in Amazom Web Service(aws) \n\n## Description :\nIn this article I am giving practical process to host a Ubuntu Nginx server in aws Ubuntu EC2 Instance. You need a aws account and a local Ubuntu Machine.I install Ubuntu envirionment in Windows via wsl.\n\n## aws account setup :\n\n1. Creating an aws account from [here](https://aws.amazon.com/)\n2. Creating a Ubuntu 24.04 LTS EC2 Instance and connect and run then install NGINX and run following way\n* N.B : Don't forget to open port 80 and 443 port during ec2 creation process.Generally default ssh port is open but you need to check http as wel as https port also.\n3. After creating Ubuntu EC2 Instances Run following commands in web based EC2 Terminal\n\n```bash\n    sudo apt update\n    sudo apt upgrade\n    sudo apt autoclean\n    sudo apt autoremove\n    sudo apt install ssh\n```\n\n## Installing and Run NGINX Server in Ubuntu 24.4 LTS\n\n### SSH Conection:\n\nIf You are in ![Static Badge](https://img.shields.io/badge/Linux-maker?logo=linux\u0026color=blue)\n    then don't need to install wsl but may need to install ssh by ```sudo apt install ssh``` and follow.\n\n    If you are in ![Static Badge](https://img.shields.io/badge/Windows-11-maker?logo=windows\u0026color=blue\u0026cacheSeconds=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fwindows%2Fwsl%2Finstall)\n then you need to install Ubuntu system in your windows machine otherwise you are not able to access all bash commands in Windows terminal.\n\n    You need to run following commands in your Windows Terminal which is started as '**Run as Administrator**' \n\n    ```bash\n        wsl --install\n    ```\n    Which give available windows sub system option then install ubuntu by following command and install the distro in current directory\n    ```bash\n        wsl --install -d \u003cDistro\u003e\n    ```\n    Then Set username and password now your machine is ready for ssh\n\n    One important thing supposo You want to change directory in a windows path \"B:\\Web_Projects\\aws_project\" then you need to type\n\n    ```bash\n        cd /mnt/b/Web_Projects/aws_project #add /mnt/ before all windows path\n    ```\n\n    * SSH Connection :\n        Suppose You have created and downloaded \"keypair.pem\" and your public dns id is public_dns then \n    ```bash\n        cd keypair.pem_directory\n        chmod 400 \"keypair.pem\" #making executable\n        sudo apt uupdate #for updating packages\n        sudo apt upgrade -y #for upgrading packages\n        sudo apt autoremove -y #for remove broken packages\n        sudo apt autoclean -y #clean broken packages\n        sudo apt install ssh #installing ssh in system\n        sudo ssh -i \"keypair.pem\" public_dns #access remotely ec2\n    ```\n\n    If You see ```ssh: connect to host ec2-**-***-***-***.ap-****-1.compute.amazonaws.com port 22: Network is unreachable``` then check network connection, keyvalue pair file location.\n    \n----------------------------------------------\n\n## NGINX server setup\nAfter making successfull ssh connection with your local linux machine and aws ec2 then run this commands.\n\n1. Installing nginx \n\n    ```bash\n    sudo apt update\n    sudo apt upgrade\n    sudo apt install nginx\n    ```\n\n2. List of applications are allow by ufw(Firewall service)\n    ```bash\n    sudo ufw app list\n\n    Output\n    Available applications:\n    Nginx Full\n    Nginx HTTP\n    Nginx HTTPS\n    OpenSSH\n    ```\n    \n\n3. Allowing Traffic only on port 80 . If you want to open 443 then you need to type ```sudo ufw allow 'Nginx Full'```\n    ```bash\n    sudo ufw allow 'Nginx HTTP'\n    sudo ufw enable\n    ```\n\n4. Checking Status\n    ```bash\n    sudo ufw status\n    Output\n    Status: active\n\n    To                         Action      From\n    --                         ------      ----\n    OpenSSH                    ALLOW       Anywhere                  \n    Nginx HTTP                 ALLOW       Anywhere                  \n    OpenSSH (v6)               ALLOW       Anywhere (v6)             \n    Nginx HTTP (v6)            ALLOW       Anywhere (v6)\n    ```\n\n    If output is shown ```inactive``` then you need to enable ufw in your instance by ```sudo ufw enable``` . After that your EC2 instance not work in browser then you need to access the EC2 instance by ssh through Ubuntu shell.\n\n    \n\n\n\n5. Checking Web Server\n\n    ```bash\n    systemctl status nginx\n\n    Output\n    ● nginx.service - A high performance web server and a reverse proxy server\n    Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)\n    Active: active (running) since Fri 2020-04-20 16:08:19 UTC; 3 days ago\n        Docs: man:nginx(8)\n    Main PID: 2369 (nginx)\n        Tasks: 2 (limit: 1153)\n    Memory: 3.5M\n    CGroup: /system.slice/nginx.service\n            ├─2369 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;\n            └─2380 nginx: worker process\n    ```\n\n6. Get Web Server Public IP\n    ```bash\n    curl -4 icanhazip.com\n    ```\n\n7. See Your Website on ```http://your_server_ip```\n\n8. You will see\n\n    ![NGINX Welcome Server ](./Image/nginx_server_welcome.png)\n\nSuccess! Congratulations your public website is  live.\n\n## Add Domain in Your webservice:\n\n10. First you need to buy a domain from domain selling portal as for example I have purchase a domain from [here](https://www.namecheap.com/) with cheap price 101 rupee for one year. You can try Godady.com . Once There was Freenom site which gave free domain for one year but now I am not able to get a free domain from there. Custom Webpage with custom domain 'your_domain'.\n```bash\n    sudo mkdir -p /var/www/your_domain/html\n    sudo chown -R $USER:$USER /var/www/your_domain/html\n    sudo chmod -R 755 /var/www/your_domain\n    sudo nano /var/www/your_domain/html/index.html\n```\nput custom webpage ```index.html``` file inside of '/var/www/your_domain/html/'\n\n```\n    \n    (html)\n        \u003chtml\u003e\n        \u003chead\u003e\n            \u003ctitle\u003eWelcome to your_domain!\u003c/title\u003e\n        \u003c/head\u003e\n        \u003cbody\u003e\n            \u003ch1\u003eSuccess!  The your_domain server block is working!\u003c/h1\u003e\n        \u003c/body\u003e\n    \u003c/html\u003e\n\n```\n\n```CTRL+X``` to save the file in nano editor.\n\n```bash\n    sudo nano /etc/nginx/sites-available/your_domain\n````\n\nChange your_domain with actual domain name.\n\n```bash\n    server {\n        listen 80;\n        listen [::]:80;\n\n        root /var/www/your_domain/html;\n        index index.html index.htm index.nginx-debian.html;\n\n        server_name your_domain www.your_domain;\n\n        location / {\n                try_files $uri $uri/ =404;\n        }\n    }\n```\nCreating a link of /etc/nginx/sites-available/your_domain into etc/nginx/sites-enabled/ location.\n\n```bash\n    sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/\n```\n\n```bash\n    sudo nano /etc/nginx/nginx.conf\n```\n\nremove ```#``` in front of ```server_names_hash_bucket_size```.\n\n```bash\n    sudo nginx -t #Checking nginx syntax\n\n    sudo systemctl restart nginx #restart nginx\n```\n\n## Server Log\n- /var/log/nginx/access.log: Every request to your web server is recorded in this log file unless Nginx is configured to do otherwise.\n\n- /var/log/nginx/error.log: Any Nginx errors will be recorded in this log.\n\n![Success Domain Website](Image/success_domain.png)\n\n## Credit\n\n![Static Badge](https://img.shields.io/badge/digitalOcean-article-maker?logo=digitalocean\u0026logoColor=white\u0026labelColor=blue\u0026color=black\u0026cacheSeconds=https%3A%2F%2Fwww.digitalocean.com%2Fcommunity%2Ftutorials%2Fhow-to-install-nginx-on-ubuntu-20-04)\n\n\n\n## For Question :\n![Gmail](https://img.shields.io/badge/Gmail-baponkar%40gmail.com-red?logo=gmail)\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaponkar%2Faws-ubuntu-nginx-server-host","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaponkar%2Faws-ubuntu-nginx-server-host","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaponkar%2Faws-ubuntu-nginx-server-host/lists"}