Skip to content

Instantly share code, notes, and snippets.

@micah1701
Created November 4, 2025 02:29
Show Gist options
  • Select an option

  • Save micah1701/00bd95001b9cfe0cedcb088c13684a24 to your computer and use it in GitHub Desktop.

Select an option

Save micah1701/00bd95001b9cfe0cedcb088c13684a24 to your computer and use it in GitHub Desktop.
These are the steps I always forget to do in the right order when configuring a Cloud Instance for use web server. Steps include adding PHP, Node, and other important libraries and extensions.

πŸ–₯️ Setting Up Cloud Instance Ubuntu Server from Scratch

Environment: Ubuntu 25.04 with SSH access

Starting Point: Logged in as Root User on a new installation


πŸ‘€ Create a Non-Root Sudo User

~$ adduser your_username

~$ usermod -aG sudo your_username

To give the new user the same SSH key (if you are the only user):

~$ cat /root/.ssh/authorized_keys >> /home/your_username/.ssh/authorized_keys

πŸ”„ Switch User

~$ exit

Log back in from local shell:

ssh -i /path/to/ssh/key your_username@cloudIP

🌐 Install Apache

~$ sudo apt update
~$ sudo apt upgrade
~$ sudo apt install apache2

🧰 Install PHP (with common modules)

~$ sudo apt install php php-cli php-common php-mysql php-mbstring php-xml php-zip php-gd php-curl php-pear php-dev

~$ sudo apt install libapache2-mod-php

~$ sudo apt install imagemagick php-imagick

If php-pear or php-dev were not installed:

~$ sudo apt install php-pecl
~$ sudo apt install php-dev

πŸ—ƒοΈ Install Microsoft SQL Server Support (optional)

~$ sudo apt install unixodbc-dev
~$ sudo pecl install sqlsrv
~$ sudo pecl install pdo_sqlssrv

Update PHP configuration:

~$ sudo su
~$ printf "; priority=20\\nextension=sqlsrv.so\\n" > /etc/php/8.4/mods-available/sqlsrv.ini
~$ printf "; priority=30\\nextension=pdo_sqlssrv.so\\n" > /etc/php/8.4/mods-available/pdo_sqlssrv.ini
~$ exit

Enable extensions:

Use phpenmod and phpdismod instead of directly updating php.ini

~$ sudo phpenmod sqlsrv
~$ sudo phpenmod pdo_sqlssrv

πŸ”‘ Add Microsoft Repository Key

This step may-or-may not be neccessary. apt-key was deprecated in Ubuntu 25.04 and key files are stored by their given package name.

~$ sudo mkdir -p /usr/share/keyrings/
~$ curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg

πŸ“¦ Install Microsoft Package Manager

~$ curl -sSL -O https://packages.microsoft.com/config/ubuntu/25.04/packages-microsoft-prod.deb
~$ sudo dpkg -i packages-microsoft-prod.deb
~$ rm packages-microsoft-prod.deb
~$ sudo apt-get update

Install ODBC drivers and tools:

~$ sudo ACCEPT_EULA=Y apt-get install -y msodbcsq/18
~$ sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18

Make sqlcmd tools accessible:

~$ echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
~$ source ~/.bashrc

🧬 Install Git

~$ sudo apt install git

🎼 Install Composer

~$ curl -sS https://getcomposer.org/installer -o composer-setup.php
~$ sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
~$ rm composer-setup.php

🟒 Install Node.js & NPM

Install Node Version Manager (NVM):

~$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash

Then restart terminal and install Node:

~$ nvm install node

🌍 Add a Website

Create your website folder and an index file in /var/www/foldername

/var/www/html is the default site and loads via IP if no domain is set.

Alternatively, mount content to /var/www.


πŸ‘₯ Adjust Group Permissions (optional)

Set ownership and permissions:

~$ sudo chgrp -R new_group_name /var/www/
~$ sudo chmod -R g+w /var/www/
~$ sudo usermod -a -G www-data your_username

View groups:

~$ groups
# or...
~$ sudo groups your_username

βš™οΈ Configure Apache Virtual Hosts

Create .conf file in:


/etc/apache2/sites-available/

Enable your site:

~$ sudo a2ensite your_new_site.conf

πŸ“– Reference:

DigitalOcean - Set Up Apache Virtual Hosts on Ubuntu 20.04


πŸ”’ Add Lets Encrypt SSL

~$ sudo apt update

~$ sudo apt install certbot python3-certbot-apache

~$ sudo certbot --apache

πŸ“– Reference:

DigitalOcean - Secure Apache with Lets Encrypt


🧱 Additional References


☁️ Cloud Terminology

  • Instance β†’ Virtual server

  • Image β†’ OS (e.g., Ubuntu 22) + Setup

  • Volume β†’ Storage drive (like D:\\), usually mounted at /mnt/foldername

    • If mounted at /, it serves as the root storage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment