Wordpress nginx redirect loop

后端 未结 5 539
旧巷少年郎
旧巷少年郎 2020-12-15 09:13

So, yesterday I had a question how to install the wordpress in the \"/root\" directory. I wasn\'t very successful in that one and I forgo\'ed on that one.

So, right

5条回答
  •  -上瘾入骨i
    2020-12-15 09:58

    I had a lot of problems when switching from Apache to Nginx in the past, all solved when I purged Apache, which somehow was interfering with Nginx and caused problems to every server. Here is my wordpress configuration for Nginx, according to both Nginx and Wordpress guides for each other:

    server {
        listen 80;
        server_name blog.mysite.com;
    
        root /var/www/wordpress;
        index index.php;
    
        charset utf-8;
    
        location / {
          try_files $uri $uri/ /index.php?$args;
        }
    
        location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
            access_log off; log_not_found off; expires max;
        }
    
        location ~ \.php$ {
            try_files $uri /index.php;
    
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # CHANGE THE LINE ABOVE IF NEEDED
            fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
    

    I didn't even have to change anything in the admin panel when switching servers, it just worked fine.

提交回复
热议问题