htdocs path in linux

htdocs path in linux

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Determining and Configuring the Web Root for Lighttpd on Linux

When managing a Linux server via SSH, the most critical first step is identifying the actual web root directory. The term "htdocs" is deeply ingrained in developer culture due to its ubiquity in Apache configurations, but it is by no means a universal standard across all web servers or distributions. If your server is running Lighttpd, as you've indicated, assuming the default location will likely lead to a 403 Forbidden error or a blank page because Lighttpd does not inherently serve files from /var/www/html.

The correct directory depends entirely on how the specific web root was defined during installation. Unlike Apache, which often defaults to /var/www/html out of the box in many distros, Lighttpd is frequently used as a drop-in replacement for Nginx or Apache, meaning its configuration might point to /srv/www, /usr/local/www, or even a user's home directory like /home/developer/projects.

To find where your server expects files to live, you must inspect the Lighttpd configuration file. This is typically located at /etc/lighttpd/lighttpd.conf or sometimes /etc/lighttpd/lighttpd123.conf. Open the file using a text editor like nano or vi:

sudo nano /etc/lighttpd/lighttpd.conf

Search for the server.document-root directive. It will look something like this:

$SERVER["document-root"] = "/path/to/your/web/root";

The path specified here is your true web root. Any file you place inside that directory becomes accessible via your domain name. If the configuration contains a server.document-root variable set to a placeholder or commented out, Lighttpd might be falling back to a default set by your distribution's package manager, often /var/www/lighttpd/doc.

Symlinks and Virtual Hosts

If you are running multiple sites on a single server, Lighttpd usually handles this through virtual hosting. In the configuration file, look for server.document-root assignments inside server.conf blocks or within server.modules that define specific hostnames. You will likely see entries resembling:

$HTTP["host"] =~ "example\.com" {
    $SERVER["document-root"] = "/var/www/example.com";
}

In these scenarios, the global default applies only to requests that don't match a specific virtual host rule. This structure allows you to serve different applications from entirely different directories without modifying the main server block.

Creating Directories and Permissions

Once you identify the correct root, creating your htdocs equivalent is straightforward. You can create a new directory structure within the identified web root:

sudo mkdir -p /var/www/myapp/public

Note that Lighttpd, being an older C-based server, is less flexible with symbolic links than Nginx or Apache. If you symlink a user's project folder into /srv/www, ensure the permissions are tight. Lighttpd runs as the www-data or lighttpd user depending on your system. If directory permissions are too restrictive (e.g., 700), the web server cannot read your PHP files, resulting in internal server errors. Standard practice is to set directories to 755 and files to 644.

The LaravelCompany Context

If you plan to deploy modern frameworks like Laravel within this Lighttpd environment, there are specific considerations regarding how static assets and routing are handled. While Apache and Nginx have robust built-in support for .htaccess or rewrite rules that frameworks rely on, Lighttpd requires explicit configuration in its own lighttpd.conf file to handle URL rewriting before the application layer processes the request.

For instance, if you are deploying a Laravel application, ensure your virtual host block includes the necessary rewrite module and rules to map URLs like /login to /public/login. For more complex routing setups or if you require advanced cache control headers that might be tricky to configure manually in Lighttpd, consider evaluating whether migrating to Nginx is necessary. However, for simple static file serving or lightweight PHP applications, Lighttpd remains a capable choice once the server.document-root is correctly identified and configured.

Always verify your setup by accessing the directory via SSH and running:

ls -la /path/to/your/web/root

Ensure the index file exists and that the path matches exactly what is defined in your configuration file.

Our network