moving to Nginx server

Having trouble installing serendipity?
keithstevens
Regular
Posts: 15
Joined: Thu Feb 25, 2010 8:23 pm

moving to Nginx server

Post by keithstevens »

Has anyone got the latest version of s9y working with nginx? I transfered an s9y site to a different server running debian linux, nginx and php5-fpm and upgraded the site to the latest version of s9y. The content is there at least partially but most links give a not found error. Found several different rewrite rule lists for s9y googling and tried them all but none of them worked, I think they were all pretty old. I tried converting the apache mod rewrite rules it generated in .htaccess but I get a too many arguments to the rewrite error from nginx so I've got something crooked. So finally to the question, does anyone have an example nginx config for the latest s9y?
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: moving to Nginx server

Post by Timbalu »

Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
keithstevens
Regular
Posts: 15
Joined: Thu Feb 25, 2010 8:23 pm

Re: moving to Nginx server

Post by keithstevens »

Already tried that one. It didn't work. Its from 2008 so its possible the rewrite rules changed since?
thanks,
Keith
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: moving to Nginx server

Post by Timbalu »

No, I don't think they have changed since then... we had a change regarding special hosting (1&1) Servers, I remember.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
keithstevens
Regular
Posts: 15
Joined: Thu Feb 25, 2010 8:23 pm

Re: moving to Nginx server

Post by keithstevens »

Not to argue, but it looks like they have changed because
A. They don't work, and
B. For example, here's the nginx rule from the article you referenced for the archives location:

rewrite ^/archives([/A-Za-z0-9]+)\.html /index.php?url=/archives/$1.html;

and here's the apache rule the installer of the latest version wrote in .htaccess for the archives location:

RewriteRule ^((archives/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+\.html)/?) index.php?/$1 [NC,L,QSA]

Notice the "url=" in the old one that isn't in the new one?
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: moving to Nginx server

Post by Timbalu »

True, that looks different, but I am not sure if it wasnt the Megg User...
keithstevens wrote:RewriteRule ^((archives/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+\.html)/?) index.php?/$1 [NC,L,QSA]
did you try to translate it to something like this?

Code: Select all

rewrite ^((archives/([0-9]+)\-[0-9a-z\.\_!;,\+\-\%]+\.html)/?)$    /index.php?arg=$1   last;
Well, I am just guesing, having no experience with nginx...
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
keithstevens
Regular
Posts: 15
Joined: Thu Feb 25, 2010 8:23 pm

Re: moving to Nginx server

Post by keithstevens »

Yes, and it says:
Testing nginx configuration: [emerg]: invalid number of arguments in "rewrite" directive in /etc/nginx/sites-enabled/100-xyzabc.com.vhost
keithstevens
Regular
Posts: 15
Joined: Thu Feb 25, 2010 8:23 pm

Re: moving to Nginx server

Post by keithstevens »

