Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
401 views
in Technique[技术] by (71.8m points)

nginx - Except homepage all links give 404 Not Found on Ubuntu Drupal 8.8.x-dev site

After Drupal 8.8.x-dev installation my website homepage works fine, all others give

404 Not Found nginx/1.14.0 (Ubuntu)

on ubuntu 18.04 LEMP.

Drupal -8.8.x-dev installation on root var/www/blog.rakhikamakshi.in/html.

Command executed -

$ curl --output /tmp/drupal.tar.gz https://ftp.drupal.org/files/projects/drupal-8.8.x-dev.tar.gz
$ sudo rm -fr /var/www/blog.rakhikamakshi.in/public_html
$ sudo tar xf /tmp/drupal-8.8.x-dev.tar.gz -C /var/www/
$ sudo mv /var/www/drupal-8.8.x-dev/ /var/www/blog.rakhikamakshi.in/public_html
$ sudo chown -R www-data.www-data /var/www/blog.rakhikamakshi.in/public_html

Drupal installation command-

$ sudo composer create-project drupal-composer/drupal-project:8.x-dev /var/www/blog.rakhikamakshi.in/public_html --stability dev --no-interaction

Installation successful!

So my Drupal site is on the blog.rakhikamakshi.in/web directory

The problem is the main page (homepage) works fine, all others give 404 error Not Found nginx/1.14.0 (Ubuntu)

in Drupal .htaccess I uncommented RewriteBase /Drupal

1.
# RewriteBase /Drupal                   
To        
RewriteBase /blog.rakhikamakshi.in/public_html/web        
not worked
     
2.
# RewriteBase /Drupal                   
To  
RewriteBase /blog.rakhikamakshi.in/web
not worked
 
3.
# RewriteBase /Drupal                   
To 
RewriteBase /web
Again not worked

my ubuntu 18.04 Nginx.conf configuration is -

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}


#mail {
#   # See sample authentication script at:
#   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#   # auth_http localhost/auth.php;
#   # pop3_capabilities "TOP" "USER";
#   # imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#   server {
#       listen     localhost:110;
#       protocol   pop3;
#       proxy      on;
#   }
# 
#   server {
#       listen     localhost:143;
#       protocol   imap;
#       proxy      on;
#   }
#}

etc/nginx/sites-available/blog.rakhikamakshi.in configuration (using Nginx server block for multiple site) -

# Default server configuration
#
server {
        listen 80;
        listen [::]:80;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
    #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/blog.rakhikamakshi.in/public_html;

    # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;

        server_name blog.rakhikamakshi.in www.blog.rakhikamakshi.in;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        # pass PHP scripts to FastCGI server
 #
        location ~ .php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /.ht {
        #       deny all;
        #}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#       listen 80;
#       listen [::]:80;
#
#       server_name example.com;
#
#       root /var/www/example.com;
#       index index.html;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
#}

my local site root is - /var/www/blog.rakhikamakshi.in/public_html

http://blog.rakhikamakshi.in/phpinfo.php on browser shows -

phpinfo();

Searching on google I found a similar question on StackOverflow link which concerned the apache server, I am using Nginx.

Does someone has any solution on this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...