Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can host a PHP and HTML website on your local area network (LAN) by running a web server on a computer connected to that network. Other devices open the site in a browser using the host computer’s LAN IP address or local hostname. HTML works once the server is configured to serve files; PHP also needs a configured PHP runtime.

How LAN website hosting works

The host computer runs a web server such as Apache or Nginx. The server responds to browser requests for files in its configured document root. A device on the same network can request those pages using the host’s LAN address—for example, http://192.168.1.25/ if that is the host’s current address.

The address and document-root path vary by operating system and server configuration. Raspberry Pi’s official Apache guide uses /var/www/html as its example document root and shows hostname -I for finding the Pi’s address. Those are examples for that setup, not universal commands or paths: Raspberry Pi: Setting up an Apache web server.

Set up a basic LAN site

  1. Choose the host. Use a computer already connected to your LAN, or an optional dedicated device such as a Raspberry Pi. You do not need to buy a separate computer simply to try local hosting.
  2. Install a web server. Follow the current installation instructions for your operating system and chosen server. Raspberry Pi’s guide demonstrates Apache installed with apt; that package command is specific to its documented environment.
  3. Add an HTML page. Create an index.html file in the server’s configured document root. For the Raspberry Pi example, that is /var/www/html. Test the page in a browser on the host computer first.
  4. Find the host’s LAN address. Use your operating system’s network settings or its documented command. On the Raspberry Pi setup above, hostname -I displays the Pi’s address.
  5. Test from another device. Connect a phone, laptop, or other client to the same LAN and enter http://HOST-IP/, replacing HOST-IP with the host’s address. If the page loads locally but not on the other device, check that both devices are on the intended network, that the host address is correct, and that the host firewall permits the server’s HTTP traffic.

Enable PHP when the site needs it

A web server does not execute PHP just because a file ends in .php. It must pass PHP requests to a configured PHP runtime. Raspberry Pi’s beginner guide demonstrates installing PHP and an Apache module for its example environment. For a new Apache deployment, however, the PHP manual recommends PHP-FPM with Apache’s mod_proxy_fcgi rather than mod_php. Use current package and configuration instructions for your operating system: PHP manual: Apache 2.x on Unix systems.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
TP-Link TL-SG105, 5 Port Gigabit Unmanaged Ethernet Switch, Network Hub, Ethernet Splitter, Plug & Play, Fanless Metal Design, Shielded Ports, Traffic Optimization
  • 𝗢𝗻𝗲 𝗦𝘄𝗶𝘁𝗰𝗵 𝗠𝗮𝗱𝗲 𝘁𝗼 𝗘𝘅𝗽𝗮𝗻𝗱 𝗡𝗲𝘁𝘄𝗼𝗿𝗸: 5× 10/100/1000Mbps RJ45 Ports supporting Auto Negotiation and Auto MDI/MDIX.
  • 𝗚𝗶𝗴𝗮𝗯𝗶𝘁 𝘁𝗵𝗮𝘁 𝗦𝗮𝘃𝗲𝘀 𝗘𝗻𝗲𝗿𝗴𝘆: Latest innovative energy-efficient technology greatly expands your network capacity with much less power consumption and helps save money.
  • 𝗥𝗲𝗹𝗶𝗮𝗯𝗹𝗲 𝗮𝗻𝗱 𝗤𝘂𝗶𝗲𝘁: IEEE 802.3X flow control provides reliable data transfer and Fanless design ensures quiet operation.
  • 𝗣𝗹𝘂𝗴 𝗮𝗻𝗱 𝗣𝗹𝗮𝘆: Easy setup with no software installation or configuration needed.
  • 𝗔𝗱𝘃𝗮𝗻𝗰𝗲𝗱 𝗦𝗼𝗳𝘁𝘄𝗮𝗿𝗲 𝗙𝗲𝗮𝘁𝘂𝗿𝗲𝘀: Prioritize your traffic and guarantee high quality of video or voice data transmission with Port-based 802.1p/DSCP QoS and IGMP Snooping.

After configuring PHP, request a simple PHP test page in the browser to confirm that the server executes it rather than displaying its source. Remove diagnostic pages such as phpinfo() when finished; they can expose environment details. PHP also warns that source filters can expose sensitive PHP source code on production systems, so do not enable them casually.

Choose Apache or Nginx

Both Apache and Nginx can serve static HTML and forward PHP requests to a PHP runtime. The right fit depends on your application, the integration supported by your operating system’s packages, and what you are comfortable configuring and maintaining—not on a proven speed winner for this use case.

Rank #2
Sale
NETGEAR 5-Port Gigabit Ethernet Unmanaged Network Switch (GS305)
  • GIGABIT ETHERNET PORTS: Features 5 x 1.0Gbps Ethernet ports for high-speed connectivity. Auto-negotiating ports detect the optimal speed for connected devices and work with existing Cat5e or Cat6 Ethernet cables.
  • PLUG-AND-PLAY UNMANAGED NETWORK SWITCH: Simple plug-and-play setup with no software to install or configuration required.
  • FLEXIBLE MOUNTING OPTIONS: Compact metal design supports desktop or wall-mount placement for versatile installation.
  • SILENT & ENERGY-EFFICIENT OPERATION: Fanless design ensures silent performance, while IEEE 802.3az Energy Efficient Ethernet reduces power consumption without compromising high-speed network performance.
  • REGIONAL COMPATIBILITY: Made for use in U.S. & CA only
