Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-03-20 14:43:31

eddiewebb
New Member
Registered: 2010-03-20
Posts: 2

Running TextPattern on nginx

I rely on nginx to host my sites cause it is so darn snappy.

Anyway I am having understanding just what it is the current rewrite rules are doing, so I am unable to write the corresponding nginx logic.

Could someone explain just how the ‘-’ is used? I am used to rewrite rules that turn site.com/section/article into something like site.com/index.php?s=$1&a=$2…
ANd why does the default rule check for files, directories, and favicon seperatly?

Thanks kindly,

Eddie
—-

Right now my admin panel works fine without many riles, but I can’t view the site without decoding this.

Offline

#2 2010-03-20 14:57:51

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Running TextPattern on nginx

The .htaccess rules won’t directly rewrite anything with logic you are after (use plain get vars and such). The rules are used to deliver all requests to index.php which then decides what to show depending on the requested URI.

The check for existing directories and files is there just to filter them, and deliver the actual content (file or directory) instead of letting TXP to handle it.

The check for favicon is there for same reason. Because most browsers request favicons automatically from the domain root even when there is no favicon defined. The rule is there to exclude the rewrite process just like with existing files and directories. Othervise if there is no favicon, the request would be handled by Textpattern.

eddiewebb wrote:

Right now my admin panel works fine without many riles, but I can’t view the site without decoding this.

Well, point is that permlink settings can be changed from TXP’s preferences (Admin / Prefs > Permlink mode). There you can select messy -mode.

Last edited by Gocom (2010-03-20 15:00:27)

Offline

#3 2010-03-21 12:38:40

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Running TextPattern on nginx

The ‘-’ has no special meaning.

To make clean URLs work, Textpattern looks at URL stored in the REQUEST_URI variable. That variable should contain “site.com/section/article” or something similar. All that’s done by the .htaccess file is redirect all requests for files and directories that do not exist (except for the favicon) to the index.php file. All the magic for converting the clean URL into various parameters is done in index.php (well, really publish.php, but it starts in index.php).

Offline

#4 2010-03-22 21:10:17

eddiewebb
New Member
Registered: 2010-03-20
Posts: 2

Re: Running TextPattern on nginx

Thanks to both of you.

So for the time being I have ‘messy urls’, and am pointing non-existent file paths to index.php anyway. But assuming messy urls, the rewrite rules should have no impact..

But I am still unable to view site, I just get kicked to my content creation page every time if a user, or the login if not. It sounds like it may have more to do with the wordpress import than rewrite rules…

Is the visible webroot folder to be the downloaded archive root, or the ‘textpattern’ folder beneath it? Both use identical .htaccess files and have index scripts.

/home/me/webroot/texpat.webbmaster.org/textpattern-4.2.0/textpattern
OR
/home/me/webroot/texpat.webbmaster.org/textpattern-4.2.0

MY Installation

Offline

#5 2010-03-22 22:21:45

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Running TextPattern on nginx

You didn’t install it in the correct location.
For example: the files that are visible at http://texpat.webbmaster.org/lang/ should be at http://texpat.webbmaster.org/textpattern/lang/
It seems that you didn’t install it in the root directory of your website, but in the parent directory of that root dir. That’s why visiting http://texpat.webbmaster.org/ leads to the admin side login (which should be at http://texpat.webbmaster.org/textpattern/)

Offline

#6 2010-03-22 22:38:11

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Running TextPattern on nginx

You should have uploaded only the contents of the folder textpattern-4.2.0, not the folder itself. Did you follow the Detailed installation instructions?

Offline

#7 2010-04-02 20:26:39

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

Re: Running TextPattern on nginx

Yeah, I tried this today and gave up, getting clean URLs to work is impossible. There is nginx and textpattern by Ross Lonstein that suggests otherwise, but clean URLs are not working properly, nor does paging or searching.

If you want to save yourself a lot of hassle, forget nginx for TXP. It works fine with Wordpress (I set up another install a few days ago).

