设置维基但是nginx给了我一些问题

时间:2012-09-27 16:04:55

标签: nginx mediawiki

我正在尝试在wiki.lightenedblade.com上设置wiki,当我尝试转到该链接时,它会给我一条404消息

但是,我的配置文件和LocalSettings文件似乎不是nginx配置。这是我的NginX配置:

    server {
            listen  80;
            server_name lightenedblade.com www.lightenedblade.com;
            root /home/metalmine/public_html/lightenedblade;

            location / {
                    autoindex on;
                    index index.html;
            }
        location ~ \.php$ {
                    fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
                    fastcgi_index  index.php;
                    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    autoindex on;
                    index index.php;
                    include        fastcgi.conf;
        }

    }

    server {
            server_name wiki.lightenedblade.com;
            root /home/metalmine/public_html/lightenedblade/w;

            # Location for the wiki's root
        location / {
            # Do this inside of a location so it can be negated
            location ~ \.php$ {
                try_files $uri $uri/ =404; # Don't let php execute non-existent php files
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            }
        }

        location /images {
            # Separate location for images/ so .php execution won't apply

            location ~ ^/images/thumb/(archive/)?[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ {
                # Thumbnail handler for MediaWiki
                # This location only matches on a thumbnail's url
                # If the file does not exist we use @thumb to run the thumb.php script
                try_files $uri $uri/ @thumb;
            }
        }
        location /images/deleted {
            # Deny access to deleted images folder
            deny    all;
        }

        # Deny access to folders MediaWiki has a .htaccess deny in
        location /cache       { deny all; }
        location /languages   { deny all; }
        location /maintenance { deny all; }
        location /serialized  { deny all; }

        # Just in case, hide .svn and .git too
        location ~ /.(svn|git)(/|$) { deny all; }

        # Hide any .htaccess files
        location ~ /.ht { deny all; }

        # Uncomment the following code if you wish to hide the installer/updater
        ## Deny access to the installer
        #location /mw-config { deny all; }

        # Handling for the article path
        location /wiki {
            include /etc/nginx/fastcgi_params;
            # article path should always be passed to index.php
            fastcgi_param SCRIPT_FILENAME   $document_root/index.php;
            fastcgi_pass  unix:/var/run/php-fpm/php-fpm.sock;
        }

        # Thumbnail 404 handler, only called by try_files when a thumbnail does not exist
        location @thumb {
            # Do a rewrite here so that thumb.php gets the correct arguments
            rewrite ^/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /thumb.php?f=$1&width=$2;
            rewrite ^/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /thumb.php?f=$1&width=$2&archived=1;

            # Run the thumb.php script
            include /etc/nginx/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME   $document_root/thumb.php;
            fastcgi_pass  unix:/var/run/php-fpm/php-fpm.sock;
        }

    }

这是我的LocalSettings:https://gist.github.com/3794836

感谢您的时间。

1 个答案:

答案 0 :(得分:0)

你到底有什么问题?

我注意到secound“服务器”不是“正在侦听”...你有server_name,但不是例如listen 80 ...

尝试使用nginx -t

它通常会告诉您配置中是否有错误以及在哪里!

编辑(评论不太可读)

找不到404 ...所以服务器正在侦听但没找到您请求的页面(1)。

我注意到你也有:

location / {
            # Do this inside of a location so it can be negated
            location ~ \.php$ {
                try_files $uri $uri/ =404; # Don't let php execute non-existent php files

(1)您请求移动网站的“根”,以便nginx查找和“index。*”

但你没有“index.php”

您可以添加“index index.php;”假设移动站点是php并且文件index.php当然存在

希望这能解决你的问题