Suporte » Desenvolvendo com WordPress » Nginx – Permalinks Error 404

  • Pessoal, minha instalação local usando o Nginx vem dando problema em relação ao Permalinks.
    Já olhei algum post pelo site, mas não consegui resolver nada.

    #user  nobody;
    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    events {
        worker_connections  1024;
    }
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        # configure temporary paths
        # nginx is started with param -p, setting nginx path to serverpack installdir
        fastcgi_temp_path temp/fastcgi;
        uwsgi_temp_path temp/uwsgi;
        scgi_temp_path temp/scgi;
        client_body_temp_path temp/client-body 1 2;
        proxy_temp_path temp/proxy;
    
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        server_name_in_redirect off;
        server_tokens           off;
    
        server_names_hash_bucket_size 64; # added for longer domain names
        server_names_hash_max_size    512;
    
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        types_hash_max_size 2048;
    
        # Size Limits
        client_body_buffer_size     64k;
        client_header_buffer_size   4k;
        client_max_body_size        8M;
        large_client_header_buffers 4 64k;
    
        # Timeouts
        client_body_timeout     10;
        client_header_timeout   10;
        keepalive_timeout       30;
        send_timeout            10;
        keepalive_requests      10;
    
        # FastCGI
        fastcgi_connect_timeout      60;
        fastcgi_send_timeout         120;
        fastcgi_read_timeout         300; # default: 60 secs; when step debugging with XDEBUG, you need to increase this value
        fastcgi_buffer_size          64k;
        fastcgi_buffers              4 64k;
        fastcgi_busy_buffers_size    128k;
        fastcgi_temp_file_write_size 128k;
    
        # output compression saves bandwidth
        # http://wiki.nginx.org/HttpGzipModule
        gzip                on;
        gzip_vary           on;
        gzip_proxied        any;
        gzip_http_version   1.1;
        gzip_buffers        16 8k;
        gzip_comp_level     5;
        gzip_types          text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    
        # show all files and folders
        autoindex on;
    
        server {
            # access from localhost only
            listen       127.0.0.1:8080;
            server_name  localhost;
            root         www;
    
            # the following default "catch-all" configuration, allows access to the server from outside.
            # please ensure your firewall allows access to tcp/port 80. check your "skype" config.
            # listen       80;
            # server_name  _;
    
            log_not_found off;
            charset utf-8;
    
            access_log  logs/access.log  main;
    
            # handle files in the root path /www
            location / {
                index  index.php index.html index.htm;
            }
    
            #error_page  404              /404.html;
    
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   www;
            }
    
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ \.php$ {
            #    proxy_pass   http://127.0.0.1;
            #}
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9100
            #
            location ~ \.php$ {
                try_files      $uri =404;
                fastcgi_pass   127.0.0.1:9100;
                fastcgi_index  index.php;
                fastcgi_param  PHP_FCGI_MAX_REQUESTS 1000;
                #fastcgi_param  PHP_FCGI_CHILDREN 100;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
    
            # add expire headers and speed up image access with a vary header
            location ~* ^.+.(gif|ico|jpg|jpeg|png|flv|swf|pdf|mp3|mp4|xml|txt|js|css)$ {
                expires 30d;
                add_header Vary Accept-Encoding;
            }
    
            # only allow these request methods
            if ($request_method !~ ^(GET|HEAD|POST)$ ){ return 405; }
    
            # deny access to .htaccess files (if Apache's document root concurs with nginx's one)
            # deny access to git & svn repositories
            location ~ /(\.ht|\.git|\.svn) {
                access_log off;
                log_not_found off;
                deny  all;
            }
        }
    
        # another virtual host using mix of IP-, name-, and port-based configuration
        #
        #server {
        #    listen       8000;
        #    listen       somename:8080;
        #    server_name  somename  alias  another.alias;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
        # HTTPS server
        #
        #server {
        #    listen       443 spdy ssl;
        #    server_name  localhost;
        #    root         www;
        #
        #    ssl                  on;
        #    ssl_certificate      ../../../bin/openssl/certs/cert.pem;
        #    ssl_certificate_key  ../../../bin/openssl/certs/cert.key;
        #
        #    ssl_session_timeout  5m;
        #    ssl_session_cache    shared:SSL:50m;
        #
        #    ssl_protocols              TLSv1.1 TLSv1.2;
        #    ssl_ciphers                HIGH:!aNULL:!MD5;
        #    ssl_prefer_server_ciphers  on;
        #
        #    HSTS
        #    add_header Strict-Transport-Security max-age=15768000;
        #
        #    OCSP Stapling ---
        #    fetch OCSP records from URL in ssl_certificate and cache them
        #    ssl_stapling on;
        #    ssl_stapling_verify on;
        #
        #    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9100
        #    #
        #    location ~ \.php$ {
        #        try_files      $uri =404;
        #        fastcgi_param  HTTPS on;
        #        fastcgi_pass   127.0.0.1:9100;
        #        fastcgi_index  index.php;
        #        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        #        include        fastcgi_params;
        #    }
        #}
    
        # include config files of "enabled" domains
        include domains-enabled/*.conf;
    }

    Vi isso: https://codex.wordpress.org/Nginx#URL_Rewrites_.2F_Permalinks, mas nada adiantou.
    Obs: minha instalação é localhost. path wp:C:\servidor\www\wordpress\

Visualizando 2 respostas - 1 até 2 (de um total de 2)
  • Não entendo muito, nunca usei Nginx como servidor, mais dando uma olhada rapida na internet, me parece que ele não suporta arquivos “.htaccess”.

    Vi em um tópico na Digital Ocean usuários tratando deste assunto, ao que parece, é só alterar a configuração do arquivo:

    /etc/nginx/conf.d

    Isso se tratando de um servidor CentOS, no Windows acho que você deve procurar por ele, e alterar as configurações para:

    location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
            try_files $uri $uri/ /index.php?$args;
        }

    Vê se cheguei ao menos perto =D

    Vi aqui: digitalocean com/community/questions/enabling-nginx-mod_rewrite

    Criador do tópico saulohenrique1997

    (@saulohenrique1997)

    Infelizmente, ainda persiste.

Visualizando 2 respostas - 1 até 2 (de um total de 2)
  • O tópico ‘Nginx – Permalinks Error 404’ está fechado para novas respostas.