{"id":20371578,"url":"https://github.com/atulkamble/azure-ubuntu-webserver-setup","last_synced_at":"2025-03-04T20:27:52.020Z","repository":{"id":252900416,"uuid":"806415507","full_name":"atulkamble/azure-ubuntu-webserver-setup","owner":"atulkamble","description":"This project provides step-by-step guide for setting up a full website on an Azure Ubuntu Virtual Machine. ","archived":false,"fork":false,"pushed_at":"2024-08-13T06:44:10.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T10:48:28.593Z","etag":null,"topics":["apache","azure","azurecli","azurevm","ubuntu","ubuntu-server","webserver"],"latest_commit_sha":null,"homepage":"http://linkedin.com/in/atuljkamble","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atulkamble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":"atulkamble"}},"created_at":"2024-05-27T06:50:40.000Z","updated_at":"2024-08-13T06:44:13.000Z","dependencies_parsed_at":"2024-08-13T07:52:19.789Z","dependency_job_id":null,"html_url":"https://github.com/atulkamble/azure-ubuntu-webserver-setup","commit_stats":null,"previous_names":["atulkamble/azure-ubuntu-webserver-setup"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fazure-ubuntu-webserver-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fazure-ubuntu-webserver-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fazure-ubuntu-webserver-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atulkamble%2Fazure-ubuntu-webserver-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atulkamble","download_url":"https://codeload.github.com/atulkamble/azure-ubuntu-webserver-setup/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241916699,"owners_count":20041963,"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":["apache","azure","azurecli","azurevm","ubuntu","ubuntu-server","webserver"],"created_at":"2024-11-15T01:08:35.416Z","updated_at":"2025-03-04T20:27:51.993Z","avatar_url":"https://github.com/atulkamble.png","language":"HTML","funding_links":["https://github.com/sponsors/atulkamble"],"categories":[],"sub_categories":[],"readme":"# Deploy a Full Website on Azure Ubuntu VM \n# Clone repo\n```\ngit clone https://github.com/atulkamble/azure-ubuntu-webserver-setup.git\ncd azure-ubuntu-webserver-setup\n```\n\nDetailed step-by-step guide to creating an Azure Linux VM with Ubuntu, installing a web server, and deploying a full website using Azure CLI and shell scripting.\n\n### Clone this Project\n```\ngit clone https://github.com/atulkamble/AzureWebsiteProject.git\ncd AzureWebsiteProject\n```\n\n### Prerequisites\n\n1. **Install Azure CLI**: If you haven't installed the Azure CLI, follow the instructions [here](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli).\n2. **Login to Azure**: Open your terminal and run:\n   ```sh\n   az login\n   ```\n\n### Step 1: Create Resource Group\n\nFirst, create a resource group to hold your resources:\n\n```sh\nRESOURCE_GROUP=\"MyResourceGroup\"\nLOCATION=\"eastus\"\n\naz group create --name $RESOURCE_GROUP --location $LOCATION\n```\n\n### Step 2: Create a Virtual Machine\n\n1. **Create VM:**\n   ```sh\n   VM_NAME=\"MyUbuntuVM\"\n   IMAGE=\"UbuntuLTS\"\n   ADMIN_USERNAME=\"azureuser\"\n   SSH_KEY_PATH=\"$HOME/.ssh/id_rsa.pub\"\n\n   az vm create \\\n     --resource-group $RESOURCE_GROUP \\\n     --name $VM_NAME \\\n     --image $IMAGE \\\n     --admin-username $ADMIN_USERNAME \\\n     --ssh-key-value $SSH_KEY_PATH \\\n     --output json \\\n     --verbose\n   ```\n\n2. **Open Port 80 for Web Traffic:**\n   ```sh\n   az vm open-port --resource-group $RESOURCE_GROUP --name $VM_NAME --port 80\n   ```\n\n### Step 3: Install Apache Web Server and Deploy Website\n\n1. **Get Public IP Address:**\n   ```sh\n   PUBLIC_IP=$(az vm show --show-details --resource-group $RESOURCE_GROUP --name $VM_NAME --query publicIps -o tsv)\n   ```\n\n2. **Create Website Files:**\n\n   Create a directory for your website files:\n\n   ```sh\n   mkdir mywebsite\n   cd mywebsite\n   ```\n\n   Create an `index.html` file:\n\n   ```html\n   \u003c!DOCTYPE html\u003e\n   \u003chtml\u003e\n   \u003chead\u003e\n       \u003ctitle\u003eMy Azure VM Website\u003c/title\u003e\n   \u003c/head\u003e\n   \u003cbody\u003e\n       \u003ch1\u003eHello from Azure VM!\u003c/h1\u003e\n       \u003cp\u003eWelcome to my website hosted on an Azure VM with Ubuntu and Apache.\u003c/p\u003e\n   \u003c/body\u003e\n   \u003c/html\u003e\n   ```\n\n3. **Deploy Website to VM:**\n\n   Upload your website files to the VM:\n\n   ```sh\n   scp -o \"StrictHostKeyChecking no\" -r * $ADMIN_USERNAME@$PUBLIC_IP:/tmp/\n   ```\n\n4. **Install Apache and Move Website Files:**\n\n   Connect to the VM and install Apache, then move the website files to the Apache directory:\n\n   ```sh\n   ssh -o \"StrictHostKeyChecking no\" $ADMIN_USERNAME@$PUBLIC_IP \u003c\u003cEOF\n   sudo apt update\n   sudo apt install apache2 -y\n   sudo systemctl start apache2\n   sudo systemctl enable apache2\n   sudo mv /tmp/* /var/www/html/\n   EOF\n   ```\n\n### Step 4: Verify the Website\n\n1. **Open a Web Browser:**\n   - Navigate to the public IP address of your VM: `http://\u003cPUBLIC_IP\u003e`\n   - You should see the website content you created in `index.html`.\n\n### Step 5: Secure Your Website with HTTPS (Optional)\n\n1. **Install Certbot and Obtain SSL Certificate:**\n   ```sh\n   ssh $ADMIN_USERNAME@$PUBLIC_IP \u003c\u003cEOF\n   sudo apt install certbot python3-certbot-apache -y\n   sudo certbot --apache --non-interactive --agree-tos --email your-email@example.com -d your-domain.com\n   EOF\n   ```\n\n2. **Update DNS Records:**\n   - Ensure your domain's DNS records point to your VM's public IP address.\n\n### Complete Script\n\nHere’s a complete script that automates the above steps:\n\n```sh\n#!/bin/bash\n\n# Variables\nRESOURCE_GROUP=\"MyResourceGroup\"\nLOCATION=\"eastus\"\nVM_NAME=\"MyUbuntuVM\"\nIMAGE=\"UbuntuLTS\"\nADMIN_USERNAME=\"azureuser\"\nSSH_KEY_PATH=\"$HOME/.ssh/id_rsa.pub\"\nDOMAIN=\"your-domain.com\"\nEMAIL=\"your-email@example.com\"\n\n# Create Resource Group\naz group create --name $RESOURCE_GROUP --location $LOCATION\n\n# Create VM\naz vm create \\\n  --resource-group $RESOURCE_GROUP \\\n  --name $VM_NAME \\\n  --image $IMAGE \\\n  --admin-username $ADMIN_USERNAME \\\n  --ssh-key-value $SSH_KEY_PATH \\\n  --output json \\\n  --verbose\n\n# Open Port 80\naz vm open-port --resource-group $RESOURCE_GROUP --name $VM_NAME --port 80\n\n# Get Public IP\nPUBLIC_IP=$(az vm show --show-details --resource-group $RESOURCE_GROUP --name $VM_NAME --query publicIps -o tsv)\n\n# Create website files\nmkdir mywebsite\ncd mywebsite\necho '\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003eMy Azure VM Website\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003ch1\u003eHello from Azure VM!\u003c/h1\u003e\n    \u003cp\u003eWelcome to my website hosted on an Azure VM with Ubuntu and Apache.\u003c/p\u003e\n\u003c/body\u003e\n\u003c/html\u003e' \u003e index.html\n\n# Deploy website to VM\nscp -o \"StrictHostKeyChecking no\" -r * $ADMIN_USERNAME@$PUBLIC_IP:/tmp/\n\n# Install Apache and move website files\nssh -o \"StrictHostKeyChecking no\" $ADMIN_USERNAME@$PUBLIC_IP \u003c\u003cEOF\nsudo apt update\nsudo apt install apache2 -y\nsudo systemctl start apache2\nsudo systemctl enable apache2\nsudo mv /tmp/* /var/www/html/\nEOF\n\n# Optionally secure the website with HTTPS\nssh -o \"StrictHostKeyChecking no\" $ADMIN_USERNAME@$PUBLIC_IP \u003c\u003cEOF\nsudo apt install certbot python3-certbot-apache -y\nsudo certbot --apache --non-interactive --agree-tos --email $EMAIL -d $DOMAIN\nEOF\n\necho \"Website is available at http://$PUBLIC_IP\"\n```\n\n### Running the Script\n\n1. **Save the script to a file, e.g., `create-azure-vm-with-website.sh`.**\n2. **Make the script executable:**\n   ```sh\n   chmod +x create-azure-vm-with-website.sh\n   ```\n3. **Run the script:**\n   ```sh\n   ./create-azure-vm-with-website.sh\n   ```\n\nBy following these steps and running the provided script, you will have an Ubuntu server running on an Azure VM with Apache installed, hosting a complete website. You can further customize the script and your website as needed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkamble%2Fazure-ubuntu-webserver-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatulkamble%2Fazure-ubuntu-webserver-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatulkamble%2Fazure-ubuntu-webserver-setup/lists"}