http://jseb.ca/" itemprop="description"/>

jsebean.com

Jonah's blog is here

Web/Technology

Web development and Technology related topics.

Microsoft debuted the "ribbon interface" back in 2007 to give Office a fresh new look to compliment its new features. Many complained it was counterproductive much like the former assistant present in office releases before 2007 (who doesn't remember clippy?), but honestly, it wasn't bad looking from a design standpoint. The fresh new design was the only thing that made me like it. Courtesy Wikipedia LGPL <http://commons.wikimedia.org/w/index.php?curid=25484245>

Going on that, in 2017, LibreOffice, the most popular open source office suite alternative ever since Oracle destroyed the forever loved OpenOffice, has also implemented its own take on the ribbon interface. However, while I'm no designer, it's not hard to tell from comparisons that not only have they implemented a functionally worse interface, they also did a splendid job of making it one of the ugliest by maintaining the pre-office 2007 design elements. Like please, using classic win32 tab controls instead of actually making it a "ribbon interface"? There's not even a little padding in the tabs? It's all crunched together.

libreoffice ribbon

Granted this is still "experimental", and the theme extensibility of some linux desktops does make it more tolerable, but let's be honest here, nobody in the ~1% of Desktop Linux users actually want this. Please, if you're going to invest this much time into it, at least make it look better in Windows, the platform that debuted this with the user base of pretty much the only users who will actually (maybe?) use it. Otherwise what's the point of wasting so much time on it?

Happy monday!

TL;DR: If you just want the rewrite rules for Lighttpd, scroll to the bottom code snippet.

So like most every other PHP app I've worked with, everybody seems to support both apache and nginx but poor old lighttpd gets left out in the cold and has no support on how to configure it in documentation.

Well have no fear, because you'll have to pry lighttpd out of my cold dead hands!

A while back I setup a VHOST for jseb.ca on Lighttpd with an FTP server so I could integrate it with Sharex. One other feature sharex seems to support is "short URLs" using an API from a PHP script called YOURLS. So I wanted to install it on my low end box.

Now if you caught on earlier, this blog is hosted using a flat-file database platform called htmly, because my lowendbox with only 128MB RAM isn't really ideal for running something like wordpress. MySQL can sure eat the RAM, so I sort of decided to not use MySQL on this server at all.

SQLite on the other hand is a perfect candidate. While it locks the entire database when you're writing to it, something like a URL shortener is a perfect application, since it's pretty much read only. Only time it writes is when I decide to add a URL, which is a fast query and so few and far between, it's a way better candidate for a personal URL shortener over MySQL anyway.

Unfortunately, YOURLS doesn't support SQLite out of the box. Luckily there's a great project here on github that adds it. Sweet! That was easy! Install php5-sqlite on my Debian install, chown/chmod your stuff so PHP can write to the directory YOURLS is in, install it by going to /admin/ and we're all set.

However, first thing you'll notice if you're running lighttpd is you'll get 404s since lighttpd doesn't support .htaccess, which YOURLS generates when you first install it. A search around on the internet will find stuff like this, but all the snippets in the examples causes issues for me.

While the last post from gsdefender (from Apr 24, 2016) works, my index.html on jseb.ca doesn't! Now I know it's not special, but it triggered me that if you visit the root, rather than showing my index.html it resulted in a redirect loop which freaked out Chrome.

Now like you probably figured out by now if you read anything here, I'm not much of a sysadmin or programmer, but I know my way around enough to be dangerous. I never got my head around regex stuff, but a quick look at lighttpd documentation says the ?

match zero or one of the previous symbol

Previous being keyword here... I just removed it.

So, now, with a vhost setup and mod_rewrite enabled for lighttpd, my lighttpd.conf looks like this for jseb.ca:

$HTTP["host"] == "jseb.ca" {
    server.document-root = "/var/www/upload/"
    url.rewrite-once = (
#        "^/([0-9A-Za-z-]+)?$" => "/yourls-go.php?id=$1",
#        "^/([0-9A-Za-z-]+)?\+$" => "/yourls-infos.php?id=$1",

        "^/([0-9A-Za-z-]+)$" => "/yourls-go.php?id=$1",
        "([0-9A-Za-z-]+)\+$" => "/yourls-infos.php?id=$1",
)

As you can see, the original copy-pasta from the github issue is commented out so you can note the difference between the two. It works for me... now my uploads and shorturls both reside on jseb.ca and coexists pefectly along with an index.html. So hopefully this helps anybody else who wants to run YOURLS on lighttpd.

Why did they put the ? to begin with? I don't know? enter image description here

I couldn't upload images to htmly with my lighttpd config. Further, the lighttpd config blocked my favicon.ico file. All images would result in a 404 when uploaded, despite ls-ing to the directory shows it uploaded successfully. I'm not using vhost with lighttpd... and honestly ... I blindly copied and pasted the config directly from the htmly documentation found on the github readme (and of course... enabled the rewrite mod in lighttpd.conf which is as simple as uncommenting. The verbatim code was:

$HTTP["url"] =~ "^/config" {
  url.access-deny = ( "" )
}
$HTTP["url"] =~ "^/system/includes" {
  url.access-deny = ( "" )
}
$HTTP["url"] =~ "^/system/admin/views" {
  url.access-deny = ( "" )
}

url.rewrite-once = (
  "^/(themes|system|vendor)/(.*)" => "$0",
  "^/(.*\.php)" => "$0",

  # Everything else is handles by htmly
  "^/(.*)$" => "/index.php/$1"
)

My issue was I would get 404s on images I upload. So I modified the line "^/(themes|system|vendor)/(.*)" => "$0", to show "^/(themes|system|vendor|content/images)/(.*)" => "$0", where content/images is where the images reside when you upload them with htmly.

Next, I added a line directly below it "^/(favicon\.ico|robots\.txt|humans\.txt|sitemap\.xml)$" => "$0", which of course, ensures favicon.ico, robots.txt, humans.txt and sitemap.xml actually works.

It works. It's not perfect. I want to be able to create other directories without rewrite screwing me over for hosting random files and whatever else I feel like. Perhaps I'll setup proper vhosts and elaborate on that down the road as I work on this site. For now the config is in /etc/lighttpd/lighttpd.conf at the bottom, and it gets the job done, so I'm happy.

FWIW... here is my entire config I ended up modifying to for those of you who also want to blindly copy and paste :P

$HTTP["url"] =~ "^/config" {
  url.access-deny = ( "" )
}
$HTTP["url"] =~ "^/system/includes" {
  url.access-deny = ( "" )
}
$HTTP["url"] =~ "^/system/admin/views" {
  url.access-deny = ( "" )
}

url.rewrite-once = (
  "^/(themes|system|vendor|content/images)/(.*)" => "$0",
  "^/(favicon\.ico|robots\.txt|humans\.txt|sitemap\.xml)$" => "$0",
  "^/(.*\.php)" => "$0",

  # Everything else is handles by htmly
  "^/(.*)$" => "/index.php/$1"
)

But yeah.... fixes that issue for you lighttpd users out there who can't upload images with the htmly platform :)

Why am I using lighttpd? Well certainly apache is out of the picture for a 128MB Low End Box. Lighttpd was the choice mainly because I've used it more than nginx. I like nginx and have used it a bit but lighttpd gets the job done for me where I have more experience with it (it use to serve the chickentalk.org forums I used to run a few years ago well so you can say I used it in "production") and is rock stable as far as I can tell for all the memory leak complaining I've heard about in the past, so I use it.

Perhaps one day I'll switch to nginx since that's where the community is at, but old habits die hard. It's always been my goto apache alternative.