带有gitlab捆绑nginx的PHP不起作用

带有gitlab捆绑nginx的PHP不起作用,php,nginx,gitlab-omnibus,Php,Nginx,Gitlab Omnibus,我已经在CentOS 7上使用omnibus软件包设置了gitlab。我想使用gitlab服务器来托管其他网站。通过将下面的代码添加到/etc/gitlab/gitlab.rb,我已经启用了自定义nginx conf nginx['custom_nginx_config'] = "include /etc/nginx/conf.d/*.conf;" 我还在/etc/nginc/conf.d中创建了conf文件。静态HTML文件正在工作,但当我尝试运行php脚本时,发现一个文件未找到-404错误

我已经在CentOS 7上使用omnibus软件包设置了gitlab。我想使用gitlab服务器来托管其他网站。通过将下面的代码添加到/etc/gitlab/gitlab.rb,我已经启用了自定义nginx conf

nginx['custom_nginx_config'] = "include /etc/nginx/conf.d/*.conf;"
我还在/etc/nginc/conf.d中创建了conf文件。静态HTML文件正在工作,但当我尝试运行php脚本时,发现一个文件未找到-404错误

以下是php的nginx配置:

server{
    listen 80;
    server_name example.com;
    root /var/www/vhosts/example;
    index index.php index.html index.htm;
    location / {
        try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /opt/gitlab/embedded/html;
    }

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include /opt/gitlab/embedded/conf/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }

}
以下是错误日志:

FastCGI在读取来自上游的响应时,在stderr中发送了:“主脚本未知”,客户端x.x.x,服务器:example.com,请求:“GET/HTTP/1.1”,upsteam:fastcgi://127.0.0.1:9000,主机:“example.com”


可能您的问题来自“location~.php$”配置

您已经通过包含正确的fatscgi_参数(而不是默认参数)修复了gitlab omnibus的第一个问题。现在它似乎来自位置配置

请针对您的配置尝试以下代码:

location ~ \.php$ {
   #in your case maybe : /opt/gitlab/embedded/html
   root  [YOUR APP DIRECTORY]; 

   try_files  $uri  $uri/  /index.php?$args;
   index  index.html index.htm index.php;

   fastcgi_param PATH_INFO $fastcgi_path_info;
   fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

   fastcgi_pass 127.0.0.1:9000;
   fastcgi_index index.php;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   fastcgi_intercept_errors on;

   include /opt/gitlab/embedded/conf/fastcgi_params;
}
这个补丁在Debian8服务器上对我有效

希望能有所帮助