Drupal 8 and Nginx File not found on every page but front

Events happening in the community are now at Drupal community events on www.drupal.org.
naeluh's picture

I am trying to install Drupal 8 which I did successfully I am just having a bit of trouble. I a virtual host and in a sub directory I installed d8 but I can only access the front every other page gives me a 404 ?

here is my server config for that directory -

server {
        listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6

        root /var/www/toughcom.com/public_html;
        index index.php index.html index.htm;

        if (!-e $request_filename) {
        rewrite ^/(.)$ /index.php?q=$1 last;
        }

        # Make site accessible from http://localhost/
        server_name toughcom.com;

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ .php$ {
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
                }

        location ~
.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires 1y;
                log_not_found off;
                }


}

Can someone point me to the right the direction heres the location of the install
http://toughcom.com/d8/

thanks

Comments

got it to work thanks

naeluh's picture

got it to work thanks

Hi, Naeluh, can you please

stanleywau's picture

Hi, Naeluh, can you please tell me how to solve this problem? I have same problem as you. thanks

Hi Stanley it was my vhost

naeluh's picture

Hi Stanley it was my vhost file was configured wrong

here is what I ended up with in the conf in the sites-available folder go ahead and try this it worked for me -

server {
        listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6
       
        # This is the full path to your index file
        root /var/www/www.example.com/public_html;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        # This will be your domain name
        server_name example.com;

  location / {
                index index.php;
                # This is cool because no php is touched for static content
                try_files $uri $uri/ @rewrite;
                expires max;
              }

  location @rewrite {
                # Some modules enforce no slash (/) at the end of the URL
                # Else this rewrite block wouldn't be needed (GlobalRedirect)
                rewrite ^/(.*)$ /index.php?q=$1;
              }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
   location ~ .php$ {
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
                }
}

Let me know if this works

thanks

Hi, naeluh, Thanks for your

stanleywau's picture

Hi, naeluh,

Thanks for your help. I fixed this problem.

When I noticed the drupal7 I installed hadn't used the clean URL, and drupal8 used the clean URL, I realized this problem may be caused by clean URL setting. So I tried to set the clean URL on my virtual host configration file, it works.

Thanks for your warm help!

Stanley

same problem

fawad ali's picture

hello i enable the clean urls and also run a2enmode rewrite the then restart apache2 services but do not work for me i am using ubuntu 16.04

Are you trying to use nginx

nateb's picture

Are you trying to use nginx and apache at the same time? You'll have to pick one or the other.

If you're just looking for help with Apace, you may check out the other posts around here.

same problem need some help.

musicster's picture

I using WNMP web server, and here is my config.

worker_processes 1;

error_log logs/error.log;
pid logs/nginx.pid;

events {
# Max value 16384
worker_connections 8192;
# Accept multiple connections
multi_accept on;
}

Settings that affect all server blocks

http {
include php_processes.conf;
include mime.types;
default_type application/octet-stream;

access_log  logs/access.log;

sendfile on;

keepalive_timeout  65;
ssl_session_timeout 10m;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1 SSLv3;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS;
ssl_prefer_server_ciphers on;
gzip  on;
# http server

Begin HTTP Server

server {
listen 80; # IPv4
server_name localhost;

## Parametrization using hostname of access and log filenames.
access_log logs/localhost_access.log;
error_log logs/localhost_error.log;

## Root and index files.
root html;
index  index.php index.html index.htm;

## If no favicon exists return a 204 (no content error).
location = /favicon.ico {
    try_files $uri =204;
    log_not_found off;
    access_log off;
}

## Don't log robots.txt requests.
location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}
## Try the requested URI as files before handling it to PHP.
location / {

    ## Regular PHP processing.
    location ~ \.php$ {
        try_files  $uri =404;
        fastcgi_pass   php_processes;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    ## Static files
    location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {
        expires max;
        log_not_found off;
        ## No need to bleed constant updates. Send the all shebang in one
        ## fell swoop.
        tcp_nodelay off;
        ## Set the OS file cache.
        open_file_cache max=1000 inactive=120s;
        open_file_cache_valid 45s;
        open_file_cache_min_uses 2;
        open_file_cache_errors off;
    }

    ## Keep a tab on the 'big' static files.
    location ~* ^.+\.(?:ogg|pdf|pptx?)$ {
        expires 30d;
        ## No need to bleed constant updates. Send the all shebang in one
        ## fell swoop.
        tcp_nodelay off;
    }
    } # / location

}

End HTTP Server

Begin HTTPS Server

server {
listen 443 http2 ssl;
server_name localhost;
ssl_certificate cert.pem;
ssl_certificate_key key.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

## Parametrization using hostname of access and log filenames.
access_log logs/localhost_access.log;
error_log logs/localhost_error.log;

## Root and index files.
root html;
index  index.php index.html index.htm;

## If no favicon exists return a 204 (no content error).
location = /favicon.ico {
    try_files $uri =204;
    log_not_found off;
    access_log off;
}

## Don't log robots.txt requests.
location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}
## Try the requested URI as files before handling it to PHP.
location / {

    ## Regular PHP processing.
    location ~ \.php$ {
        try_files  $uri =404;
        fastcgi_pass   php_processes;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    ## Static files are served directly.
    location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {
        expires max;
        log_not_found off;
        ## No need to bleed constant updates. Send the all shebang in one
        ## fell swoop.
        tcp_nodelay off;
        ## Set the OS file cache.
        open_file_cache max=1000 inactive=120s;
        open_file_cache_valid 45s;
        open_file_cache_min_uses 2;
        open_file_cache_errors off;
    }

    ## Keep a tab on the 'big' static files.
    location ~* ^.+\.(?:ogg|pdf|pptx?)$ {
        expires 30d;
        ## No need to bleed constant updates. Send the all shebang in one
        ## fell swoop.
        tcp_nodelay off;
    }
    } # / location

} # End HTTPS Server
}

Nginx

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week