WordPress.org

Ready to get started?Download WordPress

Forums

Serving cached static html pages with LightTPD or NGINX? (8 posts)

  1. bolonki
    Member
    Posted 6 years ago #

    The Super Cache pages says "Mod Rewrite is used to serve the static HTML pages. As fancy permalinks is also a requirement it should already be installed".

    Apache is notoriously slow for serving static content, so I wonder if it's possible to serve those static HTML with an alternative webserver such as LightTPD or Nginx, that would make Super Cache even better.

    I know Donncha and the WP sites use LiteSpeed, which I think it's a big mistake -- LiteSpeed is not only a commercial product, but it's closed source and most likely includes code from LightTPD and / or NGINX which are free. WordPress is already benefitting this commercial venture being the posterboy for LiteSpeed, which has very expensive licensing (they charge $250 PER CORE in your server, a dual opteron 280 would cost you $1,000) and they also delve in censorship with a policy that bans its use for legal adult content (I wonder how come WordPress.com runs LiteSpeed, when it's chock full of adult content to the point of being banned in Turkey?).

    Anyway, I think WordPress should use its considerable clout and influence to foster the development of LightTPD and / or NGINX as fast, efficient and FREE webserver alternatives.

    So going back to my original question, I wonder if it's possible to configure the server so that the static html pages are served by other than Apache. I don't mean the entire server running Nginx or Lighty, but a "normal" server with Apache and Nginx or Lighty as a proxy for serving content and the static html pages.

    And please, please, someone publish how to get WordPress permalinks to work under Lighty or NGINX, that would be a great start towards dropping LiteSpeed.

  2. cicloid
    Member
    Posted 6 years ago #

    Actually I'm working on it, maybe by monday I would have this figured out for nginx, Stay tunned! :D

  3. Donncha O Caoimh
    Member
    Posted 6 years ago #

    I did a few searches for nginx and wordpress mod_rewrite rules and found a few interesting sites. At least one listed rules to make WordPress work on nginx.

    cicloid - looking forward to seeing those rules!

  4. bolonki
    Member
    Posted 6 years ago #

    Look forward to your report Cicloid! Nginx looks very promising indeed, perhaps this could be the start of a fruitful association between WordPress and Nginx.

    I certainly hope so, since I believe it's a mistake by WordPress.org and WordPress.com to use LiteSpeed, a very expensive commercial, closed source webserver that clearly has drawn code from both LightTPD and Nginx, as can be surmised from several posts by its lead developer George Wang. Nginx has defeated LiteSpeed in *independent* tests (and not the improbable ones posted at their site):

    Take a look at this Nginx vs LiteSpeed test, and take a look at the graph that shows Nginx with a transfer rate of 70,91 Kbps beating LiteSpeed's 63,36. Look for George Wang's comments on the post, he tries to make a case that the tester didn't have the right "settings", but even his test shows Nginx on a par. It's understandable, his $499 *per CPU core* product was handily beaten by Nginx, a FREE, open source Russian webserver. And I bet Wang keeps borrowing code and ideas from both Nginx and LightTPD for his closed source commercial venture.

    Donncha: your Super Cache it's an AWESOME plugin that deserves to be included in the core WP distribution (if a superfluous toy like 'widgets' made it to the core, this needs to be there as well). Thanks Donncha for a very needed upgrade to Galli's original!

  5. honewatson
    Member
    Posted 6 years ago #

    Some rewrite attempts for nginx are happening over here:

    http://thread.gmane.org/gmane.comp.web.nginx.english/2282/focus=2287

  6. masquerade
    Member
    Posted 6 years ago #

    Permalinks in Lighttpd is incredibly easy and should be found easily with a quick google search, but in case its not:

    $HTTP["host"] == "yourwebsite.com" {
    server.error-handler-404 = "/index.php?error=404"
    }

    That's all really. Looking up lighttpd syntax should be able to let you restrict the 404 handler to specific directories. There are also old lighttpd rewrite rules which are much more efficient than the apache ones, but really using rewrite rules over a 404 handler doesn't matter anyways, and WP will be stubborn and parse the request itself if it can.

    Lighttpd has always gotten along with me and handles very high traffic and loads well, I'd recommend it for daily usage over apache for almost any task.

  7. honewatson
    Member
    Posted 6 years ago #

    Try this config...

    server {
    listen       80;
    server_name  yourmublogs.com *.yourmublogs.com;
    
    location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
    {
    root /home/yourmublogs/public_html;
    expires 30d;
    break;
    }
    
    location / {
    root   /home/yourmublogs/public_html;
    index  index.html index.htm index.php;
    rewrite ^.*/files/(.*) /wp-content/blogs.php?file=$1;
    
    if (!-e $request_filename) {
    rewrite ^.+?(/wp-.*) $1 last;
    rewrite ^.+?(/.*\.php)$ $1 last;
    }
    
    if ($query_string !~ ".*s=.*") {
    rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html;
    }
    
    if ($http_cookie !~ "^.*comment_author_.*$" ) {
    rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html;
    }
    
    if ($http_cookie !~ "^.*wordpressuser.*$" ) {
    rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html;
    }
    
    if ($http_cookie !~ "^.*wp-postpass_.*$" ) {
    rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html
    break;
    }
    
    error_page    404  =  @tricky;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    root   html;
    }
    
    location @tricky {
    rewrite ^ /index.php last;
    fastcgi_pass   127.0.0.1:8098;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME /home/yourmublogs/public_html$fastcgi_script_name;
    include        /usr/local/nginx/conf/fastcgi_params;
    }
    
    location ~ \.php$ {
    fastcgi_pass   127.0.0.1:8098;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME /home/yourmublogs/public_html$fastcgi_script_name;
    include        /usr/local/nginx/conf/fastcgi_params;
    }
    }
  8. BlakkJakk
    Member
    Posted 6 years ago #

    Actually the Nginx vs LiteSpeed test ironically made the case for Apache(FASTCGI) over both of them. In the tests Apache(FASTCGI) out performed the other options in most tests.

    The author claims Apache uses more memory but offers no benchmarks or evidence.

    Interesting.

Topic Closed

This topic has been closed to new replies.

About this Topic