Convert Apache rewrite to NGinx
Steve Holdoway
steve at greengecko.co.nz
Sun Mar 3 18:59:17 UTC 2013
Why not just use the wp config examples in the docs? Both Wordpress and nginx offer them.
Steve
On 4/03/2013, at 7:38 AM, GASPARD kévin <list-reader at koshie.fr> wrote:
> Thanks for your reply.
>
>> On Sun, Mar 03, 2013 at 01:52:48PM +0100, GASPARD kévin wrote:
>>
>> Hi there,
>>
>>> Using nginx 1.2.1 on Debian Wheezy 64 bits.
>>>
>>> My wordpress need rewrite, it gave me this:
>>
>>> # nginx configuration
>>>
>>> location / {
>>> if (!-e $request_filename){
>>> rewrite ^(.*)$ /index.php break;
>>> }
>>> }
>>
>> See http://wiki.nginx.org/Pitfalls
>>
>> Particularly the "Front Controller Pattern based packages" section.
>>
>> Probably a single extra try_files line will work for you.
>>
>> f
>
> This is my new config file :
>
> server {
> listen 80;
> listen 443 ssl;
> # server_name 176.31.122.26;
> server_name doinalefort.fr www.doinalefort.fr;
> root /var/www/doinalefort.fr;
>
> msie_padding on;
>
> # ssl_certificate /etc/nginx/certs/auction-web.crt;
> # ssl_certificate_key /etc/nginx/certs/auction-web.key;
>
> ssl_session_timeout 5m;
>
> ssl_protocols SSLv2 SSLv3 TLSv1;
> ssl_ciphers HIGH:!aNULL:!MD5;
> ssl_prefer_server_ciphers on;
>
> error_log /var/log/nginx/error.log;
> access_log /var/log/nginx/access.log;
>
> index index.php;
> fastcgi_index index.php;
>
> client_max_body_size 8M;
> client_body_buffer_size 256K;
>
> location ~ \.php$ {
> include fastcgi_params;
>
> # Assuming php-fastcgi running on localhost port 9000
> fastcgi_pass unix:/var/run/php5-fpm.sock;
> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
>
> fastcgi_connect_timeout 60;
> fastcgi_send_timeout 180;
> fastcgi_read_timeout 180;
> fastcgi_buffer_size 128k;
> fastcgi_buffers 4 256k;
> fastcgi_busy_buffers_size 256k;
> fastcgi_temp_file_write_size 256k;
> fastcgi_intercept_errors on;
>
> try_files $uri $uri/ /index.php?q=$uri&$args;
>
> }
> }
>
>
> By checking the URL you gave me it seems to be the good choice for Wordpress (3.5.1). I've restarted nginx, then I've this kind of permalink in Wordpress now: http://doinalefort.fr/%year%/%postname%/ and with the hello world topic it looks like this : http://doinalefort.fr/2013/hello-world/
>
> As you can see, I've a 404 error, in /var/log/nginx/error.log I've: 2013/03/03 19:34:31 [error] 27463#0: *252 "/var/www/doinalefort.fr/2013/hello-world/index.php" is not found (2: No such file or directory), client: 80.239.242.158, server: doinalefort.fr, request: "GET /2013/hello-world/ HTTP/1.1", host: "doinalefort.fr"
>
> And in access.log:
>
> 80.239.242.158 - - [03/Mar/2013:19:35:28 +0100] "GET /2013/hello-world/ HTTP/1.1" 404 142 "-" "Opera/9.80 (X11; Linux x86_64; Edition Next) Presto/2.12.388 Version/12.14"
>
> An idea?
>
> Also, I've googled a little more and I finally found this blog: http://themesforge.com/featured/high-performance-wordpress-part-3/
>
> But honestly I don't have enough Nginx's knowledge to know if this guy have write something serious. If you can tell me if it's okay it'll maybe solve a lot of problem before they appear.
>
> Cordially, Koshie
>
>
> --
> Sorry for my english, I'm trying the best in each e-mail writing. Tell me if I'm not clear enough.
> This mail account is only for list reading, to contact me send an e-mail at kevingaspard at koshie.fr
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
More information about the nginx
mailing list