Codeigniter + Nginx + php-fpm = 502错误

时间:2011-11-19 14:08:10

标签: codeigniter nginx

我已经尝试了几个配置说明和论坛帖子,但没有对我有用,当我尝试访问我的网站时,我仍然遇到502错误的网关错误。

$config[“index_page”] = “”;

...

$config[“uri_protocol”] = “REQUEST_URI”; // also tried AUTO

我的nginx配置:

server {
    server_name     dev.monitr.io;
    root            /home/monitr/web/dev/www/;
    include         /etc/sites/ci_vhost;
} 

的/ etc /位点/ ci_vhost:

index index.html index.php index.htm;

# set expiration of assets to MAX for caching
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
 expires max;
 log_not_found off;
}

location / {
 # Check if a file exists, or route it to index.php.
 try_files $uri $uri/ @rewrites;
}

location @rewrites {
        if (!-e $request_filename)
        {
            rewrite ^/(.*)$ /index.php/$1 last;
            break;
        }
    }

   location ~ \.php {
        include /etc/nginx/fastcgi_params;

        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
        fastcgi_index index.php;
} 

亲切的问候,菲利普

1 个答案:

答案 0 :(得分:1)

Follow instruction将dotdeb.org添加到apt来源。 Dotdeb.org包含现代nginx和php。

  1. apt-get update
  2. apt-get install nginx
  3. 配置nginx(你之前的配置或多或少没问题,google“nginx php 5.3”手册)
  4. apt-get install php5-cli php5-common php5-suhosin // suhosin有利于安全
  5. apt-get install php5-fpm php5-cgi
  6. /etc/init.d/nginx restart
  7. /etc/init.d/php5-fpm restart
  8. 试试你的phpinfo脚本
  9. 安装mysql,pear等。不要忘记一些操作码cacher - CI的巨大性能提升。
  10. 谷歌“nginx php 5.3”的完整手册,有很多。希望你不要从源代码编译任何东西:)