Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP应用程序重定向周期_Php_Codeigniter_Nginx_Docker - Fatal编程技术网

PHP应用程序重定向周期

PHP应用程序重定向周期,php,codeigniter,nginx,docker,Php,Codeigniter,Nginx,Docker,我让这个应用程序在一个标准的LAMP堆栈上运行,但是当我尝试在docker nginx+php fpm中运行它时,我得到了一个错误(使用.docker容器) 编辑:此容器在同一容器中运行nginx和php fpm 这是标准输出错误: 2016/04/13 23:23:13[错误]20#0:*6内部重定向到“/sistema/index.php/”时的重写或内部重定向周期,客户端:192.168.139.1,服务器:,请求:“GET/sistema/index.php/gui/gui/logi

我让这个应用程序在一个标准的LAMP堆栈上运行,但是当我尝试在docker nginx+php fpm中运行它时,我得到了一个错误(使用.docker容器)

编辑:此容器在同一容器中运行nginx和php fpm

这是标准输出错误:

2016/04/13 23:23:13[错误]20#0:*6内部重定向到“/sistema/index.php/”时的重写或内部重定向周期,客户端:192.168.139.1,服务器:,请求:“GET/sistema/index.php/gui/gui/login HTTP/1.1”,主机:“192.168.139.132”

192.168.139.1--[13/Apr/2016:23:23:13+0000]“GET/sistema/index.php/gui/gui/login HTTP/1.1”500 594“-”Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,如Gecko)Chrome/49.0.2623.112 Safari/537.36”


因此,我不确定是PHP Codeigniter App+ExtJS出了问题,还是URL模式(index.PHP/gui/gui/login)不起作用。

您的nginx配置,是fastcgi的一部分

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
        fastcgi_split_path_info       ^(.+\.php)(.*)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_read_timeout 120;
}
您的配置试图将php代理到unix套接字,而不是9000端口

应该是
fastcgi\u pass unix:/var/run/php5-fpm.sock更改为
fastcgi\u pass 127.0.0.1:9000

下一个。尝试观看php fpm配置,在那里您应该可以找到侦听端口

最后,如果您使用的是docker,请确保所有docker主机都可以相互访问

UPD 1:似乎
.htaccess
也有问题-可以为特定主机保存apache规则,例如重定向。PHP-FPM不会读取该文件并忽略它


UPD 2
.htaccess
可以在PHP web根文件夹(index.PHP所在的位置)中找到

因此,最后的问题是default.conf

使用此问题作为配置指南,我终于做到了:

因此,my/etc/nginx/sites enabled/default.conf的结尾如下:

server {
    listen   80; ## listen for ipv4; this line is default and implied
    listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    #server_name localhost;

    # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
    sendfile off;

    # Add stdout logging

    error_log /dev/stdout info;
    access_log /dev/stdout;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            index index.php;
            try_files $uri $uri/ /index.php?$query_string;
    }
    location /sistema/ {
            index /server/index.php;
            try_files $uri /server/index.php/$uri;
    }
    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /usr/share/nginx/html;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php {
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            include fastcgi_params;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_read_timeout 120;
    }

    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
            expires           5d;
    }

    # deny access to . files, for security
    #
    location ~ /\. {
            log_not_found off;
            deny all;
    }

我不太清楚这到底是如何工作的,所以,这就是我如何使它工作的,但是如果有人能向我解释这一点,我将非常感激。

目前“/etc/php/fpm/pool.d/www.conf”指向“listen=/var/run/php5 fpm.sock”。我应该把它改成“127.0.0.1:9000”吗?PS:它们在同一个docker容器中,根据您的建议进行更改会引发以下错误:[错误]19#0:*1在内部重定向到“/sistema/index.php/gui/gui/login/index.php//index.php//index.php//index.php//index.php//index.php//index.php//index.php//index.php//index.php//index.php//index.php/”,客户端:192.168.139.1,服务器:,请求:“GET/sistema/index.php/gui/gui/login HTTP/1.1”,主机:“192.168.139.132”,如果它们在同一个容器中,unix套接字应该可以工作。是的,你是对的,我正在编辑这个问题。谢谢在你的问题中,你发布了URL
http://ip-vm/sistema/index.php/gui/gui/login
。这是正确的uri吗?我的意思是,您的web服务器应该正确回答
sistema/index.php/gui/gui/login
?或者它不是正确的url?
server {
    listen   80; ## listen for ipv4; this line is default and implied
    listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    #server_name localhost;

    # Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
    sendfile off;

    # Add stdout logging

    error_log /dev/stdout info;
    access_log /dev/stdout;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            index index.php;
            try_files $uri $uri/ /index.php?$query_string;
    }
    location /sistema/ {
            index /server/index.php;
            try_files $uri /server/index.php/$uri;
    }
    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /usr/share/nginx/html;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php {
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            include fastcgi_params;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_read_timeout 120;
    }

    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
            expires           5d;
    }

    # deny access to . files, for security
    #
    location ~ /\. {
            log_not_found off;
            deny all;
    }