Project

General

Profile

[Solved] lighttpd on tor. .php files throw error 503

Added by burning over 3 years ago

I'm running lighttpd version 1.4.53 on Raspberry Pi OS Lite (The headless/CLI version) on a raspberry pi 2.
I am attempting to host an onion site on the tor network using lighttpd on my raspberry pi.
link to my lighttpd config: https://paste.lighttpd.net/C7#cLP2P7u5n5tUbDxJmh8slxrA

I am able to load html files perfectly fine when inserting the onion domain into my Tor Browser but whenever it tries to access .php files, it throws an error 503. I've enabled fastcgi and fastcgi-php modules as per this guide: https://pimylifeup.com/raspberry-pi-lighttpd/
after setting up lighttpd from following this one: https://mroystonward.github.io/self-hosting-with-raspberry-pi-and-tor/

I was told that this might be due to a typo in the contents of my index.php file which, as per the first tutorial I linked, should be "" (sans quote marks). Apparently it was missing a semicolon and should have been "" but this didn't solve the problem either after fixing the typo and rebooting.

And as a follow up question; once this is solved, How can I get mediawiki working with lighttpd?
I've found this tutorial: https://www.mediawiki.org/wiki/Manual:Installing_MediaWiki_with_Lighttpd
but it mentions localhost in the config, I don't think you can access localhost using tor so I'm a little stumped as how to sort that out?


Replies (9)

RE: lighttpd on tor. .php files throw error 503 - Added by gstrauss over 3 years ago

I posted on IRC:

503 Service Unavailable means that lighttpd is not able to contact the backend, e.g. your fastcgi. Is it running?
Your PHP-FPM service is probably not running (not started)

BTW, your paste is incomplete. Your lighttpd config contains: include "/etc/lighttpd/conf-enabled/*.conf".
Please use lighttpd -f /etc/lighttpd/lighttpd.conf -p to have lighttpd print the entire config.

RE: lighttpd on tor. .php files throw error 503 - Added by burning over 3 years ago

Ah, sorry about that. I'm connecting to the raspberry pi through ssh so I just copied the config to a USB drive and opened the text file on my computer and C&P'd it from there. Would lighttpd -f /etc/lighttpd/lighttpd.conf -p >> text_file_on_USB_drive work as a way to copy the contents onto USB?

RE: lighttpd on tor. .php files throw error 503 - Added by gstrauss over 3 years ago

Yes, that would work to capture the config. The reason I was asking was to see if mod_fastcgi was configured to start the backend, or if it was configured to use a socket, which would suggest use of PHP-FPM. Since the docs you posted use PHP-FPM, I presume that is what you are using and that your PHP-FPM service is not running.

PHP-FPM service is independent from lighttpd. Please see documentation for your linux distro for how to start the PHP-FPM service.

RE: lighttpd on tor. .php files throw error 503 - Added by gstrauss over 3 years ago

Regarding your MediaWiki question, please follow the tutorial. As long as Tor can reach your lighttpd server, it is fine that the lighttpd server fronts the MediaWiki backend listening on localhost.

RE: lighttpd on tor. .php files throw error 503 - Added by burning over 3 years ago

I just followed this guide on setting up lighttpd with PHP-FPM: https://www.howtoforge.com/tutorial/how-to-install-lighttpd-with-php-fpm-and-mysql-on-ubuntu-2004/
I had to skip a tiny part of the section to do with setting up mysql (From what I can tell, it basically covers alternate ways of accomplishing essentially the same things outlined in the mediawiki guide) as I already got as far as following the Configuring mysql section on this page: https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Debian_or_Ubuntu
so I basically already covered that bit I think...
and so trying to follow that one instruction on the first link wouldn't work, as when I tried to do systemctl enable mysql it output
Synchronizing state of mysql.service with Sysv service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mysql
Failed to enable unit: Too many levels of symbolic links

but I could still do the secure installation bit just fine. And like I said, that instruction probably tried to do something that's already been done in following that other guide, that's my impression of course I could be wrong, I'm not too familiar with SQL or PHP.
(Other than that one tiny snag which I don't think affects anything) I followed the guide verbatim but upon testing that one liner index.php file again, it still gives me an error 503 Service not available so php STILL doesn't seem to be working even though I checked and ran ls -lah /etc/lighttpd/conf-enabled/ and I got the exact same output as the guide.

And I know this isn't the mediawiki forums, but I thought I'd still ask considering it somewhat involves lighttpd. But in this tutorial here: https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Debian_or_Ubuntu
It says to edit /etc/php/7.3/apache2/php.ini to set upload limits and the like, but I tried looking for a lighttpd equivalent (/etc/php/7.3/lighttpd/) within which I would have assumed the php.ini file is located, but there is no such /etc/php/7.3/lighttpd/ directory. But there is a php.ini file located in /etc/php/7.3/fpm
silly question, I know, seeing as it seems almost blatantly obvious that this is the correct file/directory I'm looking for in my case, but I just want to doubly make sure before I edit it; would this be the correct file I need to modify?

RE: lighttpd on tor. .php files throw error 503 - Added by gstrauss over 3 years ago

The lighttpd service is distinct and independent from the PHP-FPM service.

Please re-read the tutorial more carefully.
https://www.howtoforge.com/tutorial/how-to-install-lighttpd-with-php-fpm-and-mysql-on-ubuntu-2004/#step-install-and-configure-phpfpm

And I know this isn't the mediawiki forums

Correct. This is not the mediawiki forum.

RE: lighttpd on tor. .php files throw error 503 - Added by burning over 3 years ago

I've re-read the tutorial carefully about four times now, believe me; I already assumed I missed something there. But I can't for the life of me think up any reason it's not working. SQL is enabled, PHP-FPM is enabled, my lighttpd.conf is configured with the appropriate modules etc. But I still can't get lighttpd to open index.php files without throwing error 503

RE: lighttpd on tor. .php files throw error 503 - Added by burning over 3 years ago

Ah, I apologize. You were right! I did misread the configuration file for fastcgi! I thought the "socket" variable was the to remain unchanged but it just looked similar enough that I didn't notice it needed to change from lighttpd to php. I've changed it accordingly now and php files are working!

Thanks very much for your help! :)

    (1-9/9)