THU.JUN.18
2026
23:36:59
← back to modules MODULE · 01 · PHP
0 / 10 chapters complete · 0%

LAN Access — Phone, Tablet, Other PCs

Make your server reachable from any device on your home WiFi. Phone, tablet, smart TV if you're feeling weird.

Three things: server binds to all interfaces (already does), firewall allows port 80, you know the IP. Set up the firewall properly while you're at it.

Step 1: Find the LAN IP

hostname -I

Yours: 192.168.0.19. Anything starting with 192.168 or 10.0 is a private home network IP.

Pro move: log into your router admin (usually http://192.168.0.1), find "DHCP reservation" or "static lease", bind the laptop's MAC address to its current IP. Five minutes; never lose the server again.

Step 2: Confirm Apache binds to all interfaces

Check /etc/apache2/ports.conf — should say bare Listen 80, not Listen 127.0.0.1:80.

Step 3: Set up the firewall (ufw)

Ubuntu ships ufw (Uncomplicated Firewall) — friendly frontend for iptables. Let's do this properly.

ORDER MATTERS. If you're configuring this over SSH, you MUST allow SSH BEFORE enabling the firewall. Otherwise the firewall blocks port 22 the moment it turns on, and your SSH connection dies with no way back short of physically walking to the laptop.
  1. Allow SSH first (CRITICAL): sudo ufw allow OpenSSH
  2. Allow web traffic: sudo ufw allow 'Apache Full' (opens 80 + 443)
  3. Enable firewall: sudo ufw enable
  4. Verify: sudo ufw status

Output should look like:

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
Apache Full                ALLOW       Anywhere

Step 4: Restrict by network (optional, but smart)

The above lets anyone who can reach the IP through. Behind a home router, that's fine in practice (NAT blocks outsiders). Belt-and-suspenders version:

sudo ufw delete allow 'Apache Full'
sudo ufw allow from 192.168.0.0/24 to any port 80
sudo ufw allow from 192.168.0.0/24 to any port 443

The /24 covers 192.168.0.0 through 192.168.0.255 — your whole LAN.

Phone Test

Goal: load your PHP page on your phone. Tiny moment, big "I made the internet" feeling.

  1. On your phone, connect to the SAME WiFi as the server
  2. Open a browser, hit http://192.168.0.19/
  3. You should see the Apache default page
  4. Now try http://192.168.0.19/hello.php (or /greet.php?name=Eric)
  5. Take a screenshot. You just used your phone to view a page that came from a laptop in your room. That's a flex.

If it's not working

  • Connection refused: firewall blocking OR Apache not running. Check both with sudo systemctl status apache2 and sudo ufw status.
  • Connection timed out: wrong IP, or phone on different WiFi (5GHz vs 2.4GHz can be isolated, "guest network" mode blocks LAN, VPN routes around your LAN).
  • 403 Forbidden from phone but works locally: vhost has Require local. Check /etc/apache2/sites-enabled/.
  • Phone sees Apache default but PHP shows source: PHP module not loaded. sudo a2enmod php8.3 && sudo systemctl restart apache2
From your phone, browse to your greet.php page with a query param like ?name=YourName. Take a screenshot for the receipts. Send it to a friend. "Built this in my bedroom."