[SOLVED]Torrent list not yet available... nginx + php-fpm FreeBSD

lisas4567

Member
May 25, 2018
773
0
16
Hi, I'm trying to setup rtorrent and ruTorrent in FreeBSD (FreeNAS jail). I've tried a numerous combinations of permissions and scgi_port but they all give me this error:

nginx.conf
Code:
master_process on;
worker_processes 4; # Ideally this should match the number of cores your server has!
worker_cpu_affinity 0001 0010 0100 1000;
worker_priority 0;
worker_rlimit_nofile 8192;

error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
multi_accept off;
worker_connections 1024;
use kqueue;
}


http {
include mime.types;
default_type application/octet-stream;

keepalive_timeout 0;

## General Options
charset utf-8;
source_charset utf-8;
ignore_invalid_headers on;
server_name_in_redirect off;

## TCP options
tcp_nodelay off;
tcp_nopush on;

server {
listen 80;
server_name 192.168.1.19;
root /var/www/rutorrent;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ @handler;
expires 30d;
}

location @handler {
rewrite ^ /index.php?/$request_uri;
}

location ~ ^/index.php$ {
root /var/www/rutorrent;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_param FUEL_ENV production;
include fastcgi_params;
}

location ~ \.php$ {
allow 192.168.1.0/24;
deny all;
}

location ~* ^/(modules|application|system) {
return 403;
}

error_page 404 /index.php;

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
allow 192.168.1.0/24;
deny all;
}
}

}
~/.rtorrent.rc
Code: [Select]
scgi_local = /tmp/rpc.socket
log.execute=/home/user/.rtorrent.log

/var/www/rutorrent/conf/config.php
Code:

$scgi_port = 0;
$scgi_host = "unix:///tmp/rpc.socket";

This is how I start rtorrent + rutorrent
Code:
rtorrentand I get this
Code:
(18:08:35) Using 'kqueue' based polling.
(18:08:35) Using 'kqueue' based polling.
(18:08:35) Using 'kqueue' based polling.
(18:08:35) Closed XMLRPC log.
(18:08:35) Opened log file.
Code:
sudo service php-fpm start ; sudo service nginx startand in rutorrent there is this error
Code:
28.08.2013 17:45:05] WebUI started.
[28.08.2013 17:45:05] Bad response from server: (200 [parsererror,getplugins]) <?php require_once( "util.php" ); require_once( "settings.php" ); function pluginsSort($a, $b) { $lvl1 = (float) $a["info"]["plugin.runlevel"]; $lvl2 = (float) $b["info"]["plugin.runlevel"]; if($lvl1>$lvl2) return(1); if($lvl1<$lvl2) return(-1); return( strcmp($a["name"],$b["name"]) ); } function getFlag($permissions,$pname,$fname) { $ret = true; if(array_key_exists($pname,$permissions) && array_key_exists($fname,$permissions[$pname])) $ret = $permissions[$pname][$fname]; else if(array_key_exists("default",$permissions) && array_key_exists($fname,$permissions["default"])) $ret = $permissions["default"][$fname]; return($ret); } function getPluginInfo( $name, $permissions ) { $info = array( 'rtorrent.need'=>1, 'rtorrent.remote'=>'ok', 'rtorrent.external.warning'=>array(), 'rtorrent.external.error'=>array(), 'rtorrent.script.error'=>array(), 'rtorrent.php.error'=>array(), 'rtorrent.version'=>0x802, 'rtorrent.version.readable'=>'0.8.2', 'plugin.may_be_shutdowned'=>1, 'plugin.may_be_launched'=>1, 'plugin.runlevel'=>10.0, 'plugin.description'=>'', 'plugin.author'=>'unknown', 'plugin.dependencies'=>array(), 'php.version'=>0x50000, 'php.version.readable'=>'5.0.0', 'php.extensions.warning'=>array(), 'php.extensions.error'=>array(), 'web.external.warning'=>array(), 'web.external.error'=>array(), 'plugin.help'=>'', ); $fname = "../plugins/".$name."/plugin.info"; if(is_readable($fname)) { $lines = file($fname); foreach($lines as $line) { $fields = explode(":",$line,2); if(count($fields)==2) { $value = addcslashes(trim($fields[1]),"\\\'\"\n\r\t"); $field = trim($fields[0]); switch($field) { case "plugin.help": case "plugin.author": case "plugin.description": case "rtorrent.remote": { $info[$field] = $value; break; } case "plugin.may_be_shutdowned": case "plugin.may_be_launched": case "rtorrent.need": { $info[$field] = intval($value); break; } case "plugin.version": case "plugin.runlevel": { $info[$field] = floatval($value); break; } case "rtorrent.version": case "php.version": { $version = explode('.', $value); $info[$field] = (intval($version[0])<<16) + (intval($version[1])<<8) + intval($version[2]); $info[$field.'.readable'] = $value; break; } case "plugin.dependencies": case "rtorrent.external.warning": case "rtorrent.external.error": case "rtorrent.script.error": case "rtorrent.php.error": case "web.external.warning": case "web.external.error": case "php.extensions.warning": case "php.extensions.error": { $info[$field] = explode(',', $value); break; } // for compatibility case "author": case "description": { $info['plugin.'.$field] = $value; break; } case "remote": { $info['rtorrent.remote'] = $value; break; } case "need_rtorrent": { $info['rtorrent.need'] = intval($value); break; } case "version": case "runlevel": { $info['plugin.'.$field] = floatval($value); break; } } } } $perms = 0; if($permissions!==false) { if(!getFlag($permissions,$name,"enabled")) return(false); $flags = array( "canChangeToolbar" => 0x0001, "canChangeMenu" => 0x0002, "canChangeOptions" => 0x0004, "canChangeTabs" => 0x0008, "canChangeColumns" => 0x0010, "canChangeStatusBar" => 0x0020, "canChangeCategory" => 0x0040, "canBeShutdowned" => 0x0080, /* "canBeLaunched" => 0x0100, */ ); foreach($flags as $flagName=>$flagVal) if(!getFlag($permissions,$name,$flagName)) $perms|=$flagVal; if(!$info["plugin.may_be_shutdowned"]) $perms|=$flags["canBeShutdowned"]; } $info["perms"] = $perms; } return(array_key_exists("plugin.version",$info) ? $info : false); } function findRemoteEXE( $exe, $err, &$remoteRequests ) { $st = getSettingsPath().'/'.rand(); if(!array_key_exists($exe,$remoteRequests)) { $path=realpath(dirname('.')); global $pathToExternals; $add = ''; if(isset($pathToExternals[$exe]) && !empty($pathToExternals[$exe])) $add = " ".escapeshellarg($pathToExternals[$exe]); $req = new rXMLRPCRequest(new rXMLRPCCommand("execute", array( "sh", "-c", escapeshellarg(addslash($path)."test.sh")." ".$exe." ".escapeshellarg($st).$add))); $req->run(); $remoteRequests[$exe] = array( "path"=>$st, "err"=>array() ); } $remoteRequests[$exe]["err"][] = $err; } function testRemoteRequests($remoteRequests) { $ret = ""; foreach($remoteRequests as $exe=>$info) { $file = $info["path"].$exe.".found"; if(!is_file($file)) { foreach($info["err"] as $err) $ret.=$err; } else @unlink($file); } return($ret); } $jResult = "theWebUI.deltaTime = 0;\n"; $access = getConfFile('access.ini'); if(!$access) $access = "../conf/access.ini"; $permissions = parse_ini_file($access); $settingsFlags = array( "showDownloadsPage" => 0x0001, "showConnectionPage" => 0x0002, "showBittorentPage" => 0x0004, "showAdvancedPage" => 0x0008, "showPluginsTab" => 0x0010, "canChangeULRate" => 0x0020, "canChangeDLRate" => 0x0040, "canChangeTorrentProperties" => 0x0080, ); $perms = 0; foreach($settingsFlags as $flagName=>$flagVal) if(array_key_exists($flagName,$permissions) && $permissions[$flagName]) $perms|=$flagVal; $jResult .= "theWebUI.showFlags = ".$perms.";\n"; $jResult .= "theURLs.XMLRPCMountPoint = '".$XMLRPCMountPoint."';\n"; $jResult.="theWebUI.systemInfo = {};\ntheWebUI.systemInfo.php = { canHandleBigFiles : ".((PHP_INT_SIZE<=4) ? "false" : "true")." };\n"; if($handle = opendir('../plugins')) { ignore_user_abort(true); set_time_limit(0); @chmod('/tmp',0777); if(!function_exists('preg_match_all')) { $jResult.="noty(theUILang.PCRENotFound,'error');"; $jResult.="theWebUI.systemInfo.rTorrent = { started: false, iVersion : 0, version : '?', libVersion : '?' };\n"; } else { $remoteRequests = array(); $theSettings = rTorrentSettings::get(true); if(!$theSettings->linkExist) { $jResult.="noty(theUILang.badLinkTorTorrent,'error');"; $jResult.="theWebUI.systemInfo.rTorrent = { started: false, iVersion : 0, version : '?', libVersion : '?', apiVersion : 0 };\n"; } else { if($theSettings->idNotFound) $jResult.="noty(theUILang.idNotFound,'error');"; $jResult.="theWebUI.systemInfo.rTorrent = { started: true, iVersion : ".$theSettings->iVersion.", version : '". $theSettings->version."', libVersion : '".$theSettings->libVersion."', apiVersion : ".$theSettings->apiVersion." };\n"; if($theSettings->mostOfMethodsRenamed) $jResult.="theWebUI.systemInfo.rTorrent.newMethodsSet = true;\n"; if($do_diagnostic) { $up = getUploadsPath(); $st = getSettingsPath(); @chmod($up,$profileMask); @chmod($st,$profileMask); @chmod('./test.sh',$profileMask & 0755); if(PHP_USE_GZIP && (findEXE('gzip')===false)) { @define('PHP_USE_GZIP', false); $jResult.="noty(theUILang.gzipNotFound,'error');"; } if(PHP_INT_SIZE<=4) { if(findEXE('stat')===false) $jResult.="noty(theUILang.statNotFoundW,'error');"; findRemoteEXE('stat',"noty(theUILang.statNotFound,'error');",$remoteRequests); } if(!@file_exists($up.'/.') || !is_readable($up) || !is_writable($up)) $jResult.="noty(theUILang.badUploadsPath+' (".$up.")','error');"; if(!@file_exists($st.'/.') || !is_readable($st) || !is_writable($st)) $jResult.="noty(theUILang.badSettingsPath+' (".$st.")','error');"; if(isLocalMode() && !$theSettings->idNotFound) { if($theSettings->uid<0) $jResult.="noty(theUILang.cantObtainUser,'error');"; else { if(!isUserHavePermission($theSettings->uid,$theSettings->gid,$up,0x0007)) $jResult.="noty(theUILang.badUploadsPath2+' (".$up.")','error');"; if(!isUserHavePermission($theSettings->uid,$theSettings->gid,$st,0x0007)) $jResult.="noty(theUILang.badSettingsPath2+' (".$st.")','error');"; if(!isUserHavePermission($theSettings->uid,$theSettings->gid,'./test.sh',0x0005)) $jResult.="noty(theUILang.badTestPath+' (".realpath('./test.sh').")','error');"; } } if($theSettings->badXMLRPCVersion) $jResult.="noty(theUILang.badXMLRPCVersion,'error');"; } } $plg = getConfFile('plugins.ini'); if(!$plg) $plg = "../conf/plugins.ini"; $permissions = parse_ini_file($plg,true); $init = array(); $names = array(); $disabled = array(); $phpVersion = phpversion(); if( ($pos=strpos($phpVersion, '-'))!==false ) $phpVersion = substr($phpVersion,0,$pos); $phpIVersion = explode('.',$phpVersion); $phpIVersion = (intval($phpIVersion[0])<<16) + (intval($phpIVersion[1])<<8) + intval($phpIVersion[2]); $phpRequired = false; $userPermissions = array( "__hash__"=>"plugins.dat" ); $cache = new rCache(); $cache->get($userPermissions); $cantBeShutdowned = 0x0080; $canBeLaunched = 0x0100; $disabledByUser = 0x8000; $loadedExtensions = array_map("strtolower",get_loaded_extensions()); while(false !== ($file = readdir($handle))) { if($file != "." && $file != ".." && is_dir('../plugins/'.$file)) { if(!array_key_exists($file,$userPermissions)) $userPermissions[$file] = true; $info = getPluginInfo( $file, $permissions ); if($info) { if( $info["plugin.may_be_launched"] && getFlag($permissions,$file,"enabled")=="user-defined") { $info["perms"] |= $canBeLaunched; if(!$userPermissions[$file]) { $info["perms"] |= $disabledByUser; $disabled[$file] = $info; $info = false; } } else $info["perms"] |= $cantBeShutdowned; } if($info!==false) { if(!$theSettings->linkExist && $info["rtorrent.need"]) { $disabled[$file] = $info; continue; } if($info['php.version']>$phpIVersion) { $jResult.="noty('".$file.": '+theUILang.badPHPVersion+' '+'".$info['php.version.readable']."'+'.','error');"; $disabled[$file] = $info; continue; } $extError = false; foreach( $info['php.extensions.error'] as $extension ) if(!in_array( $extension, $loadedExtensions )) { $jResult.="noty('".$file.": '+theUILang.phpExtensionNotFoundError+' ('+'".$extension."'+').','error');"; $extError = true; } if($extError) { $disabled[$file] = $info; continue; } if(count($info['web.external.error']) || count($info['web.external.warning']) || count($info['rtorrent.external.error']) || count($info['rtorrent.external.warning'])) eval( getPluginConf( $file ) ); foreach( $info['web.external.error'] as $external ) { if(findEXE($external)==false) { $jResult.="noty('".$file.": '+theUILang.webExternalNotFoundError+' ('+'".$external."'+').','error');"; $extError = true; } else if($external=='php') $phpRequired = true; } if($extError) { $disabled[$file] = $info; continue; } if($theSettings->linkExist) { if($info['rtorrent.version']>$theSettings->iVersion) { $jResult.="noty('".$file.": '+theUILang.badrTorrentVersion+' '+'".$info['rtorrent.version.readable']."'+'.','error');"; $disabled[$file] = $info; continue; } foreach( $info['rtorrent.external.error'] as $external ) { findRemoteEXE($external,"noty('".$file.": '+theUILang.rTorrentExternalNotFoundError+' ('+'".$external."'+').','error'); thePlugins.get('".$file."').disable();",$remoteRequests); if($external=='php') $phpRequired = true; } foreach( $info['rtorrent.script.error'] as $external ) { $fname = $rootPath.'/plugins/'.$file.'/'.$external; @chmod($fname,$profileMask & 0755); if(!isUserHavePermission($theSettings->uid,$theSettings->gid,$fname,0x0005)) { $jResult.="noty('".$file.": '+theUILang.rTorrentBadScriptPath+' ('+'".$fname."'+').','error');"; $extError = true; } } if($extError) { $disabled[$file] = $info; continue; } foreach( $info['rtorrent.php.error'] as $external ) { $fname = $rootPath.'/plugins/'.$file.'/'.$external; @chmod($fname,$profileMask & 0644); if(!isUserHavePermission($theSettings->uid,$theSettings->gid,$fname,0x0004)) { $jResult.="noty('".$file.": '+theUILang.rTorrentBadPHPScriptPath+' ('+'".$fname."'+').','error');"; $extError = true; } } if($extError) { $disabled[$file] = $info; continue; } if(!isLocalMode()) { if($info["rtorrent.remote"]=="error") { $jResult.="noty('".$file.": '+theUILang.errMustBeInSomeHost,'error');"; $disabled[$file] = $info; continue; } if($do_diagnostic && ($info["rtorrent.remote"]=="warning")) $jResult.="noty('".$file.": '+theUILang.warnMustBeInSomeHost,'error');"; } } if($do_diagnostic) { if($theSettings->linkExist) foreach( $info['rtorrent.external.warning'] as $external ) findRemoteEXE($external,"noty('".$file.": '+theUILang.rTorrentExternalNotFoundWarning+' ('+'".$external."'+').','error');",$remoteRequests); foreach( $info['web.external.warning'] as $external ) if(findEXE($external)==false) $jResult.="noty('".$file.": '+theUILang.webExternalNotFoundWarning+' ('+'".$external."'+').','error');"; foreach( $info['php.extensions.warning'] as $extension ) if(!in_array( $extension, $loadedExtensions )) $jResult.="noty('".$file.": '+theUILang.phpExtensionNotFoundWarning+' ('+'".$extension."'+').','error');"; } $js = "../plugins/".$file."/init.js"; if(!is_readable($js)) $js = NULL; $php = "../plugins/".$file."/init.php"; if(!is_readable($php)) $php = NULL; $init[] = array( "js" => $js, "php" => $php, "info" => $info, "name" => $file ); $names[] = $file; } } } if($phpRequired) { $val = strtoupper(ini_get("register_argc_argv")); if( $val!=='' && $val!='ON' && $val!='1' && $val!='TRUE' ) $jResult.="noty(theUILang.phpParameterUnavailable,'error');"; } usort($init,"pluginsSort"); foreach($init as $plugin) { $jEnd = ''; $pInfo = $plugin["info"]; $deps = array_diff( $pInfo["plugin.dependencies"], $names ); if(count($deps)) { $jResult.="noty('".$plugin["name"].": '+theUILang.dependenceError+' ".implode(",",$deps)."','error');"; $disabled[$plugin["name"]] = $pInfo; continue; } $jResult.="(function () { var plugin = new rPlugin( '".$plugin["name"]."',".$pInfo["plugin.version"]. ",'".$pInfo["plugin.author"]."','".$pInfo["plugin.description"]."',".$pInfo["perms"].",'".$pInfo["plugin.help"]."' );\n"; if($plugin["php"]) require_once( $plugin["php"] ); else $theSettings->registerPlugin($plugin["name"],$pInfo["perms"]); if($plugin["js"]) { $js = file_get_contents($plugin["js"]); if($theSettings->isPluginRegistered($plugin["name"])) $jResult.=$js; else { if(strpos($js,"plugin.loadLang()")!==false) $jResult.="plugin.loadLang();"; } $jResult.="\n"; } $jResult.=$jEnd; $jResult.="\n})();"; } foreach($disabled as $name=>$pInfo) { $jResult.="(function () { var plugin = new rPlugin( '".$name."',".$pInfo["plugin.version"]. ",'".$pInfo["plugin.author"]."','".$pInfo["plugin.description"]."',".$pInfo["perms"].",'".$pInfo["plugin.help"]."' );\n"; $jResult.="plugin.disable(); "; if($pInfo["perms"] & $disabledByUser) $jResult.="plugin.unlaunch(); "; $jResult.="\n})();"; } $jResult.=testRemoteRequests($remoteRequests); $theSettings->store(); } closedir($handle); } cachedEcho($jResult,"application/javascript",true);
[28.08.2013 17:45:05] Bad response from server: (405 [error,getuisettings]) <html> <head><title>405 Not Allowed</title></head> <body bgcolor="white"> <center><h1>405 Not Allowed</h1></center> <hr><center>nginx/1.4.2</center> </body> </html>
I think that the rtorrent isn't starting xmlrpc properly and in the .rtorrent.log there is nothing. I should also mention that this happens with RPC, with RPC and HTTPRC and neither and this even happens when I only start nginx and not php-fpm. The other threads with this problem doesn't help me. This is the guide I followed but I changed a bit: http://blog.bobbyallen.me/2013/01/05/install-nginx-mysql-php-apc-and-memcached-on-freebsd-9-0/

EDIT: I edited to use sockets instead
 

peshua19

Member
May 25, 2018
897
0
16
PHP isn't installed or isn't configured properly. Your web-server returns script body, instead of its running.
 

peshua19

Member
May 25, 2018
897
0
16
Quote :
But rtorrent is running as it should then?


Don't know. May be yes, may be no. This is a your system, right? Try to check this.
 

lisas4567

Member
May 25, 2018
773
0
16
Code:
master_process on;
worker_processes 4; # Ideally this should match the number of cores your server has!
worker_cpu_affinity 0001 0010 0100 1000;
#worker_cpu_affinity 0001 0010;
worker_priority 0;
worker_rlimit_nofile 8192;

error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
multi_accept off;
worker_connections 1024;
use kqueue;
}


http {
include mime.types;
default_type application/octet-stream;

keepalive_timeout 0;

## General Options
charset utf-8;
source_charset utf-8;
ignore_invalid_headers on;
server_name_in_redirect off;

## TCP options
tcp_nodelay off;
tcp_nopush on;

server {
listen 80;
server_name 192.168.1.19;
root /usr/local/www/rutorrent/;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ @handler;
expires 30d;
}

location @handler {
rewrite ^ /index.php?/$request_uri;
}

location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /usr/local/www/rutorrent/$fastcgi_script_name;
fastcgi_param FUEL_ENV production;
include fastcgi_params;
allow 192.168.1.0/24;
deny all;
}

location ~* ^/(modules|application|system) {
return 403;
}

error_page 404 /index.php;

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;

}
}

}


tweaked my config and now it works thanks!