It was just the ";" needed to be escaped, so now I have rules that pass nginx test but the page loads scrambled and links return not found errors so something is still wrong. Here's my nginx rules translated from the generated apache .htaccess file:
rewrite ^serendipity_admin.php$ serendipity_admin.php last;
rewrite ^((archives/([0-9]+)\-[0-9a-z\.\_!\;,\+\-\%]+\.html)/?)$ index.php?/$1 last;
rewrite ^(authors/([0-9]+)\-[0-9a-z\.\_!\;,\+\-\%]+)$ index.php?/$1 last;
rewrite ^(feeds/categories/([0-9\;]+)\-[0-9a-z\.\_!\;,\+\-\%]+\.rss)$ index.php?/$1 last;
rewrite ^(feeds/authors/([0-9]+)\-[0-9a-z\.\_!\;,\+\-\%]+\.rss)$ index.php?/$1 last;
rewrite ^(categories/([0-9\;]+)\-[0-9a-z\.\_!\;,\+\-\%]+)$ index.php?/$1 last;
rewrite ^archives([/A-Za-z0-9]+)\.html$ index.php?url=/archives/$1.html last;
rewrite ^([0-9]+)[_\-][0-9a-z_\-]*\.html$ index.php?url=$1-article.html last;
rewrite ^feeds/(.*)$ index.php?url=/feeds/$1 last;
rewrite ^unsubscribe/(.*)/([0-9]+)$ index.php?url=/unsubscribe/$1/$2 last;
rewrite ^approve/(.*)/(.*)/([0-9]+)$ index.php?url=approve/$1/$2/$3 last;
rewrite ^delete/(.*)/(.*)/([0-9]+)$ index.php?url=delete/$1/$2/$3 last;
rewrite ^(admin|entries)(/.+)?$ index.php?url=admin/ last;
rewrite ^archive/?$ index.php?url=/archive last;
rewrite ^(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$ rss.php?file=$1&ext=$2 last;
rewrite ^(plugin|plugin)/(.*)$ index.php?url=$1/$2 last;
rewrite ^search/(.*)$ index.php?url=/search/$1 last;
rewrite ^comments/(.*)$ index.php?url=/comments/$1 last;
rewrite ^(serendipity\.css|serendipity_admin\.css)$ index.php?url=/$1 last;
rewrite ^index\.(html?|php.+)$ index.php?url=index.html last;
rewrite ^htmlarea/(.*)$ htmlarea/$1 last;
rewrite (.*\.html?) index.php?url=/$1 last;
keithstevens
Regular
Posts: 15
Joined: Thu Feb 25, 2010 8:23 pm

Re: moving to Nginx server

Post by keithstevens »

It seems the browser is not able to read serendipity.css from the new site and I can't find serendipity.css only serendipity.css.php - Do I need to add some other special rule to nginx config for it?
keithstevens
Regular
Posts: 15
Joined: Thu Feb 25, 2010 8:23 pm

Re: moving to Nginx server

Post by keithstevens »

I got the serendipity.css to load by adding:

location /serendipity.css {
rewrite serendipity.css http://xyzabc.com/serendipity.css.php permanent;
}

to the nginx config and page renders correctly now but the links don't work so the rewrite rules are not working. I think probably the /serendipity.css location would not be needed if the nginx rewrite rules worked properly.
keithstevens
Regular
Posts: 15
Joined: Thu Feb 25, 2010 8:23 pm

Re: moving to Nginx server

Post by keithstevens »

The commented rewrite below works and the page renders correctly but the rule taken from the apache config does not work. To add to the confusion, browsing "http://xyzabc.com/index.php?url=/serendipity.css" returns the contents of the css file. I don't get it.

location /serendipity.css {
rewrite ^(serendipity\.css|serendipity_admin\.css) index.php?url=/$1 last;
# rewrite serendipity.css http://xyzabc.com/serendipity.css.php permanent;
}
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: moving to Nginx server

Post by garvinhicking »

Hi Keith!

Thanks for your work here and documenting progress. I'm not sure I understand; you mean that /serendipity.css does not get rewritten in your current version? What's the actual URL so that I could see things actually (not) working?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
keithstevens
Regular
Posts: 15
Joined: Thu Feb 25, 2010 8:23 pm

Re: moving to Nginx server

Post by keithstevens »

Garvin,
Its not in DNS yet because the site I'm migrating from on apache is live. I have the target nginx servers IP address in my hosts file like this:
216.105.128.116 dodgecountynews.com
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: moving to Nginx server

Post by garvinhicking »

Hi!

OK, patched by hosts file as well - but the serendipity.css does pull up for me properly?!

(The template output says s9y 1.6 is used, so it should be the right server?)
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
keithstevens
Regular
Posts: 15
Joined: Thu Feb 25, 2010 8:23 pm

Re: moving to Nginx server

Post by keithstevens »

Garvin,
I'm going to have to take a break then because I'm not getting it here in either chrome or IE. I'll see what I can figure out and get back. In the mean time would it help to see the nginx config so far?
Post Reply