If you think about it, there’s not much in using nginx over Apache. If you remove all the modules that you’re not using, tweak the mpm_prefork a bit, you can get a very snappy Apache with a very low memory footprint. Yes, it is not as cool as nginx, but does it really matter?

Last edited by gerhard (2010-04-02 20:26:48)

Offline

#8 2010-04-14 01:00:49

rlonstein
New Member
Registered: 2010-04-14
Posts: 1
Website

Re: Running TextPattern on nginx

gerhard wrote:

Yeah, I tried this today and gave up, getting clean URLs to work is impossible. There is nginx and textpattern by Ross Lonstein that suggests otherwise, but clean URLs are not working properly, nor does paging or searching.

Hi, I’m the author of that blog post and clean urls do seem to be working with nginx and textpattern. I’m not an expert with nginx (or Txp, for that matter), but I use it regularly and sat down with the documentation and fiddled with the config until it worked then stripped the nginx rules apart and tried to get a concise set.

I agree that unless you have some important reason not to use Apache just do it and save yourself the trouble.

Drop me an email if you want to discuss (the site is not the above blog) but I’m fairly sure there’s nothing I left out.

- Ross

Offline

#9 2010-05-04 16:26:27

archayl
New Member
Registered: 2010-04-03
Posts: 5

Re: Running TextPattern on nginx

Hi all, here is what I’ve done on my local nginx server to work with TXP clean URL.

I put this rule inside /etc/nginx/sites-enabled/default, which is the default site configuration file in Ubuntu nginx installation. Put it in any conf file of your TXP server.

My TXP installation is in relative directory is /wizz

location /wizz {
        if (-e $request_filename) {
            break;
        }
        rewrite ^/wizz/(.*)$ /wizz/index.php?=$1 last;
}

The first rule is to capture any request with extension, and that should be static files such as .js, .css, .html and .ico. This stands on the principle of clean URL doesn’t include period.

The second rule is to capture all things other than the above. Basically, this script is just a translation to from the default .htaccess provided by default TXP installation, except for the HTTP Auth.

Hope this helps somebody. Anything not right here, please do response.

Edited: I misunderstood the rewrite condition earlier. Fixed.

Last edited by archayl (2010-06-08 15:57:15)

Offline

#10 2011-05-22 23:59:22

minusf
Member
Registered: 2005-02-15
Posts: 104

Re: Running TextPattern on nginx

just a quick post: txp works fine with nginx, clean urls, everything.
i highly recommend nginx. tried once, never looked back.

any devs reading this? i think it’s high time teaching
txp_diag.php about other webservers, apache hasn’t been
the only gig in town for years now. no self-respecting
c10k web server comes without basic stuff like url rewriting
these days. though i am not a fan of cherokee/lighty,
i am sure txp runs on them just fine.

example of a relevant /etc/nginx/nginx.conf part:

       server {
                server_name www.example.com example.com;
                access_log /var/log/nginx/example.com-access.log main;
                root /var/www/htdocs/example.com;

                # hostname nacism
                if ($host ~* ^example\.com) {
                        rewrite ^(.*)$ http://www.example.com$1 permanent;
                }

                # no more if (-e $request_name) rewriting, really, this is it
                try_files $uri $uri/ /index.php?$args;

                location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
                        access_log      off;
                        expires         30d;
                }

                location ~ \.php$ {
                        fastcgi_pass    127.0.0.1:8090;
                }
        }

we is experts™

Offline

#11 2011-05-23 09:24:59

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Running TextPattern on nginx

It would perhaps help if you describe what exactly doesn’t work on the diagnostics tab when using nginx. Even better if you provide a patch.

PS. Read this article about setting up nginx and php-fastcgi securely.

Offline

#12 2011-05-23 11:19:54

minusf
Member
Registered: 2005-02-15
Posts: 104

Re: Running TextPattern on nginx

i didn’t say something was not working. i meant that txp_diag could drop the
scare red letter warning that Clean URLs are only supported by Apache, use at your own risk


we is experts™

Offline

Board footer

Powered by FluxBB