Need lightttpd clean urls

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
karthick62's picture

Hi,

I have started using drupal on lighttpd for the few days.. My directory set up goes like this .

1./document-root/site
2./document-root/site/subsite1
3./document-root/site/subsite2
I am able to get the clean urls for the above sites using lua scripts. I have no problem on accessing the pages using both apache and lighttpd

But I got another site,like

4./document-root/site/subsite3/subsite3.1

When I click the pages on the subsite3 and subsite3.1 I am getting page not found errors when I use lighttpd. but it works fine with apache2. I need help on this.

Thanks in advance...

Comments

I am using Froxlor with Lighttpd and have Clean URLs

spflanze's picture

I am using the Froxlor control panel to manage my sites. It has an option to use Lighttpd and does vhost but does not use Lighttpd's vhost module.

To make clean URL's possible with this I have added in lighttpd.conf:

# For Drupal clean URLs while not interfering with Froxlor:
url.rewrite-if-not-file = (
   "^[^/]?/$" => "$0",
   "^[^/]
?/froxlor/.$" => "$0",
   "^[^/]
?/phpmyadmin/.$" => "$0",
   "^[^/]
?/([^?]*?)$" => "/index.php?q=$1"
)

The above will make the Froxlor control panel and phpmyadmin available from every domain. I intend to modify the above so it can only be available from a specific domain.

Because Debian's aptitude likes to install phpmyadmin in the path:
/usr/share/phpmyadmin

and Froxlor sets up Lighttpd to expect it in the directory:
/var/www/phpmyadmin

I have made /var/www/phpmyadmin a link to /usr/share/phpmyadmin.

karthick62, when you say you

Garrett Albright's picture

karthick62, when you say you have separate "sites," do you mean that in the Drupal multi-site sense? Or are they being used as separate web roots by Lighty?

Are you using one of the Lighty virtual hosts options? Which one? How is it configured?

At this time I have two

spflanze's picture

At this time I have two domains being served by Lighttpd. One is a dynamic Drupal based site. The other is a static site with several subdomains. Each subdomain is webmastered by a user to whom I have granted access using Froxlor. The Drupal site is a testing site I am using to work on migrating the static site to Drupal using the import_html module. The static site is the production site. At this time I do not have a multisite where a single Drupal codebase handles several domains.

When the migration is complete I will have the same Drupal code base run both domains. When this happens the currently static site will become a Drupal production site and it will also have several subdomains. Some of these subdomains will be static and some Drupal based. To make subdomains Drupal based in a way that is compatible with Froxlor I expect to have to make the directories Froxlor creates for them links to the directory of the main site where Drupal would handle the requests.

I am not yet at the point of figuring out how to make the same Drupal codebase handle two domain names in a way that is compatible with Froxlor. I am sure it is doable.

Since I have two sites on the server I am doing virtual hosting. But Froxlor manages the Bind9 configuration files to do virtual hosting in a way that does not make use of Lighttpd's vhost module.

Froxlor creates a subdirectory for each user to put files that are to be exposed to the web in. This one subdirectory and subdirectories of it contain all files for all websites the user webmasters. I do not believe this a structure that is compatible with Lighttpd's vhost module. I believe the addition to lighttpd.conf I gave above may be compatible with Lighttpd's vhost module. But I am not in a situation to test it.

I have no idea what Froxlor

Garrett Albright's picture

I have no idea what Froxlor is. But here's how my server is set up with regards to multisite.

I use the mod_simple_vhost module, configured like so:

simple-vhost.server-root = "/usr/local/www/"
simple-vhost.default-host = "abweb.us"
simple-vhost.document-root = "/www/"

So in the directory /usr/local/www/abweb.us/www/, I have my main Drupal installation, which is set up like a standard Drupal multisite. Inside other directories under /usr/local/www/, such as /usr/local/www/2problems.com/www/, I have static sites, other Drupal installations for experimental/testing stuff, etc.

So when Lighty gets a request for a certain domain name, it will check if a directory corresponding to that domain name exists; for example, if a request for http://2problems.com/ hits the server, it checks to see if /usr/local/www/2problems.com/www/ exists. If yes, it uses that directory as the document root and serves files from that directory; if no, it uses the default directory (/usr/local/www/abweb.us/www/) as the root, at which point Drupal kicks in and sees if it has a corresponding domain name in its multi-site setup.

On the domain name side of things, I simply modify the A records manually for each domain name to point to my server.

This set-up may be a bit more advanced than you're comfortable with, but it requires no additional software on the server and no messy symlinks, and it's served me well both personally and professionally for years. It's the way I'd recommend going about a situation like this.

As for clean URLs, I leave that to the Lua script. Yes, it can be done in pure config as well, but the Lua script is more tweakable.

Froxlor

