Creating a Web Development Platform with LAMP on Ubuntu

Intended Audience:

Web Developers creating a web development platform that utilizes the following tech stack:

  • VPS Server (w/DirectAdmin)
  • LAMP (Linux (Ubuntu)/Apache/MySQL/PHP)
  • git with GitLab
  • Composer
  • npm / yarn
  • Laravel
  • Vue

Context

I am a web developer who is a solopreneur/entreprogrammer working with open-source technologies.

My setup and tech stack includes the following:

  • I manage my projects between GitLab, Trello, and Diagrams
  • My desktop is a Ubuntu-based LAMP server and laptop is a MacBook Air
  • I write code in VSCode, use git to push code to my Production server(s) and central repo’s at GitLab
  • I script/automate whatever I can with shell scripts using bash
  • Coffee, cafe’s, and cafe patios

Web Development Platform

The web development infrastructure that I use consists of:

Servers:

  • Production Environment (PROD)
  • Testing Environment (UAT)
  • Development Environment (localhost)

Production Environment

My Production Environment is served from a VPS account that is fully managed by the fine folks over at KnownHost. The benefit to having fully managed hosting is that rather than me completing the work required on the production server myself, I can submit support tickets to have them complete the work for me. A ticket is usually closed off within minutes, freeing up my time to work on other tasks (esp if something breaks in the process that they end up fixing). I find it to be a necessary expense to be able to outsource my Production “IT department” (but I still have to maintain my own local development environment myself).

We need to create a server that can process http requests that are made when a user (human or otherwise) makes a request to our web server.

What happens when a user tries to access our website:

  1. http request made to codingwithcoffee.net
  2. DNS lookup for IP address
  3. Routed to network -> server on network
  4. webhost is found, processed, and response is sent back

My preference has always been to develop on the target platform of my production servers, and “natively” in the OS (as opposed to using a virtual machine like VMWare or Vagrant). This will most likely change onces I get to the point of moving towards containerization – but I am not at that point yet as a solopreneur.

The nice thing about setting up the LAMP Server, is that you don’t have to remember to go and start all of those PHP-based(?) services. They are already up and running, and hopefully, there’s a variable stored within the code to make it easy to swap out what environment you are working on: ie: localhost:8000 can be http://dev.shoppingcart or http://shoppingcart.dev or just http://shoppingcart/

Why a VM vs locally developing?

Let the world push you into complexity.

So I’m trying to wait until it’s necessary to implement other things in my development workflow.

  • CI/CD
  • Unit Testing

My Steps to Installing a VPS Production Server:

  1. Register VPS
  2. Create website on VPS account
  3. setup git process

Create a Web Development Workstation on Ubuntu:

  1. Install Base OS (Ubuntu) || Install Ubuntu on VMWare Guide
    1. sudo mkdir ~/web
    1. sudo chmod -R 777 ~/web
  2. Install and Configure git on Ubuntu Guide
    • ssh-keygen -t ed25519 -C “<comment>”
    • nano ~/.ssh/id_ed25519.pub #copy to GitLab account
    • git clone git@gitlab.com:sipofwater/scripts.git ~/web/scripts
  3. Ubuntu Software -> vscode -> install
  4. Install and Configure a LAMP Server on Ubuntu Guide
    1. bash ~/web/scripts/webserver/installwebserver.sh
  5. Implement Backup Guide

References: