【问题标题】:nginx settings location mis-downloadingnginx设置位置错误下载
【发布时间】:2013-04-21 06:22:32
【问题描述】:

我在 Ubuntu 12.04LTS 上使用 php5-fpm 为 wordpress 和 phpMyAdmin 设置 nginx。

我的 phpMyAdmin 位于/var/www/phpMyAdmin,wordpress 位于 /home/user/workspace/wordpress,MySQL 位于 /var/run/mysqld/mysqld.sock

我想将/ 映射到wordpress,/phpmyadmin 映射到phpMyAdmin,那么我该如何实现呢??

Wordpress 看起来不错,但在访问 /phpmyadmin 时,浏览器将请求“下载”为文件...??

这是我当前的 nginx.conf:

server {
    listen 8000;
    root /home/user/workspace/wordpress;
    index index.html index.htm index.php;\

    location ~* /phpmyadmin { #TODO: shall here be a  tailing slash??
        #TODO: root or alias???
    }

    location ~ \..*/.*\.php$ {
        return 403;
    }
    location / {
        #TODO: show the following line be un-commented??
        #try_files $uri $uri/ /index.php?q=$uri&$args;
        # Uncomment to enable naxsi on this location
        # include /etc/nginx/naxsi.rules
    }
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        fastcgi_intercept_errors on;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;#TODO: could this being removed??
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    #FIXME: and how to block all access to /home/user/workspace/wordpress/server.d/*
    #This doesn't work??
    location /sever\.d {
        autoindex on;
        deny all;
    }

如果所有服务器都以www-data:www-data 运行,我应该为目录wordpress/phpMyAdmin/ 设置什么权限? 目前我设置为755 user:www-data,对吗??

我还没有在linux下设置服务器,我在winxp下使用那些服务器,所以我正在尝试。

【问题讨论】:

    标签: wordpress nginx phpmyadmin php


    【解决方案1】:

    在你的位置之间添加这个

    location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
               }
               location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /phpMyAdmin {
               rewrite ^/* /phpmyadmin last;
        }
    

    介于两者之间 还 您缺少服务器名称。输入 server_name example.com;

    【讨论】:

    • 所以我必须为 phpmyadmin 设置另一个 cgi 处理程序??
    猜你喜欢
    • 2018-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多