nginx 仅提供域名的主目录

nginx 仅提供域名的主目录

我已经设置了 nginx,并让它(某种程度上)在两个不同的域上运行。但出于某种原因,无论在地址栏中输入什么,nginx 都只提供目录的索引文件。例如,example.com/about 只显示 example.com

这是我当前的配置,如果你们当中有人能帮助我,我将不胜感激,谢谢!

server {
    listen 80;
    server_name samayres.net www.samayres.net;

    index index.html index.php index.htm;


    access_log /home/sam/www/samayres.net/logs/access_logs.log;
    error_log /home/sam/www/samayres.net/logs/error_logs.log;
    root /home/sam/www/samayres.net;
    error_page 401 401.html;
    error_page 403 403.html;
    error_page 404 404.html;
    error_page 500 502 503 504 500.html;

    location / {
            try_files $uri $uri/ /index.php?$args;
     }

# rewrite adminpanel to use https
    rewrite ^/adminpanel(.*)$ https://$host$uri permanent;

# Add trailing slash to */wp-admin requests. Needed if wordpress is installed later
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

 # Directives to send expires headers
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
             expires 30d;
    }

# Deny all attempts to access hidden files such as .htaccess, .htpasswd
    location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
    }

    location ~ \.php$ {
            try_files index index.php $uri =404;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /home/sam/www/samayres.net/index.php;
             }

}

nginx.conf 是默认的,我没有对其进行任何更改。

答案1

正是因为这个fastcgi_param SCRIPT_FILENAME /home/sam/www/samayres.net/index.php;

它应该是这样的fastcgi_param SCRIPT_FILENAME $document_root/php/$fastcgi_script_name;

根据 NGINX 的文档:http://wiki.nginx.org/HttpFastcgiModule

相关内容