spflanze's picture

Froxlor is a control panel just like CPanel is only there is no license fee. It is open source freeware. It is not hardly as well featured as CPanel but does meet my need.

I had trouble with the LUA script so I developed the url.rewrite-if-not-file addition in the configuration file. It does not do all the LUA script can but it is faster and meets my need.

lighttpd.conf Update

spflanze's picture

Here is an updated version of the addition to the lighttpd.conf file for Clean URLs:

# For Drupal clean URLs:
url.rewrite-if-not-file = (
# Pass URLs without file paths or queries unchanged:
   "^[^/]?/$" => "$0",
# Work around for Batch mode in import_html issue http://drupal.org/node/1085426
   "^[^/]
?/batch\?(.$)" => "index.php?q=batch&$1",
# Work around Drupal 6 clean URL login bug issue http://drupal.org/node/1085380:
   "^[^/]
?/(.?)\?destination" => "/index.php?q=$1",
# Pass any unclean URL unchanged:
   ".
?\?.$" => "$0",
# The below prevents update, froxlor, and phpmyadmin from being interefered with:
#   "^[^/]
?/update.php/.$" => "$0",
   "^[^/]
?/froxlor/.$" => "$0",
   "^[^/]
?/phpmyadmin/.$" => "$0",
# Convert a clean URL to an unclean one so Drupal can process it:
   "^[^/]
?/([^?]*?)$" => "/index.php?q=$1"
)

I uncomment the update.php line only when I need to run update.php.

Please edit your post and use

Garrett Albright's picture

Please edit your post and use the "Filtered HTML -- No Markdown" input format so that Markdown doesn't eat your formatting.

It appears I am not able to.

spflanze's picture

It appears I am not able to. For some reason the edit link appears for me only for the posting of mine Sun, 2011-01-09 17:04 and none of the others.

lighttpd config file script excerpt I posted came out find when I copy and pasted it into the Notepad editor on my computer. How was the format eaten for you?

Using Drupal multisite

karthick62's picture

Hi Garrett Albright,

I am using drupal multi site setup.I have not configured any V hosts setup.

I have had to change it again

spflanze's picture

I have had to change it again to handle ? characters in clean URLs. Here is the update:

# For Drupal clean URLs:
url.rewrite-if-not-file = (
# Pass URLs without file paths or queries unchanged:
   "^[^/]?/$" => "$0",
# Work around Drupal 6 clean URL login bug issue http://drupal.org/node/1085380:
   "^[^/]
?/(.?)\?destination" => "/index.php?q=$1",
# Pass any unclean URL unchanged:
   "^[^/]
?/\?.$" => "$0",
   "^[^/]
?/index.php\?.$" => "$0",
# The below prevents update, froxlor, and phpmyadmin from being interfered with:
#   "^[^/]
?/update.php/.$" => "$0",
   "^[^/]
?/froxlor/.$" => "$0",
   "^[^/]
?/phpmyadmin/.$" => "$0",
# Convert a clean URL to an unclean one so Drupal can process it:
   "^[^/]
?/([^?]?)$" => "/index.php?q=$1",
# If there is a ? character in the clean URL it must be converted to an ampersand:
   "^[^/]
?/([^?]?)\?(.?)$" => "/index.php?q=$1&$2"
)

Do you see how your post is

Garrett Albright's picture

Do you see how your post is being mangled? It's because Markdown italicizes things between asterisks. Try again (again), but this time, use the "No Markdown" format if you want your post to be usable by others.

No Markdown Posting

spflanze's picture

url.rewrite-if-not-file = (
# Pass URLs without file paths or queries unchanged:
   "^[^/]*?/$" => "$0",
# Work around Drupal 6 clean URL login bug issue http://drupal.org/node/1085380:
   "^[^/]*?/(.*?)\?destination" => "/index.php?q=$1",
# Pass any unclean URL unchanged:
    "^[^?]*\?[^=/]*=.*$" => "$0",
# The below prevents update, froxlor, webalizer, awstats-icon and phpmyadmin from being interfered with:
   "^[^/]*?/update.php(/.*$)?" => "$0",
   "^[^/]*?/froxlor(/.*$)?" => "$0",
   "^[^/]*?/phpmyadmin(/.*$)?" => "$0",
   "^[^/]*?/webalizer(/.*$)?" => "$0",
   "^[^/]*?/awstats-icon(/.*$)?" => "$0",  
# Convert a clean URL to an unclean one so Drupal can process it:
   "^[^/]*?/([^?]*?)$" => "/index.php?q=$1",
# Question marks must be converted to ampersands:
   "^[^/]*?/([^?]*?)\?(.*?)$" => "/index.php?q=$1&$2"
)

The above was revised on June 18, 2011. This config snippet is not compatible with the Boost cache.