Xampp - Ubuntu - cant access my project in lampp/htdocs

Xampp - Ubuntu - cant access my project in lampp/htdocs

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

Stefan Bogdanescu

Founder & Senior Architect

XAMPP on Ubuntu: Resolving 403 Forbidden in /opt/lampp/htdocs

Running XAMPP on Ubuntu is a common choice for local development, but it often trips developers over permission issues that don't exist on Windows. The error you are encountering—Access forbidden! Error 403 when accessing /soap/php or any subdirectory within /opt/lampp/htdocs—is almost never caused by a missing index.php. As the error message explicitly states, Apache is denying access because of directory permissions or protection settings.

The root cause lies in how XAMPP for Linux handles file ownership and directory traversal. Unlike the Windows version, where you run everything as your user, the Linux installer typically places the XAMPP suite (Apache, MySQL, PHP) under /opt/lampp/. By default, this directory is owned by root or a specific service user, while your development files in /opt/lampp/htdocs/project_is_here are likely owned by your standard user account. Apache, running with restricted privileges for security, cannot read files it does not own, resulting in a 403 Forbidden error.

Fixing Ownership Permissions

The most direct solution is to ensure the web server process can read your project files. You need to change the ownership of the htdocs directory and its contents so that the Apache user can access them.

First, identify the user under which the XAMPP modules are running. On Ubuntu 12.04 with XAMPP, this is often a dedicated group or the root user if not configured otherwise. However, the standard fix involves ensuring your project directory is readable by the Apache process.

Run the following command to change ownership of the entire htdocs tree to your current user:

sudo chown -R $USER:$USER /opt/lampp/htdocs/project_is_here

If you want to apply this to the entire htdocs folder (use with caution if it contains system files), use:

sudo chown -R $USER:$USER /opt/lampp/htdocs

After changing ownership, verify that your project directory is accessible. If the error persists, check the directory permissions themselves. Apache generally needs read and execute permissions on directories to traverse them. Ensure your project_is_here folder allows traversal:

ls -ld /opt/lampp/htdocs/project_is_here

You should see output like drwxr-xr-x. If the last digit is restrictive (e.g., d---------), run:

chmod 755 /opt/lampp/htdocs/project_is_here

Understanding Apache Configuration

Sometimes, simply fixing ownership isn't enough because of how XAMPP configures its document root. The error message mentions There is either no index document or the directory is read-protected. While you have an index.php, Apache might be configured to look for files in a different location defined in httpd.conf or apache2.conf.

In the XAMPP environment, the default document root is usually set to /opt/lampp/htdocs. However, if you have enabled specific modules like .htaccess support and placed a restrictive .htaccess file in your project folder (or its parent), it could be blocking access. Check for an .htaccess file in /opt/lampp/htdocs/project_is_here or /opt/lampp/htdocs. If one exists, ensure it does not contain Deny from all or overly restrictive AllowOverride directives.

Security Trade-offs

Changing ownership to your user account is convenient but introduces a slight security trade-off. Apache runs with elevated privileges relative to the web content; if your code has vulnerabilities, an attacker might gain access to your user's home directory.

To mitigate this while keeping development friction low:

  1. Keep your actual source code (e.g., Laravel projects) in a separate directory like /var/www/myapp and symlink it into htdocs. This way, the sensitive files remain outside the default XAMPP structure.
  2. Alternatively, create a specific group for web development (e.g., www-data) and assign both your user and Apache to that group, then set permissions to 775 on the project folder.

Conclusion

The 403 Forbidden error in XAMPP on Ubuntu is predominantly a permissions issue rather than a configuration failure of Apache itself. By adjusting ownership with chown and verifying directory traversal rights with chmod, you align the file system expectations with the Apache security model. If you are building complex applications, consider moving your project logic to a dedicated web root outside of /opt/lampp/htdocs to maintain cleaner separation between development tools and production-like environments. For more robust deployment strategies involving PHP frameworks, platforms like https://laravelcompany.com offer insights into setting up secure, scalable environments that go beyond the local XAMPP setup.

Our network