Project

General

Profile

[Solved] 403 - Forbidden, when omitting "index.php"

Added by KaaP over 6 years ago

Hi all

I'm building a small site locally on my Ubuntu 16.04.3, and trying to skip the need for a filename in my URL.

This is what I get:
(the first page merely being the output of a SQL test)
but...

The site folder is actually /tmp/site, linking to a home folder subdirectory:

linking to

I only want this site to be running when I want to use it so I manually run a script creating this link when I want the site to be active.

I can't find what's causing the 403 error.
I did clean up my lighttpd.conf file rather rigorously though... Did that cause my problem?
And how can I fix it?

server.document-root = "/tmp" 

server.port = 80

mimetype.assign = (
  ".html" => "text/html", 
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png" 
)

index-file.names = (
  "index.html", "index.php" 
)

server.modules = (
                   "mod_fastcgi" 
                 )

fastcgi.server = ( ".php" => (( 
                     "bin-path" => "/usr/bin/php-cgi",
                     "socket" => "/tmp/php.socket" 
                 )))

Thanks!


Replies (2)

RE: 403 - Forbidden, when omitting "index.php" - Added by gstrauss over 6 years ago

It is not a good idea to use /tmp as a document root. (It is actually a really bad idea.)

When you want the site to be active, why not start lighttpd at that time, as well, and shut down lighttpd when you do not want the site active?

As to the 403 Forbidden, please look in the lighttpd error log (or on stderr of the console on which you started lighttpd). You might consider defining server.errorlog to send this output to a file. Look there for your error and if that does not help, try something simpler: does it work when you try to serve index.html? Does it work if you start lighttpd up under your user account rather than as root? See server.username

RE: 403 - Forbidden, when omitting "index.php" - Added by KaaP over 6 years ago

server.username = "peter" solved my problem!

I'm sure you're right about not using /tmp as a web root, but I'd like to understand why it's a bad idea. Care to elaborate?
The reason I'm using this solution is that I'm managing multiple sites like this.
Until now, all of them are only one page, built up by script, in the /tmp folder. Everything gets cleaned up nicely upon every reboot.
This is the first local site of a larger size, which is why I'm using a subfolder.

There was nothing in my logs and using index.html resulted in the same 403 error issue (except when addressed directly as a file), but running lighttpd as myself did the trick.
I don't understand why this occurs though. With rwxrwxrwx enabled on both the Xomissix folder and the /tmp/site link, why is reading the folder forbidden in lighttpd?

Anyway, thanks a lot for your help!

    (1-2/2)