Consideration Apache Nginx
PHP integration in a new setup PHP’s current guidance recommends PHP-FPM with mod_proxy_fcgi. Nginx documentation describes forwarding PHP requests using FastCGI.
Existing application configuration May suit an application that already depends on Apache configuration. May suit an application already configured for Nginx.
Performance comparison for this LAN workload No comparative result established. No comparative result established.

See the server’s request-processing guidance for the Nginx FastCGI model: Nginx: ngx_http_fastcgi_module.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep the site local and protect PHP

A site reachable on your LAN is not automatically available from the internet. Internet access requires additional network and security configuration; do not assume the LAN setup is safely or intentionally public. Raspberry Pi’s documentation distinguishes a local project from internet-facing hosting and notes that public deployment needs firewall configuration and additional security measures: Raspberry Pi security documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

Best Value
TP-Link LS1005G, Litewave 5 Port Gigabit Ethernet Unmanaged Switch
  • 【One Switch Made to Expand Network】Features 5 RJ45 ports with 10/100/1000Mbps speeds, supporting Auto-Negotiation and Auto MDI/MDIX for hassle-free setup. Ideal for expanding your network, with 1 uplink (input) port and 4 output ports to split your Ethernet connection to multiple devices.
  • 【Gigabit that Saves Energy】Latest innovative energy-efficient technology greatly expands your network capacity with much less power consumption and helps save money
  • 【Reliable and Quiet】IEEE 802.3X flow control provides reliable data transfer and Fanless design ensures quiet operation
  • 【Plug and Play】Easy setup with no software installation or configuration needed
  • 【Ethernet Splitter】Connect to your router or modem for additional wired connections (laptop, gaming console, printer, etc)
Rank #4
TP-Link 8 Port Gigabit Ethernet Network Switch - Ethernet Splitter | Plug & Play | Fanless | Sturdy Metal w/ Shielded Ports | Traffic Optimization | Unmanaged | Lifetime Protection (TL-SG108)
  • 8 GIGABIT PORTS: Features 8 RJ45 ports supporting 10/100/1000 Mbps speeds, providing high-speed wired network connectivity for computers, printers, gaming consoles, and other Ethernet-enabled devices
  • PLUG AND PLAY SETUP: No configuration required; simply connect the switch to your network devices and it is ready to use immediately, making network expansion quick and hassle-free
  • FANLESS QUIET DESIGN: The fanless design ensures silent operation, making this switch suitable for noise-sensitive environments such as home offices, bedrooms, or conference rooms
  • STURDY METAL CONSTRUCTION: Built with a durable metal housing and shielded ports that provide reliable performance, better heat dissipation, and protection against electromagnetic interference
  • TRAFFIC OPTIMIZATION: Supports IEEE 802.3x flow control and advanced traffic optimization technology to reduce data bottlenecks and ensure smooth, efficient data transfer across your network
Rank #3
Sale
NETGEAR 8-Port Gigabit Ethernet Unmanaged Network Switch (GS308)
  • GIGABIT ETHERNET PORTS: Features 8 x 1.0Gbps Ethernet ports for high-speed connectivity. Auto-negotiating ports detect the optimal speed for connected devices and work with existing Cat5e or Cat6 Ethernet cables.
  • PLUG-AND-PLAY UNMANAGED NETWORK SWITCH: Simple plug-and-play setup with no software to install or configuration required.
  • FLEXIBLE MOUNTING OPTIONS: Compact metal design supports desktop or wall-mount placement for versatile installation.
  • SILENT & ENERGY-EFFICIENT OPERATION: Fanless design ensures silent performance, while IEEE 802.3az Energy Efficient Ethernet reduces power consumption without compromising high-speed network performance.
  • REGIONAL COMPATIBILITY: Made for use in U.S. & CA only
  • Do not expose PHP-FPM to untrusted networks. The PHP manual warns, “php-fpm must not be reachable from an untrusted network.” A client able to connect to FastCGI can influence request configuration and execute code. Keep PHP-FPM on a protected local interface or socket and configure network access deliberately: PHP manual: FastCGI Process Manager (FPM).
  • Use the built-in PHP server only for development. It can help with local development, but PHP’s manual says, “The Built-in Web Server should not be used on a public network”: PHP manual: Built-in web server.
  • Check firewall and network settings. Verify that the host firewall allows access from the devices that should reach the site, while keeping development endpoints and PHP-FPM away from untrusted networks. Firewall steps vary by operating system and router; Raspberry Pi’s security documentation links to platform-specific guidance rather than providing one universal recipe.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.