Welcome! Log In Create A New Profile

Advanced

Re: Wordpress Multi-Site Converting Apache to Nginx

Francis Daly
April 30, 2014 03:16AM
On Tue, Apr 29, 2014 at 11:33:57PM -0400, Nick Rahl wrote:

Hi there,

> >That's not what ^~ means.
>
> The manual says, "If the longest matching prefix location has the
> "|^~|" modifier then regular expressions are not checked". Which
> means that a ^~ location will have a higher priority than a regular
> expression rule, right?

Correct.

> location ^~ /wordpress/ {
> try_files $uri /wordpress/index.php =404;
> }
>
> What I intend: "If the URL starts with "/wordpress/", then do not
> check any regular expression rules. Instead, load the requested URI
> directly."

Ok, so long as your idea of "load the requested uri" matches nginx's.

According to http://nginx.org/r/try_files, that should probably try to
send you the content of /usr/local/nginx/html/wordpress/index.php or 404.

> What happens: when visiting "wordpress/" I get a blank page.

What does

curl -v http://whatever/wordpress/

show?

Is your blank page a http 200 with no content, or a http 200 with some
content that the browser shows as blank, or some other http response?

> I have updated this rule to be a regex rule:
>
> llocation ~ ^/(wp-(content|admin|includes).*) {
> try_files /wordpress/$1 /wordpress/$1/index.php =404;
> }
>
>
> What I intend: "If /wp-content followed by anything, or /wp-admin
> followed by anything, or /wp-includes followed by anything: Silently
> (no browser redirect) show the same URL as if a /wordpress/
> directory were inserted in front. ie. "/wp-admin/bob" becomes
> "/wordpress/wp-admin/bob/", but does not do a redirect. If a
> directory, load index.php inside the given directoy."

try_files probably doesn't do what you think it does.

The final argument does an internal rewrite. The other arguments are
served as files in the current context, unless they end in "/" in which
case the "index" value is involved.

> What happens: I visit /wp-admin/ and get wp-admin.php, dumped as plain text.

curl -v http://whatever/wp-admin/

The logs will show which location is used. Can you see which
file-on-the-filesystem wp-admin.php is returned?

(I don't see anything in your provided config which would associate
wp-admin.php with a request for /wp-admin/. I would have expected the
file /usr/local/nginx/html/wordpress/wp-admin/index.php to be returned.)

> It's not passing to PHP.

The initial request will have a "location" chosen.

A subrequest will have a "location" chosen.

"just serve this file" will not have a "location" chosen.

> But I have a PHP block:
>
> location ~ \.php$ {
> try_files $uri =404;
> fastcgi_split_path_info ^(.+\.php)(/.+)$;
> fastcgi_index index.php;

For info: those two lines probably don't do anything useful here.

> include fastcgi_params;
> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
> fastcgi_pass unix:/var/run/php5-fpm.sock;
> }
>
> So it should be passing to PHP?

Not unless there's a request or subrequest that best-matches this
location.

Good luck with it,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Wordpress Multi-Site Converting Apache to Nginx

nrahl April 29, 2014 04:27PM

Re: Wordpress Multi-Site Converting Apache to Nginx

Francis Daly April 29, 2014 06:42PM

Re: Wordpress Multi-Site Converting Apache to Nginx

nrahl April 30, 2014 02:46AM

Re: Wordpress Multi-Site Converting Apache to Nginx

Francis Daly April 30, 2014 03:16AM

Re: Wordpress Multi-Site Converting Apache to Nginx

nrahl May 01, 2014 02:07AM

Re: Wordpress Multi-Site Converting Apache to Nginx

GreenGecko May 01, 2014 02:28AM

Re: Wordpress Multi-Site Converting Apache to Nginx

nrahl May 01, 2014 03:02AM

Re: Wordpress Multi-Site Converting Apache to Nginx

Alan Chandler May 08, 2014 03:32PM

Re: Wordpress Multi-Site Converting Apache to Nginx

Francis Daly May 01, 2014 02:58AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 229
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready