Hi!!!!
I am configuring a Nginx & PHP5-FPM server in a Raspberry and I can open php in other webs but, choosing
this configuration it shows 502 server error.
In another server (apache) it worked but not here.
I have tried a lot of tricks but no luck.
My files are:
1) In
/etc/php5/fpm/pool.d/www.conf
Code:
user = www-data
group = www-data
and
Code:
listen = /var/run/php5-fpm.sock
2) In /etc/nginx/sites-available/mysite.ga (where mysite is my web)
Code:
server {
listen 80;
server_name mysite.ga;
# if ( $http_host ~* "www\.(.*)") {
# rewrite ^ http://$1$request_uri permanent;
# }
access_log /var/log/nginx/opds.access.log;
error_log /var/log/nginx/opds.error.log;
root /home/pi/www/mysite.ga/public_html;
index feed.php;
#Useful only for Kobo reader
# location /download/ {
# rewrite ^/download/(\d+)/(\d+)/.*\.(.*)$ /fetch.php?data=$1&db=$2&type=$3 last;
# rewrite ^/download/(\d+)/.*\.(.*)$ /fetch.php?data=$1&type=$2 last;
# break;
# }
#Can break loading the images - if you don't see anything, comment
location ~ ^/images.*\.(gif|png|ico|jpg)$ {
expires 31d;
}
#Can also break loading the images, comment if it happens
location ~ .(js|css|eot|svg|woff|ttf)$ {
expires 31d;
}
#Not necessarily correct, it depends on distro.
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/tmp/fcgi.sock;
}
location /Calibre {
root /home/pi/www/mysite.ga/public_html/biblio;
internal;
}
}
3) In /etc/nginx/sites-available/default
Code:
# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts to this file
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
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/www;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# root html;
# index index.html index.htm;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
#
# root html;
# index index.html index.htm;
#
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
#
# ssl_session_timeout 5m;
#
# ssl_protocols SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
# ssl_prefer_server_ciphers on;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
4) In /etc/php5/fpm/php.ini I have uncommented:
Code:
cgi.force_redirect = 0
5) My config_default.php is
Code:
<?php
/**
* COPS (Calibre OPDS PHP Server) class file
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Sébastien Lucas <sebastien@slucas.fr>
*/
if (!isset($config))
$config = array();
/*
* The directory containing calibre's metadata.db file, with sub-directories
* containing all the formats.
* BEWARE : it has to end with a /
* You can enable multiple database with this notation instead of a simple string :
* $config['calibre_directory'] = array ("My database name" => "/home/directory/calibre1/", "My other database name" => "/home/directory/calibre2/");
*/
$config['calibre_directory'] = './biblio/';
/*
* SPECIFIC TO NGINX
* The internal directory set in nginx config file
* Leave empty if you don't know what you're doing
*/
$config['calibre_internal_directory'] = '';
/*
* Full URL prefix (with trailing /)
* useful especially for Opensearch where a full URL is often required
* For example Mantano, Aldiko and Marvin require it.
*/
$config['cops_full_url'] = '';
/*
* Number of recent books to show
*/
$config['cops_recentbooks_limit'] = '50';
/*
* Catalog's author name
*/
$config['cops_author_name'] = "Magarto";
/*
* Catalog's author uri
*/
$config['cops_author_uri'] = "http://mysite.ga";
/*
* Catalog's author email
*/
$config['cops_author_email'] = "email@email.com";
/*
* Catalog's title
*/
$config['cops_title_default'] = "Biblioteca Kindle";
/*
* Catalog's subtitle
*/
$config['cops_subtitle_default'] = "";
/*
* Wich header to use when downloading books outside the web directory
* Possible values are :
* X-Accel-Redirect : For Nginx
* X-Sendfile : For Lightttpd or Apache (with mod_xsendfile)
* No value (default) : Let PHP handle the download
*/
$config['cops_x_accel_redirect'] = "";
/*
* Height of thumbnail image for OPDS
*/
$config['cops_opds_thumbnail_height'] = "164";
/*
* Height of thumbnail image for HTML
*/
$config['cops_html_thumbnail_height'] = "164";
/*
* Icon for both OPDS and HTML catalog
* Note that this has to be a real icon (.ico)
*/
$config['cops_icon'] = "favicon.ico";
/*
* Show icon for authors, series, tags and books on OPDS feed
* 1 : enable
* 0 : disable
*/
$config['cops_show_icons'] = "1";
/*
* Default timezone
* Check following link for other timezones :
* http://www.php.net/manual/en/timezones.php
*/
$config['default_timezone'] = "Europe/Paris";
/*
* Prefered format for HTML catalog
* The two first will be displayed in book entries
* The other only appear in book detail
*/
$config['cops_prefered_format'] = array ("EPUB", "PDF", "AZW3", "AZW", "MOBI", "CBR", "CBZ");
/*
* use URL rewriting for downloading of ebook in HTML catalog
* See Github wiki for more information
* 1 : enable
* 0 : disable
*/
$config['cops_use_url_rewriting'] = "0";
/*
* generate a invalid OPDS stream to allow bad OPDS client to use search
* Example of non compliant OPDS client : Moon+ Reader
* Example of good OPDS client : Mantano, FBReader
* 1 : enable support for non compliant OPDS client
* 0 : always generate valid OPDS code
*/
$config['cops_generate_invalid_opds_stream'] = "0";
/*
* Max number of items per page
* -1 unlimited
*/
$config['cops_max_item_per_page'] = "-1";
/*
* split authors by first letter
* 1 : Yes
* 0 : No
*/
$config['cops_author_split_first_letter'] = "1";
/*
* split titles by first letter
* 1 : Yes
* 0 : No
*/
$config['cops_titles_split_first_letter'] = "1";
/*
* Enable the Lightboxes (for popups)
* 1 : Yes (enable)
* 0 : No
*/
$config['cops_use_fancyapps'] = "1";
/*
* Update Epub metadata before download
* 1 : Yes (enable)
* 0 : No
*/
$config['cops_update_epub-metadata'] = "0";
/*
* Filter on tags to book list
* Only works with the OPDS catalog
* Usage : array ("I only want to see books using the tag : Tag1" => "Tag1",
* "I only want to see books not using the tag : Tag1" => "!Tag1",
* "I want to see every books" => "",
*
* Example : array ("All" => "", "Unread" => "!Read", "Read" => "Read")
*/
$config['cops_books_filter'] = array ();
/*
* Custom Columns to add as an array containing the lookup names
* configured in Calibre
*
* For example : array ("genre", "mycolumn");
*
* Note that for now only the first, second and forth type of custom columns are supported
*/
$config['cops_calibre_custom_column'] = array ();
/*
* Rename .epub to .kepub.epub if downloaded from a Kobo eReader
* The ebook will then be recognized a Kepub so with chaptered paging, statistics, ...
* You have to enable URL rewriting if you want to enable kepup.epub download
* 1 : Yes (enable)
* 0 : No
*/
$config['cops_provide_kepub'] = "0";
/*
* Enable and configure Send To Kindle (or Email) feature.
*
* Don't forget to authorize the sender email you configured in your Kindle's Approved Personal Document E-mail List.
*
* If you want to use a simple smtp server (provided by your ISP for example), you can configure it like that :
* $config['cops_mail_configuration'] = array( "smtp.host" => "smtp.free.fr",
* "smtp.username" => "",
* "smtp.password" => "",
* "smtp.secure" => "",
* "address.from" => "cops@slucas.fr"
* );
*
* For Gmail (ssl is mandatory) :
* $config['cops_mail_configuration'] = array( "smtp.host" => "smtp.gmail.com",
* "smtp.username" => "YOUR GMAIL ADRESS",
* "smtp.password" => "YOUR GMAIL PASSWORD",
* "smtp.secure" => "ssl",
* "address.from" => "cops@slucas.fr"
* );
*/
$config['cops_mail_configuration'] = array( "smtp.host" => "xxx", "smtp.username" => "xxxx", "smtp.password" => "xxx", "smtp.secure" => "ssl", "address.from" => "xxx" );
/*
* Use filter in HTML catalog
* 1 : Yes (enable)
* 0 : No
*/
$config['cops_html_tag_filter'] = "0";
/*
* Thumbnails are generated on-the-fly so it can be problematic on servers with slow CPU (Raspberry Pi, Dockstar, Piratebox, ...).
* This configuration item allow to customize how thumbnail will be generated
* "" : Generate thumbnail (CPU hungry)
* "1" : always send the full size image (Network hungry)
* any url : Send a constant image as the thumbnail (you can try "images/bookcover.png")
*/
$config['cops_thumbnail_handling'] = "";
/*
* Contains a list of user agent for browsers not compatible with client side rendering
* For now : Kindle, Sony PRS-T1, Sony PRS-T2, All Cybook devices (maybe a little extreme).
* This item is used as regular expression so "." will force server side rendering for all devices
*/
$config['cops_server_side_render'] = "Kindle|EBRD1101|EBRD1201|cybook";
/*
* Specify the ignored categories for the home screen and with search
* Meaning that if you don't want to search in publishers or tags just add them from the list
* Only accepted values :
* - author
* - book
* - series
* - tag
* - publisher
* - rating
* - language
*/
$config ['cops_ignored_categories'] = array ();
/*
* If you use a Sony eReader or Aldiko you can't download ebooks if your catalog
* is password protected. A simple workaround is to leave fetch.php not protected (see .htaccess).
* But In that case your COPS installation is not completely safe.
* Setting this parameter to "1" ensure that nobody can access fetch.php before accessing
* index.php or feed.php first.
* BEWARE : Do not touch this if you're not using password, not using PRS-TX or not using Aldiko.
*/
$config ['cops_fetch_protect'] = "0";
/*
* WARNING NOT READY FOR PRODUCTION USE
* Make the search better (don't care about diacritics, uppercase should work on Cyrillic) but slower.
* 1 : Yes (enable)
* 0 : No
*/
$config ['cops_normalized_search'] = "1";
/*
* Enable PHP password protection (You can use if htpasswd is not possible for you)
* If possible prefer htpasswd !
* array( "username" => "xxx", "password" => "secret") : Enable PHP password protection
* NULL : Disable PHP password protection (You can still use htpasswd)
*/
$config['cops_basic_authentication'] = NULL;
/*
* Which template is used by default :
* 'default'
* 'bootstrap'
*/
$config['cops_template'] = 'default';
/*
* Set language code to force a language (see lang/ directory for available languages).
* When empty it will auto detect the language.
*/
$config['cops_language'] = '';<?php
6) My www folder is chowned to www-data
7) Errors are:
Code:
2015/05/12 11:41:25 [crit] 4673#0: *4 connect() to unix:/tmp/fcgi.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.0.1$