First PHP File
The setup you'll use forever
Picture the cast:
- Windows = your cockpit (where your hands are)
- VS Code on Windows = the editor
- VS Code Remote-SSH = the bridge to Lubuntu
- Files actually live on Lubuntu's disk
- Apache reads those files when a browser asks
Like Google Docs but for code — you edit "in" VS Code, file lives on the server. Exact pattern the pros use with AWS, just with a laptop instead of a datacenter.
Connect VS Code to Lubuntu
- In VS Code: open Extensions, search "Remote - SSH", install
- Hit F1 → "Remote-SSH: Connect to Host..."
- Add new host:
ssh erictey@192.168.0.19 - Pick where to save SSH config (default is fine)
- VS Code reopens connected to Lubuntu — check bottom-left, should say "SSH: 192.168.0.19"
- File → Open Folder →
/home/erictey/server
The disk-to-URL map
Apache is configured to serve from /home/erictey/server/. The mapping:
- File
/home/erictey/server/index.php→ URLhttp://192.168.0.19/ - File
/home/erictey/server/hello.php→ URLhttp://192.168.0.19/hello.php
Path on the left, URL on the right. They mirror each other.
Write your first PHP file
- In VS Code (connected to Lubuntu), create new file:
hello.php - Type this:
<?php echo "Hello, network."; ?> - Save (Ctrl+S)
- From Windows browser: hit
http://192.168.0.19/hello.php
If something went wrong
- Browser shows the raw PHP code: Apache's PHP module not loaded.
sudo a2enmod php8.3 && sudo systemctl restart apache2 - 404 Not Found: wrong path/filename. Linux is case-sensitive:
Hello.php ≠ hello.php. Stick to lowercase. - 403 Forbidden:
chmod 644 /home/erictey/server/hello.php - Blank page: PHP error with display off (we fix this in the PHP tab). Check
sudo tail /var/log/apache2/error.log - Connection refused: Apache stopped.
sudo systemctl start apache2
Folder convention
One folder per project — even if there's only one project right now.
/home/erictey/server/
├── medtrack/
│ ├── index.php
│ └── assets/
├── another-project/
│ └── index.php
└── tools/
└── db-backup.php
Then http://192.168.0.19/medtrack/ serves MedTrack, the other URL serves the other project. A single Apache can host like a dozen apps without breaking a sweat.
Build: Greeter Page
Goal: take a name from the URL and greet that specific person. First taste of dynamic web pages.
- Create
/home/erictey/server/greet.php - Drop this in:
<?php $name = $_GET['name'] ?? 'stranger'; echo "<h1>Hey there, " . htmlspecialchars($name) . "!</h1>"; echo "<p>Welcome to my server. The time here is " . date('H:i') . ".</p>"; ?> - Hit
http://192.168.0.19/greet.php— should say "Hey there, stranger!" - Now hit
http://192.168.0.19/greet.php?name=Eric - Should say "Hey there, Eric!" with the current time
Stretch: add another query param like ?name=Eric&age=25 and have the page say "you're 25 years old."
What you just learned: reading URL params ($_GET), null coalescing (??), output escaping (htmlspecialchars), date formatting. We'll go deep on all of these.
/home/erictey/server/ ends up served by Apache? Peek at the APACHE tab — it's a one-line Alias in /etc/apache2/sites-available/000-default.conf.