Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/atulkamble/azure-ubuntu-webserver-setup

This project provides step-by-step guide for setting up a full website on an Azure Ubuntu Virtual Machine.
https://github.com/atulkamble/azure-ubuntu-webserver-setup

apache azure azurecli azurevm ubuntu ubuntu-server webserver

Last synced: about 1 month ago
JSON representation

This project provides step-by-step guide for setting up a full website on an Azure Ubuntu Virtual Machine.

Awesome Lists containing this project

README

        

# Deploy a Full Website on Azure Ubuntu VM
# Clone repo
```
git clone https://github.com/atulkamble/azure-ubuntu-webserver-setup.git
cd azure-ubuntu-webserver-setup
```

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

### Clone this Project
```
git clone https://github.com/atulkamble/AzureWebsiteProject.git
cd AzureWebsiteProject
```

### Prerequisites

1. **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).
2. **Login to Azure**: Open your terminal and run:
```sh
az login
```

### Step 1: Create Resource Group

First, create a resource group to hold your resources:

```sh
RESOURCE_GROUP="MyResourceGroup"
LOCATION="eastus"

az group create --name $RESOURCE_GROUP --location $LOCATION
```

### Step 2: Create a Virtual Machine

1. **Create VM:**
```sh
VM_NAME="MyUbuntuVM"
IMAGE="UbuntuLTS"
ADMIN_USERNAME="azureuser"
SSH_KEY_PATH="$HOME/.ssh/id_rsa.pub"

az vm create \
--resource-group $RESOURCE_GROUP \
--name $VM_NAME \
--image $IMAGE \
--admin-username $ADMIN_USERNAME \
--ssh-key-value $SSH_KEY_PATH \
--output json \
--verbose
```

2. **Open Port 80 for Web Traffic:**
```sh
az vm open-port --resource-group $RESOURCE_GROUP --name $VM_NAME --port 80
```

### Step 3: Install Apache Web Server and Deploy Website

1. **Get Public IP Address:**
```sh
PUBLIC_IP=$(az vm show --show-details --resource-group $RESOURCE_GROUP --name $VM_NAME --query publicIps -o tsv)
```

2. **Create Website Files:**

Create a directory for your website files:

```sh
mkdir mywebsite
cd mywebsite
```

Create an `index.html` file:

```html



My Azure VM Website


Hello from Azure VM!


Welcome to my website hosted on an Azure VM with Ubuntu and Apache.




```

3. **Deploy Website to VM:**

Upload your website files to the VM:

```sh
scp -o "StrictHostKeyChecking no" -r * $ADMIN_USERNAME@$PUBLIC_IP:/tmp/
```

4. **Install Apache and Move Website Files:**

Connect to the VM and install Apache, then move the website files to the Apache directory:

```sh
ssh -o "StrictHostKeyChecking no" $ADMIN_USERNAME@$PUBLIC_IP <`
- You should see the website content you created in `index.html`.

### Step 5: Secure Your Website with HTTPS (Optional)

1. **Install Certbot and Obtain SSL Certificate:**
```sh
ssh $ADMIN_USERNAME@$PUBLIC_IP <

My Azure VM Website

Hello from Azure VM!


Welcome to my website hosted on an Azure VM with Ubuntu and Apache.

' > index.html

# Deploy website to VM
scp -o "StrictHostKeyChecking no" -r * $ADMIN_USERNAME@$PUBLIC_IP:/tmp/

# Install Apache and move website files
ssh -o "StrictHostKeyChecking no" $ADMIN_USERNAME@$PUBLIC_IP <