简体   繁体   中英

Codeigniter + Nginx + php-fpm = 502 error

i've tried several configuration instructions and forum posts but nothing worked for me, I still get 502-bad gateway errors when I try to access my website.

$config[“index_page”] = “”;

...

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

My nginx configuration:

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

/etc/sites/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;
} 

kind regards, phillip

Follow instruction to add dotdeb.org to you apt sources. Dotdeb.org has packages of modern nginx and php.

  1. apt-get update
  2. apt-get install nginx
  3. configure nginx (your previous config is more or less ok, google "nginx php 5.3" manuals)
  4. apt-get install php5-cli php5-common php5-suhosin //suhosin is good for security
  5. apt-get install php5-fpm php5-cgi
  6. /etc/init.d/nginx restart
  7. /etc/init.d/php5-fpm restart
  8. Try your phpinfo script
  9. Install mysql, pear, etc. Don't forget about some opcode cacher - huge perfomance boost for CI.

Google "nginx php 5.3" for complete manuals, there are many. Wish you not to compile anything from sources :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM