【问题标题】:phpmyadmin and nginx gives no input filephpmyadmin 和 nginx 没有给出输入文件
【发布时间】:2016-10-06 12:54:03
【问题描述】:

这是我的主要配置文件

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

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

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  mysite.com www.mysite.com;
        root          /home/mysite/www;
        sendfile off;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        index index.php index.html index.htm;
        location / {
        }
        location /pma {
            alias /usr/share/phpmyadmin;
            location ~ \.php$ {
                try_files $uri @php;
            }
        }
        location @php {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php-fpm;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors off;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
}

phpmyadmin 文件位于 /usr/share/phpmyadmin/ 如果我去 www.mysite.com/pma/ 它给了我 未指定输入文件 并在错误日志中:

2016/06/12 15:48:47 [error] 15999#0: *1 FastCGI sent in stderr: "Unable to open primary script: /home/mysite/www/pma/index.php (No such file or directory)" while reading response header from upstream, client: my-ip, server: mysite.com, request: "GET /pma/ HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "my server ip"

我已经尝试了一切,用 root 更改别名也没有帮助,它正在将 index.php 文件下载到名为“下载”的文件中 我读过我应该使用别名而不是 root。但这似乎并没有解决我的问题...

编辑 我在 default.d 里面也有这个

# pass the PHP scripts to FastCGI server
#
# See conf.d/php-fpm.conf for socket configuration
#
index index.php index.html index.htm;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    try_files $uri =404;
    fastcgi_intercept_errors on;
    fastcgi_index  index.php;
    include        fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_pass   php-fpm;
}

【问题讨论】:

  • 这是一项正在进行的工作吗?因为我看不到您的主(非 phpmyadmin)应用程序应该如何运行 .php 文件。
  • 查看编辑后的回复

标签: php nginx fastcgi


【解决方案1】:

请将别名更改为 root,并确保在 /usr/share/pma 中的 phpmyadmin 路径正确。 在此配置中使用套接字 php-fpm。对不起我的英语不好

# # configure phpmyadmin path
    location /pma {
    root /usr/share;
    index index.php;
    location ~ ^/pma/(.+\.php)$ {
        try_files $uri $uri/ /index.php?$args;
        root /usr/share;
        fastcgi_pass unix:/var/run/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        #fastcgi_param PATH_INFO $fastcgi_script_name;
        include fastcgi_params;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 256 4k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
        fastcgi_intercept_errors on;
    }
    location ~* ^/pma/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
        root /usr/share;
        }
    } 

【讨论】:

    猜你喜欢
    • 2018-02-12
    • 1970-01-01
    • 2011-06-30
    • 2020-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-18
    相关资源
    最近更新 更多