Project

General

Profile

Newbie help

Added by NormB over 3 years ago

Hi,
I need some very basic help to get going with Lighty.

I have a working webpage running on my Raspberry Pi - running Raspian Buster, Apache2, PHP7.3. HTTPS accessible and pointed to through DynuDNS DDNS service.

Having recently bought a new Pi I though it would be a nice exercise to try out Lighty as an alternative.

I copied my SD card and worked from there. I uninstalled Apache2 and installed latest Buster Lighty (v1.4.53). I did try to be too ambitious to start with and dive straight into setting up a virtual host using ssl but as I was getting nowhere I backed off and decided to take it a step at a time and decided the best approach was:
Stage 1: get the server working on localhost
Stage 2: Get a local virtual host working pointing to my PHP files
Stage 3: Get HTTPs set up
Stage 4: Point to it externally from it's domain name.

I obviously don't understand something fundamental as I am failing at Stage2. Reading on the net seems to make it all sound fairly easy, though there seems to be quite a bit of variation in suggested syntax and methodology - possibly a result of changes to the like as newer versions have been released. So one question I have is what would be the recommended tutorial to follow that is most up to date?

Lighty is up and running. "localhost" serves my default html page and localhost/phpinfo.php serves up correctly. Also, if I change the document root in lighttpd.conf to /var/www/html/Saraband (location of my files) my webpage php files get served up and I can log in (I have some issues connecting to my database, but that can be fettled).

However, if I try and set it up as a vhost I get nowhere.
I reverted to default document root and added the following lines to lighttpd.conf (I also tried putting them in a separate file and 'including' them but it made no difference

$HTTP["host"] == "s.local" {
server.document-root = "/var/www/html/Saraband"
accesslog.filename = "/var/log/lighttpd/slocal_access.log"
server.errorlog = "/var/log/lighttpd/slocal_error.log"
}

Running lighttpd -tf tells me that "server.error.log" is deprecated (just one syntactical change from virtually all examples I have found on the web). However is still says "Syntax OK".

On restarting lighttpd and trying to access http://s.local just tells me "s.local’s server IP address could not be found."

What am I fundamentally doing wrong?
What is the best up-to-date tutorial to follow

Thanks


Replies (6)

RE: Newbie help - Added by gstrauss over 3 years ago

Hint, you're still trying to do too much at once, but do not realize it. "s.local" has nothing to do with lighttpd, but it is clear that you have not set it up correctly. If you are trying to set up a web server on localhost, use "localhost".

"s.local’s server IP address could not be found."

That sounds like a message from a client, which you have neglected to detail.

Aside: lighttpd 1.4.56 supports per-virtualhost error logs, but you're using lighttpd 1.4.53, which supports only a global server.errorlog. buster-backports has lighttpd 1.4.56-rc7, and should get lighttpd 1.4.57 in another week or two.

$HTTP["host"] == "localhost" {
  server.document-root = "/var/www/html/Saraband" 
  accesslog.filename = "/var/log/lighttpd/slocal_access.log" 
}
server.errorlog = "/var/log/lighttpd/error.log" 

RE: Newbie help - Added by NormB over 3 years ago

Brilliant!
I knew it had to be simple - all working now for Stage 2 - on to stage 3.
Any gotcha's for setting up https on localhost? - or would I be better diving straight in to trying again to set it up for my real domain name?
Also my other question - what tutorial is best to follow?

RE: Newbie help - Added by gstrauss over 3 years ago

Not brilliant; simple.

The best approach is almost always to take one small step at a time, test it, and then make another small change.

Setting up DNS and setting up TLS in lighttpd are two separate steps and should be done separately.

lighttpd TLS docs

RE: Newbie help - Added by NormB over 3 years ago

Sorry to be a pain...

I got HTTP working with a vhosts file as follows:

$HTTP["host"] == "192.168.1.144" {
server.document-root = "/var/www/html/Saraband"
accesslog.filename = "/var/log/lighttpd/slocal_access.log" file
}

I followed the certificate generation instruction:

cd /etc/lighttpd/certs
openssl req -new -x509 -keyout lighttpd.pem -out lighttpd.pem -days 365 -nodes
chmod 400 lighttpd.pem

Not sure whether it actually matters but I did use 192.168.1.144 as the FQN when creating the certificate.

I inserted server.modules += ("mod_openssl") in lighttpd.conf

I edited my vhosts file to be as follows:

$HTTP["host"] == "192.168.1.144" {
server.document-root = "/var/www/html/Saraband" # Document-root of the webserver
accesslog.filename = "/var/log/lighttpd/slocal_access.log" # Web server Access log file
#server.errorlog = "/var/log/lighttpd/slocal_error.log" # Web server Error log file
}
$SERVER["socket"] == "192.168.1.144:443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/certs/lighttpd.pem"
}

The result is that when I try to access https://192.168.1.144 it just drops back to http and says that the certificate is invalid. The web pages are served but only http.

Thanks

RE: Newbie help - Added by gstrauss over 3 years ago

That sounds like a message from a client, which you have neglected to detail.

You appear to have missed my comment from earlier.

The result is that when I try to access https://192.168.1.144 it just drops back to http and says that the certificate is invalid.

Do you know how to use your web client?

man curl
Look up the -k option for testing.

    (1-6/6)