Set up your full-stack workstation
In WEB-201 you needed a browser, an editor and Node to build the Walk Planner. A back end needs more: a programming language that runs on the server, a database server, a package manager for the language, and tools to look inside the database. Before the course can teach any of them, they must be installed, configured and talking to each other on your own computer. That is this module's whole job.
By the end of it you will have PHP 8.5, Composer 2, PostgreSQL 18, Node.js, Git and VS Code working together inside Linux, either on Linux Mint directly or on Windows through WSL 2. You will have created the database the Walk Office uses for the rest of the course, mandlas_walks, owned by its own login role, walks_app. And you will have proved the whole chain works with two small PHP pages, one showing how PHP is set up and one reading the PostgreSQL version through a real database connection. Mandla's Mountain Walks and everyone in it are invented for the course, as in WEB-201.
Why a full-stack developer works in Linux
A full-stack developer builds both halves of a web application: the front end that runs in the browser, which WEB-201 taught, and the back end that runs on a server, receives requests, applies the business rules and keeps the data. The servers that run PHP applications such as the Walk Office are almost always Linux machines. In Module 12 you will deploy the Walk Office to an Ubuntu Server virtual machine with Nginx, PHP-FPM and PostgreSQL, and in Module 13 you will write a Bash script that installs it.
Developing on the same kind of system you deploy to removes a whole class of surprises. On Linux, file names are case-sensitive, so Walk.php and walk.php are different files. Files have owners and permissions that decide who may read, write or run them. Programs come from the same packages your server will use. PHP and PostgreSQL do run on Windows directly, but every difference between your machine and the server is a bug waiting to happen.
- Distribution
- A complete Linux system built around the Linux kernel, with its own installer, desktop and packages. Ubuntu and Linux Mint are distributions, and Mint is built on Ubuntu.
- Package and package manager
- A package is a program prepared for installing, with a list of the other packages it needs. On Ubuntu and Mint the package manager is
apt, which downloads packages, installs them with what they need, and updates them later. - Repository
- A server that offers packages to
apt. Your distribution has its own, and you can add others, such as the PostgreSQL project's. - LTS
- Long-Term Support. Ubuntu releases an LTS version every two years, such as 24.04 (April 2024) and 26.04 (April 2026), and supports each for at least five years.
- sudo
- Runs one command as the administrator, called root on Linux, after asking for your own password. You need it to install software and change system settings, never to edit your own projects.
The tools you will install
| Tool | Version taught | What it does | First used |
|---|---|---|---|
| PHP | 8.5 | Runs the back-end code, and includes a small web server for development | Module 3 |
| Composer | 2 (2.11.1 on 2 November 2026) | Installs PHP libraries and frameworks, such as Laravel | Module 5 |
| PostgreSQL | 18 | The database server, with psql, its command-line client | Module 1 |
| pgAdmin or DBeaver | Current release | Optional graphical database clients | Module 1 |
| Node.js | 26 LTS, through nvm | Runs the front-end build tools Laravel uses | Module 6 |
| Git and GitHub | As in WEB-201 | Version control, branches and pull requests | This module |
| VS Code | Current release | Your editor, with extensions for PHP, PostgreSQL and EditorConfig | This module |
Two routes: Linux Mint or Windows with WSL 2
You need a Linux system, and there are two good ways to have one. Choose the one that matches the computer you already use.
| Route A: Linux Mint | Route B: Windows with WSL 2 | |
|---|---|---|
| Who it suits | You already use Linux Mint, as many WEB-201 learners did | You use Windows 10 or 11 and want to keep it |
| Linux version | Linux Mint 22.3, built on Ubuntu 24.04 | Ubuntu 26.04 LTS, inside Windows |
| Where PHP 8.5 comes from | An extra repository, because Ubuntu 24.04 has PHP 8.3 | Ubuntu's own packages |
| Where PostgreSQL 18 comes from | The PostgreSQL apt repository | The PostgreSQL apt repository |
| Editor and browser | Linux versions | Windows versions, connected to Linux |
Both routes end with the same tools, the same versions, the same folder layout and the same commands from then on. Where the course shows one command for both, it works on both.
Route A: Linux Mint
Linux Mint 22.3 "Zena", released in January 2026, is built on Ubuntu 24.04 LTS, whose code name is noble. The next major Mint release, built on Ubuntu 26.04, is planned for about Christmas 2026. If you install it later, follow Route B's PHP instructions, because its base has PHP 8.5 built in, and give the PostgreSQL script resolute, Ubuntu 26.04's code name, where this module says noble. Start by bringing your system up to date in a terminal:
$ sudo apt update && sudo apt upgrade -y
$ grep -E '^(NAME|VERSION_CODENAME|UBUNTU_CODENAME)=' /etc/os-release
NAME="Linux Mint"
VERSION_CODENAME=zena
UBUNTU_CODENAME=noble
That second command matters. Mint has its own code name, zena, but extra repositories are built for Ubuntu and know only Ubuntu's names. When a set-up script complains that it does not recognise zena, you give it noble instead, as you will do for PostgreSQL below.
Route B: Windows with WSL 2
WSL (Windows Subsystem for Linux) runs a real Linux system inside Windows. Version 2 runs a genuine Linux kernel in a lightweight virtual machine that starts in a second or two, shares your network and can see your Windows files. You type Linux commands in a Linux terminal, and you use your normal Windows browser and VS Code. Microsoft built it for exactly this: developers who want Linux tools on a Windows PC.
You need Windows 11, or Windows 10 version 2004 (build 19041) or later, and virtualisation switched on in your PC's firmware settings, which it usually is. Windows 10 reached the end of its support on 14 October 2025, so use Windows 11 if your PC can run it.
- Open PowerShell as administrator. Right-click the Start button, choose Terminal (Admin) or Windows PowerShell (Admin), and accept the prompt.
- Install WSL and Ubuntu. Type
wsl --installand press Enter. This turns on the Windows features WSL needs and installs Ubuntu, which on 2 November 2026 means Ubuntu 26.04.1 LTS. Restart Windows when it asks. - Create your Linux user. Ubuntu opens after the restart, or from the Start menu. Choose a short user name in lower case, such as
lerato, and a password. Nothing appears while you type the password, which is normal on Linux. This account is separate from your Windows account, and its password is the onesudoasks for. - Update Ubuntu. In the Ubuntu terminal, run
sudo apt update && sudo apt upgrade -y. - Check from Windows. In an ordinary PowerShell window, run
wsl -l -v. Ubuntu should be listed with VERSION 2.
PS> wsl -l -v
NAME STATE VERSION
* Ubuntu Running 2
PS> wsl --update # update WSL itself
PS> wsl --shutdown # stop every running Linux system
If wsl --install only prints its help text, WSL is already installed: run wsl --install -d Ubuntu-26.04 to add the Ubuntu this course uses. If you already have Ubuntu 24.04 in WSL, you can keep it and follow Route A's PHP instructions, because it is Mint's base too. An error mentioning virtualisation, such as 0x80370102, means it is off in your firmware settings, where it is called Intel VT-x or AMD SVM.
Work in the Linux file system, not /mnt/c
Inside WSL your Windows drives appear under /mnt, so your Windows user folder is /mnt/c/Users/lerato. It is tempting to keep projects there. Do not. Every file operation across that bridge is slow, which you will feel when Composer installs thousands of files. Linux permissions do not behave properly there, and tools that watch files for changes miss them. Keep all your work in your Linux home folder, ~, which is /home/lerato, in ~/projects.
You can still reach those files from Windows. Run explorer.exe . in the Ubuntu terminal to open the current folder in File Explorer, or type \\wsl.localhost\Ubuntu\home\lerato in its address bar. Copying a file across occasionally is fine. Working across the bridge all day is not.
Two things make this comfortable. First, a server running in WSL is reachable from Windows at localhost, so when PHP's development server listens on port 8000 in Ubuntu, Chrome or Edge on Windows opens http://localhost:8000. Second, VS Code's WSL extension splits the editor in two: the window you see runs on Windows, while a small VS Code Server runs inside Ubuntu, reading files, running the terminal and hosting the PHP extensions. Install VS Code on Windows only, never inside Ubuntu.
- Install the extension. In VS Code on Windows, open Extensions (Ctrl+Shift+X), search for "WSL" and install Microsoft's extension of that name.
- Open a Linux folder. In the Ubuntu terminal, go to a folder and type
code .. The first time, it installs the VS Code Server, then a VS Code window opens with "WSL: Ubuntu" in the green corner at the bottom left. - Install extensions on the right side. Language extensions, such as the PHP one below, must run where the code is. VS Code shows an "Install in WSL: Ubuntu" button for them.
Try it: find out where you are
In your Linux terminal, on either route, run uname -r, lsb_release -ds and pwd. On WSL the kernel name ends in microsoft-standard-WSL2, and pwd should show /home/ followed by your user name, not /mnt/c. On WSL, also run explorer.exe . and notice the address File Explorer shows.
Installing PHP 8.5
PHP is the language you will write the back end in from Module 3. A new major version arrives each November. PHP 8.5 was released on 20 November 2025, receives bug fixes until 31 December 2027 and security fixes until 31 December 2029. Its latest release on 2 November 2026 was 8.5.12, from 22 October 2026. Laravel 13, which you meet in Module 6, needs PHP 8.3 or later, so PHP 8.5 runs everything in the course.
PHP is a small core plus extensions, optional modules that add abilities such as talking to PostgreSQL. On Ubuntu and Mint each extension is a separate package, named php8.5- followed by the extension. These are the ones the course needs:
| Package | Gives PHP | Needed for |
|---|---|---|
php8.5-cli | The php command and its built-in web server | Everything |
php8.5-pgsql | The pgsql and pdo_pgsql extensions | Talking to PostgreSQL, from Module 4 |
php8.5-mbstring | Safe handling of text in any language and script, such as accented names | Laravel |
php8.5-xml | DOM, SimpleXML, XMLReader and XMLWriter | Laravel, PHPUnit |
php8.5-curl | HTTP requests to other servers | Composer, Laravel's HTTP client |
php8.5-zip | Reading zip archives | Composer downloads |
php8.5-intl | Formatting dates, numbers and money for a locale such as en_ZA | Laravel, displaying prices |
php8.5-bcmath | Exact arithmetic on large decimal numbers | Money calculations, some packages |
Install unzip too, which Composer uses to unpack downloads quickly.
PHP on Linux Mint 22: the ondrej/php repository
Ubuntu 24.04, and therefore Mint 22, comes with PHP 8.3. For newer versions, the long-standing source is a PPA (Personal Package Archive, an extra repository hosted on Ubuntu's Launchpad) kept by Ondrej Sury, who also packages PHP for Debian. It offers every supported PHP version for Ubuntu 22.04 and 24.04, and its packages follow PHP's own releases closely.
$ sudo add-apt-repository ppa:ondrej/php
You are about to add the following PPA: ...
Press [ENTER] to continue or Ctrl-c to cancel
$ sudo apt update
$ sudo apt install -y php8.5-cli php8.5-pgsql php8.5-mbstring \
php8.5-xml php8.5-curl php8.5-zip php8.5-intl php8.5-bcmath unzip
On Mint, add-apt-repository knows to use the Ubuntu name noble for the PPA, so no extra step is needed. The PPA's description says it is moving to a new home, packages.sury.org, and that Ubuntu 26.04 users should use that. Mint 22 and Ubuntu 24.04 users can keep using the PPA. Read its page before you add it, in case the advice has changed.
PHP on Ubuntu 26.04 in WSL
Ubuntu 26.04 includes PHP 8.5 in its own repositories, so you need no extra repository at all:
$ sudo apt install -y php8.5-cli php8.5-pgsql php8.5-mbstring \
php8.5-xml php8.5-curl php8.5-zip php8.5-intl php8.5-bcmath unzip
Ubuntu's PHP shows an older-looking release number, such as 8.5.4, than the PPA's. That does not mean it lacks fixes. Ubuntu's security team copies security fixes into the version it shipped, without changing the number. Either is fine for this course.
Checking PHP: php -v, php -m and php --ini
Three commands tell you what you have. php -v prints the version. php -m lists the loaded extensions, and grep filters the list to the ones you care about. php --ini shows which configuration files PHP read.
$ php -v
PHP 8.5.12 (cli) (built: ...) (NTS)
...
$ php -m | grep -E 'pgsql|mbstring|xml|curl|zip|intl|bcmath'
bcmath
curl
intl
libxml
mbstring
pdo_pgsql
pgsql
xml
xmlreader
xmlwriter
zip
$ php --ini
Configuration File (php.ini) Path: /etc/php/8.5/cli
Loaded Configuration File: /etc/php/8.5/cli/php.ini
Scan for additional .ini files in: /etc/php/8.5/cli/conf.d
Additional .ini files parsed: /etc/php/8.5/cli/conf.d/10-pdo.ini,
/etc/php/8.5/cli/conf.d/15-xml.ini,
...
If pdo_pgsql is missing from the list, the database pages later in this module fail with "could not find driver". Fix it now with sudo apt install php8.5-pgsql.
Where PHP's settings live
PHP reads its settings from a file called php.ini. On Ubuntu and Mint there is one per way of running PHP: /etc/php/8.5/cli/php.ini for the php command, including its built-in server, and later /etc/php/8.5/fpm/php.ini for PHP-FPM behind Nginx in Module 12. After the main file, PHP reads every .ini file in the matching conf.d folder in name order. That is how each extension package switches itself on, with a file such as 20-pdo_pgsql.ini holding one line, extension=pdo_pgsql.so.
Leave php.ini itself alone and add your own small file at the end of the order. Ubuntu's files start from PHP's production settings, which hide error messages from the browser. On your own machine you want to see them:
; Development settings for this machine only, never for a server
display_errors = On
error_reporting = E_ALL
date.timezone = Africa/Johannesburg
Create it with sudo nano /etc/php/8.5/cli/conf.d/99-dev.ini, or with sudo code if you prefer. Run php --ini again and it appears at the end of the list. The time zone makes PHP's dates match South African time instead of UTC, which matters as soon as Mandla's departures have start times.
Try it: ask PHP about itself
Run php -i | grep -E 'display_errors|date.timezone' before and after creating 99-dev.ini, and note the change. Then run php -r 'echo date("j F Y, H:i"), PHP_EOL;': the -r option runs one line of PHP, and the time it prints should be South African time.
Composer 2
Composer is PHP's package manager. A PHP project lists the libraries it needs in a file called composer.json, and Composer downloads them, and the libraries they need, into a vendor folder. Laravel itself is installed with Composer. Module 5 teaches it properly. Here you only install it.
Composer's official installer is a PHP script. Because you are about to run code from the internet, you first check that the file you downloaded is exactly the file Composer published. Composer publishes the installer's checksum, a long code calculated from the file's contents with the SHA-384 method. If even one byte of the file differed, its checksum would differ. Composer's own documentation gives these steps, which fetch the current checksum instead of one typed into the page:
$ cd ~
$ SIG_URL="https://composer.github.io/installer.sig"
$ EXPECTED="$(php -r "copy('$SIG_URL', 'php://stdout');")"
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ ACTUAL="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
$ [ "$EXPECTED" = "$ACTUAL" ] && echo "Installer verified" \
|| echo "Installer corrupt: do not run it"
Installer verified
$ php composer-setup.php
All settings correct for using Composer
Downloading...
Composer (version 2.11.1) successfully installed to: /home/lerato/composer.phar
Use it: php composer.phar
$ rm composer-setup.php
$ sudo mv composer.phar /usr/local/bin/composer
$ composer -V
Composer version 2.11.1 2026-10-30 14:52:10
PHP version 8.5.12 (/usr/bin/php8.5)
Run the "diagnose" command to get more detailed diagnostics output.
Moving composer.phar to /usr/local/bin/composer is the global install: that folder is on every user's search path, so composer works in any folder. It is the only Composer command that needs sudo. Never run sudo composer in a project, because the files it creates then belong to root and your own commands cannot change them. Notice that composer -V also reports which PHP it runs on. Update Composer later with sudo composer self-update.
One more line prepares for Module 6, where Composer installs command-line tools of its own into ~/.config/composer/vendor/bin. Add that folder to your search path in ~/.bashrc, then open a new terminal:
$ echo 'export PATH="$HOME/.config/composer/vendor/bin:$PATH"' >> ~/.bashrc
PostgreSQL 18
PostgreSQL is the database server the Walk Office uses. It runs in the background as a service, listens for connections on port 5432, and keeps its data in files only it may touch. Programs that talk to it, such as psql, pgAdmin and PHP, are its clients. PostgreSQL 18 was released on 25 September 2025 and is supported until November 2030. Its latest minor release on 2 November 2026 was 18.6.
Installing from the PostgreSQL apt repository
Ubuntu includes PostgreSQL, but each Ubuntu release freezes one major version for its whole life: 16 in Ubuntu 24.04 and Mint 22, and 18 in Ubuntu 26.04. The PostgreSQL project runs its own apt repository, called PGDG (PostgreSQL Global Development Group), with every supported version for every current Ubuntu LTS, updated as soon as each fix is released. The course uses it on both routes, so everyone has the same PostgreSQL 18 with the same updates. The postgresql-common package includes a script that adds the repository and its signing key for you:
$ sudo apt install -y postgresql-common
$ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
$ sudo apt install -y postgresql-18
$ sudo apt install -y postgresql-common
$ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh noble
$ sudo apt install -y postgresql-18
Without noble, the script on Mint stops with "Your system is using the distribution codename zena, but zena-pgdg does not seem to be a valid distribution", which is the code-name problem from Route A. Always install postgresql-18 by its number. The plain postgresql package means "the newest version", which from the PGDG repository will soon be PostgreSQL 19, whose first release candidate appeared on 15 October 2026.
Installing the package creates and starts a cluster, PostgreSQL's word for one running server with its own data folder and port. Ubuntu names clusters by version and name, so yours is 18/main.
$ pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
18 main 5432 online postgres /var/lib/postgresql/18/main /var/log/postgr...
$ sudo systemctl status postgresql --no-pager
$ psql --version
psql (PostgreSQL) 18.6 (Ubuntu 18.6-1.pgdg24.04+1)
If the status is down, start the cluster with sudo pg_ctlcluster 18 main start and read its log file for the reason.
The postgres superuser and your own role
PostgreSQL has its own users, called roles. A role that may log in is a login role, and a superuser role may do anything. Installation creates a superuser role called postgres, and a Linux account of the same name that owns the data files. You reach it by running psql as that Linux user with sudo -u postgres.
Typing sudo -u postgres every time soon gets tiresome, so create a role for yourself, named exactly like your Linux user, and a database of the same name, which psql opens by default:
$ psql
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432"
failed: FATAL: role "lerato" does not exist
$ sudo -u postgres createuser --superuser "$USER"
$ createdb "$USER"
$ psql -c 'SELECT current_user, current_database();'
current_user | current_database
--------------+------------------
lerato | lerato
(1 row)
The first error is the one almost everyone meets: psql logs in with a role named like your Linux user, and none existed. createuser and createdb are small programs that run the SQL for you. Your role is a superuser because this is your own development machine, where you will create and drop databases freely. The Walk Office will never use it: the application gets its own role with far fewer rights.
psql basics
psql is PostgreSQL's command-line client. You type SQL, which Module 1 teaches, and end each statement with a semicolon. You also type meta-commands, which start with a backslash, are handled by psql itself, and need no semicolon. These are the ones you need now:
| Meta-command | Does |
|---|---|
\l | Lists the databases, with their owners |
\c mandlas_walks | Connects to another database |
\dt | Lists the tables in the current database |
\du | Lists the roles and their attributes |
\conninfo | Says who you are connected as, to which database, and how |
\password walks_app | Sets a role's password without showing it or saving it in your history |
\? and \h | Help on meta-commands, and on SQL statements |
\q | Quits psql (Ctrl+D does too) |
The prompt tells you where you are: lerato=# means you are in the database lerato, and the # means you are a superuser. An ordinary role sees =>. If the prompt changes to lerato-#, psql is waiting for the rest of a statement because you forgot the semicolon: type ; and press Enter.
The Walk Office's role and database
The Walk Office connects to PostgreSQL as its own login role, walks_app, which is not a superuser, and its database, mandlas_walks, belongs to that role. Being the owner matters. Since PostgreSQL 15, ordinary roles may no longer create tables in another role's database by default: a role that is neither the owner nor given the right gets "permission denied for schema public". The owner may do anything inside its own database, which is exactly what the application needs during development, and nothing outside it.
lerato=# CREATE ROLE walks_app WITH LOGIN;
CREATE ROLE
lerato=# \password walks_app
Enter new password for user "walks_app":
Enter it again:
lerato=# CREATE DATABASE mandlas_walks OWNER walks_app;
CREATE DATABASE
lerato=# \du
List of roles
Role name | Attributes
-----------+------------------------------------------------------------
lerato | Superuser, Create role, Create DB
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS
walks_app |
An empty Attributes column for walks_app is what you want: it may log in, and nothing more. Choose a long password that you do not use anywhere else, because Modules 4 and 6 put it in configuration files, and keep it in your password manager.
How PostgreSQL decides who you are: peer and password
Try to connect as walks_app the obvious way, and PostgreSQL refuses:
$ psql -U walks_app -d mandlas_walks
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432"
failed: FATAL: Peer authentication failed for user "walks_app"
The rules for who may connect, from where, and how they prove who they are, live in a file called pg_hba.conf (host-based authentication). sudo -u postgres psql -c 'SHOW hba_file;' prints its location, /etc/postgresql/18/main/pg_hba.conf. Ubuntu's version starts with these active lines, after its comments and before three lines for replication, which copies a whole server and does not concern you here:
# TYPE DATABASE USER ADDRESS METHOD
local all postgres peer
local all all peer
host all all 127.0.0.1/32 scram-sha-256
host all all ::1/128 scram-sha-256
PostgreSQL reads the lines from the top and uses the first one that matches the connection. There are two kinds of connection. Without -h, psql connects through a Unix socket, a special file that works only on the same machine, and that matches a local line. With -h localhost, it makes a network connection over TCP to the address 127.0.0.1, and that matches a host line.
- peer
- For socket connections. PostgreSQL asks the operating system which Linux user is connecting, and allows the connection only if the role has the same name. No password is involved. That is why you, as
lerato, can log in as the rolelerato, and why you cannot log in aswalks_appthat way. - scram-sha-256
- For TCP connections here. PostgreSQL checks the role's password, using a method that never sends the password itself across the connection.
So the application's role connects over TCP with its password, which is how PHP connects too. You do not need to edit pg_hba.conf for this course. If you ever do, reload PostgreSQL afterwards with sudo systemctl reload postgresql, and never change peer or scram-sha-256 to trust, which lets anyone in without a password.
Worked example: logging in as walks_app for the first time
Lerato has just created walks_app and mandlas_walks, and wants to check that the application's login works.
- First attempt.
psql -U walks_app -d mandlas_walksfails with "Peer authentication failed for user walks_app". Reading the message: "Peer" names the method, so this was a socket connection, and her Linux userleratois notwalks_app. - Switch to TCP.
psql -h localhost -U walks_app -d mandlas_walksasks "Password for user walks_app:". She types it and gets the promptmandlas_walks=>, with=>becausewalks_appis not a superuser. - Check where she is.
SELECT current_user, current_database();answerswalks_appandmandlas_walks.\dtanswers "Did not find any relations.", because Module 1 creates the tables. - Check the owner's rights.
CREATE TABLE smoke_test (id integer);answersCREATE TABLE, andDROP TABLE smoke_test;removes it. The owner may create tables, so Module 1 will work. - Stop typing the password. She saves the password in
~/.pgpass, as shown next, and the same command now connects without asking.
Had she typed the password wrongly, the message would have been "password authentication failed for user walks_app", which names a different method and so a different cause.
Connection strings and ~/.pgpass
Every client needs the same five facts: host, port, database, user and password. A connection string packs them into one piece of text. PostgreSQL understands two forms, and PHP has a third:
| Form | Example | Used by |
|---|---|---|
| URI | postgresql://walks_app@localhost:5432/mandlas_walks | psql, many tools |
| Keywords | host=localhost port=5432 dbname=mandlas_walks user=walks_app | psql, libpq |
| PDO DSN | pgsql:host=localhost;port=5432;dbname=mandlas_walks | PHP, with the user and password given separately |
A URI may also hold the password, as walks_app:secret@localhost, but then it ends up in your shell history and in screenshots. Better to keep it in ~/.pgpass, a file in your home folder that PostgreSQL's client library, libpq, reads whenever a server asks for a password. Each line is host:port:database:user:password. libpq ignores the file unless only you can read it:
$ echo 'localhost:5432:mandlas_walks:walks_app:your-long-password' \
>> ~/.pgpass
$ chmod 600 ~/.pgpass
$ psql postgresql://walks_app@localhost:5432/mandlas_walks \
-c 'SHOW server_version;'
server_version
-----------------------------------
18.6 (Ubuntu 18.6-1.pgdg24.04+1)
(1 row)
PHP's PostgreSQL driver is built on libpq too, so it also reads ~/.pgpass when PHP runs as you. That lets this module's test page connect without a password in its code. From Module 6, Laravel keeps the same five facts in its .env file as DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME and DB_PASSWORD.
Try it: a tour in psql
Run psql as yourself. Type \l and find mandlas_walks and its owner. Type \c mandlas_walks, then \dt, then \du, then \conninfo, and read each answer. Leave out the semicolon from SELECT 1 and watch the prompt change, then finish the statement. Quit with \q.
A graphical client, if you want one
psql is all the course needs. A graphical client shows tables and data in a window, which some people find easier when exploring. Two are free and widely used:
- pgAdmin 4, from the PostgreSQL community, version 9.19 on 2 November 2026. On Windows, download the installer from pgadmin.org/download. On Mint, add pgAdmin's apt repository using the line its download page gives for Mint users, which names
noble, then installpgadmin4-desktop. pgAdmin's team says it does not test on Mint, so DBeaver may be the easier choice there. - DBeaver Community, a general database tool, version 26.2.4 on 2 November 2026. On Windows, use the installer from dbeaver.io/download. On Mint, install it from the Software Manager, which offers the Flatpak version, or with
flatpak install flathub io.dbeaver.DBeaverCommunity.
On the WSL route, install the client on Windows, not in Ubuntu. Either way, create a connection with host localhost, port 5432, database mandlas_walks, user walks_app and its password. That is a TCP connection, so it uses the password rule from Figure 0.3. Microsoft's PostgreSQL extension for VS Code does the same inside your editor.
Node.js and Git
Node.js through nvm
Laravel uses front-end build tools that run on Node.js, from Module 6. Install Node exactly as in WEB-201, with nvm (Node Version Manager), inside Linux. Node 26 has been the Active LTS version since 28 October 2026, and nvm install --lts gave Node 26.13.0 on 2 November 2026. Copy the current install command from nodejs.org/en/download, because the nvm version in it changes:
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh \
| bash
# Close the terminal and open a new one, then:
$ nvm install --lts
$ node -v
v26.13.0
$ which node
/home/lerato/.nvm/versions/node/v26.13.0/bin/node
Git, as in WEB-201
Git is already in Ubuntu and Mint. Check with git --version, and install it with sudo apt install git if needed. On the WSL route, Linux has its own Git settings, separate from Git for Windows, so tell it who you are again, exactly as in WEB-201:
$ git config --global user.name "Lerato Mokoena"
$ git config --global user.email "your-github-noreply-address"
$ git config --global init.defaultBranch main
$ git config --global core.editor "code --wait"
To push to GitHub from Linux, sign in with the GitHub CLI: sudo apt install gh, then gh auth login, choosing GitHub.com, HTTPS, "Yes" to authenticating Git with your GitHub credentials, and logging in with a web browser. On WSL, gh prints a one-time code and a web address to open in your Windows browser. SSH keys, the other way to sign in, come in Module 12, where you need them for servers.
VS Code for PHP and PostgreSQL
VS Code understands PHP's syntax out of the box but knows little about your code. Add these extensions. On WSL, install the last three "in WSL: Ubuntu", with a folder from Ubuntu open.
| Extension | Publisher | Gives you |
|---|---|---|
| WSL (WSL route only) | Microsoft | VS Code working inside Ubuntu |
| PHP Intelephense | Ben Mewburn (shown as Intelephense) | Completion, go to definition, error checking and PSR-12 formatting for PHP. The free features are all this course needs. |
| PostgreSQL | Microsoft | Connect to PostgreSQL, browse tables and run SQL from the editor |
| EditorConfig | EditorConfig | Applies each project's .editorconfig rules for indentation and line endings |
The other well-known PHP extension, "PHP" by DEVSENSE, does a similar job. Use one PHP extension, not both, or you get every suggestion twice. Intelephense's own instructions also ask you to switch off VS Code's built-in PHP suggestions: in Extensions, search for @builtin php, and disable PHP Language Features while leaving PHP Language Basics on, which colours the code. Laravel publishes an official Laravel extension too, which Module 6 introduces.
EditorConfig is a small file format, understood by most editors, that fixes a project's basic text rules so that everyone's editor saves files the same way. Each of your projects gets this file at its top. Laravel creates a very similar one itself in Module 6:
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.{js,json,css,html,yml,yaml}]
indent_size = 2
[*.md]
trim_trailing_whitespace = false
Four spaces suit PHP, as the PSR-12 coding standard requires, and two suit the JavaScript, CSS and HTML style from WEB-201. end_of_line = lf matters on Windows: Linux ends lines with one character, LF, and Windows with two, CR and LF. A Bash script saved with Windows line endings fails on Linux with errors such as "bad interpreter".
PHP's built-in server and a first page
A browser cannot run PHP. It asks a web server for a page, and the web server runs PHP to build it. On a real server that is Nginx and PHP-FPM, in Module 12. For development PHP includes its own small web server, started with php -S:
$ php -S localhost:8000 -t stack-check
[Mon Nov 2 02:23:15 2026] PHP 8.5.12 Development Server
(http://localhost:8000) started
-S localhost:8000 says which address and port to listen on, and -t stack-check names the document root, the folder whose files the server offers. A request for http://localhost:8000/info.php runs stack-check/info.php. The terminal then shows a line for every request with its status code, such as [200]: GET /info.php, and any PHP errors. Stop the server with Ctrl+C. The PHP manual is clear that it is for development only and must never be used on a public network.
The first page calls phpinfo(), which builds a long page describing PHP's version, settings and extensions:
<?php
declare(strict_types=1);
// Development only: phpinfo() shows how PHP is set up on this machine.
// Never leave a page like this on a public server.
phpinfo();
declare(strict_types=1); is the first statement of every plain PHP file in this course: it makes PHP refuse to quietly convert values between types, which Module 3 explains. Open the page and find the version at the top, "Loaded Configuration File", and the pdo_pgsql section. A phpinfo page tells an attacker exactly what to attack, which is why it never goes near a public server.
The second page proves PHP can reach PostgreSQL. It uses PDO (PHP Data Objects), PHP's standard way to talk to databases, which Module 4 teaches properly. For now, read it for the idea: build a DSN, connect, ask one question, show the answer safely.
<?php
declare(strict_types=1);
// Development only: proves PHP can reach PostgreSQL through PDO.
// The password is not written here: PDO's PostgreSQL driver uses libpq,
// which reads it from ~/.pgpass, just as psql does.
$dsn = 'pgsql:host=localhost;port=5432;dbname=mandlas_walks';
$user = 'walks_app';
$rows = [];
$error = null;
try {
$pdo = new PDO($dsn, $user, null, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
$result = $pdo->query(
'SELECT current_user AS who, current_database() AS db, '
. "current_setting('server_version') AS version"
);
$row = $result->fetch(PDO::FETCH_ASSOC);
$rows = [
'PHP version' => PHP_VERSION,
'PDO drivers' => implode(', ', PDO::getAvailableDrivers()),
'Connected as' => $row['who'],
'Database' => $row['db'],
'PostgreSQL version' => $row['version'],
];
} catch (PDOException $e) {
$error = $e->getMessage();
}
function e(string $text): string
{
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
}
?>
<!doctype html>
<html lang="en-ZA">
<head>
<meta charset="utf-8">
<title>Database check</title>
</head>
<body>
<h1>Database check</h1>
<?php if ($error !== null): ?>
<p>Could not connect: <?= e($error) ?></p>
<?php else: ?>
<dl>
<?php foreach ($rows as $label => $value): ?>
<dt><?= e($label) ?></dt><dd><?= e($value) ?></dd>
<?php endforeach; ?>
</dl>
<?php endif; ?>
</body>
</html>
The part above ?> is PHP: it tries to connect, runs one query and keeps the answers in an array, or keeps the error message if anything fails. The part below is an HTML page with small pieces of PHP in it. <?= ... ?> prints a value, and every value goes through e(), which uses htmlspecialchars so that text containing < or & cannot break the page or inject HTML. With the server running from ~/projects/walks-notes, http://localhost:8000/db-check.php shows:
Database check
PHP version 8.5.12
PDO drivers pgsql
Connected as walks_app
Database mandlas_walks
PostgreSQL version 18.6 (Ubuntu 18.6-1.pgdg24.04+1)
When that page shows your versions, the whole stack works: the browser asked PHP's server for a page, PHP ran your code, PDO used the pdo_pgsql extension to reach PostgreSQL over TCP, libpq found the password in ~/.pgpass, and PostgreSQL accepted walks_app into its own database.
The course's project folders
Everything you build lives under ~/projects, in the Linux file system on both routes. Each project is its own folder and its own Git repository on GitHub:
| Folder | Modules | What it holds |
|---|---|---|
~/projects/walks-notes | 0 onwards | Your notes for each module, the environment report and this module's check pages |
~/projects/walks-sql | 1 and 2 | The database in plain SQL: sql/schema.sql, sql/seed.sql, sql/queries.sql, the ER diagram and backups |
~/projects/walks-php | 3 to 5 | The booking pages in plain PHP, later restructured with Composer, run with php -S localhost:8000 -t public |
~/projects/walk-office | 6 to 13 | The Laravel 13 application, the Walk Office itself |
In this module you create only ~/projects and walks-notes. Each later module creates its own folder when it starts, and Laravel's installer in Module 6 creates walk-office itself. All four projects share the one database, mandlas_walks, so the data you design in Module 2 is the data the Walk Office shows in Module 7.
Keeping versions straight
Most set-up problems are version problems: two copies of a program, or a client and a server that disagree. Know the command that answers "which version am I really running?" for each tool:
| Question | Command |
|---|---|
Which PHP runs when I type php? | php -v and which php |
| Which PHP versions are installed? | ls /usr/bin/php* |
| Which Composer, on which PHP? | composer -V |
| Which psql client? | psql --version |
| Which PostgreSQL server am I connected to? | SHOW server_version; in psql |
| Which PostgreSQL clusters exist, on which ports? | pg_lsclusters |
| Which Node, from where? | node -v, which node and nvm ls |
The client and the server are separate programs with separate versions. psql --version tells you nothing about the server, and a psql connected to an older or newer server warns "WARNING: psql major version 19, server major version 18." with the real numbers. Run the check that answers your actual question.
When versions differ
Two PHPs. The ondrej/php repository installs PHP versions side by side, as php8.3, php8.5 and so on, and php points to one of them. If php -v shows the wrong one, choose with sudo update-alternatives --config php, or type the full name, such as php8.5. Extensions belong to one version: installing php8.5-pgsql does nothing for PHP 8.3.
Two PostgreSQL clusters. If an older PostgreSQL was already installed, pg_lsclusters may show 16/main on port 5432 and your new 18/main on 5433, because Ubuntu gives each new cluster the next free port. You would then be working on PostgreSQL 16 without knowing. If the old cluster holds nothing you need, remove it with sudo pg_dropcluster 16 main --stop, set port = 5432 in /etc/postgresql/18/main/postgresql.conf, and restart with sudo systemctl restart postgresql.
A version that is too new. A tool newer than the course is usually fine within the same major version, such as PHP 8.5.14 or PostgreSQL 18.7. A new major version, such as PostgreSQL 19, can behave differently: stay with the course's versions until you finish it.
Try it: one command for every version
Run php -v | head -n 1; composer -V | head -n 1; psql --version; node -v; git --version in your terminal, then psql -h localhost -U walks_app -d mandlas_walks -c 'SHOW server_version;'. Compare them with the table at the start of this module. In the practical work you turn this into a small script.
Troubleshooting the common set-up errors
Every message below is a real one, and each names its cause if you read it slowly. Ask three questions: which program printed it (psql, PHP, Composer, the shell), what it was trying to do, and what word in it names the problem.
| Message | Cause | Fix |
|---|---|---|
could not find driver | PHP's pdo_pgsql extension is not installed or not loaded for this PHP | sudo apt install php8.5-pgsql, check php -m, and restart php -S |
Peer authentication failed for user "walks_app" | A socket connection, and your Linux user is not walks_app | Add -h localhost to connect over TCP with the password |
password authentication failed for user "walks_app" | Wrong password, or a wrong line in ~/.pgpass | Reset it with \password walks_app as yourself, and correct ~/.pgpass |
fe_sendauth: no password supplied | The server wants a password and none was given | Check ~/.pgpass: the line must match host, port, database and user, and the file needs chmod 600 |
role "lerato" does not exist | No PostgreSQL role has your Linux user name | sudo -u postgres createuser --superuser "$USER" |
database "lerato" does not exist | psql opens a database named like you by default | createdb "$USER", or name one with -d |
Connection refused or No such file or directory on the socket | PostgreSQL is not running, or listens on another port | pg_lsclusters, then sudo pg_ctlcluster 18 main start, and read the log |
permission denied for schema public | The role is not the database's owner | Create the database with OWNER walks_app, or ALTER DATABASE mandlas_walks OWNER TO walks_app; |
mv: cannot move ... Permission denied | Writing a system folder without sudo | Use sudo for that one command, never for your own projects |
Failed to listen on localhost:8000 (reason: Address already in use) | Another server already uses port 8000, often one you forgot in another terminal | Stop it with Ctrl+C there, find it with ss -ltnp | grep :8000, or use port 8001 |
Two problems belong to WSL. If PostgreSQL in Ubuntu cannot start, or localhost:5432 reaches the wrong server, check whether you also installed PostgreSQL on Windows: both want port 5432, and WSL shares localhost with Windows. Uninstall the Windows copy, or stop its service. And if everything feels slow, run pwd: a path under /mnt/c means you are working across the bridge.
Sources
- Microsoft Learn, "How to install Linux on Windows with WSL": https://learn.microsoft.com/en-us/windows/wsl/install
- Microsoft Learn, "Working across Windows and Linux file systems": https://learn.microsoft.com/en-us/windows/wsl/filesystems
- Microsoft Learn, "Use systemd to manage Linux services with WSL": https://learn.microsoft.com/en-us/windows/wsl/systemd
- Microsoft Learn, "Accessing network applications with WSL": https://learn.microsoft.com/en-us/windows/wsl/networking
- Visual Studio Code, "Developing in WSL": https://code.visualstudio.com/docs/remote/wsl
- PHP, "Supported Versions": https://www.php.net/supported-versions.php
- PHP Manual, "Built-in web server": https://www.php.net/manual/en/features.commandline.webserver.php
- PHP Manual, "PDO_PGSQL DSN": https://www.php.net/manual/en/ref.pdo-pgsql.connection.php
- Ondrej Sury, "PPA for PHP" on Launchpad: https://launchpad.net/~ondrej/+archive/ubuntu/php
- Composer, "Download Composer": https://getcomposer.org/download/
- Composer, "How do I install Composer programmatically?": https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
- PostgreSQL, "Linux downloads (Ubuntu)": https://www.postgresql.org/download/linux/ubuntu/
- PostgreSQL, "Versioning Policy": https://www.postgresql.org/support/versioning/
- PostgreSQL 18 documentation, "psql": https://www.postgresql.org/docs/18/app-psql.html
- PostgreSQL 18 documentation, "The pg_hba.conf File": https://www.postgresql.org/docs/18/auth-pg-hba-conf.html
- PostgreSQL 18 documentation, "Connection Strings": https://www.postgresql.org/docs/18/libpq-connect.html
- PostgreSQL 18 documentation, "The Password File": https://www.postgresql.org/docs/18/libpq-pgpass.html
- pgAdmin, "Download": https://www.pgadmin.org/download/
- DBeaver Community, "Download": https://dbeaver.io/download/
- Node.js, "Download Node.js": https://nodejs.org/en/download
- nvm, "Node Version Manager": https://github.com/nvm-sh/nvm
- PHP Intelephense on the Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client
- PostgreSQL extension for VS Code on the Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=ms-ossdata.vscode-pgsql
- EditorConfig: https://editorconfig.org/
- Laravel 13 documentation, "Deployment: Server Requirements": https://laravel.com/docs/13.x/deployment