fossar / selfoss

multipurpose rss reader, live stream, mashup, aggregation web application
https://selfoss.aditu.de
GNU General Public License v3.0
2.36k stars 343 forks source link

Struggle with install #1223

Closed MatthK closed 4 years ago

MatthK commented 4 years ago

I have a clean install of a ubuntu 20.04 server with nginx and php7.4-fpm.

I then followed the guide here https://github.com/fossar/selfoss/wiki/Example-step-by-step-installation-using-nginx-and-SQLite and adjusted the config file to use a MySql database. I created a database selfoss and gave a selfoss user full privileges on that database.

When I go to the website, I just receive "an error occured". In the error.log I get the following error message:

2020/09/24 23:45:07 [error] 19091#19091: *56 FastCGI sent in stderr: "PHP message: HTTP 404 (GET )PHP message: [index.php:80] Base->run()" while reading response header from upstream, client: 192.168.7.10, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "selfoss.domain.com"

I then tried to access cliupdate.php but also received error messages. The first time I received:

2020/09/24 23:22:31 [error] 19091#19091: *10 FastCGI sent in stderr: "PHP message: PDOStatement: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)PHP message: [daos/mysql/Database.php:75] DB\SQL->exec()PHP message: [daos/Items.php:24] daos\mysql\Database->__construct()PHP message: [helpers/ContentLoader.php:23] daos\Items->__construct()PHP message: [cliupdate.php:6] helpers\ContentLoader->__construct()" while reading response header from upstream, client: 192.168.7.10, server: , request: "GET /cliupdate.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "selfoss.domain.com"

When I tried again, I the error log shows now consistently the following error:

2020/09/24 23:25:21 [error] 19091#19091: *14 FastCGI sent in stderr: "PHP message: PDOStatement: Trigger does not existPHP messagee: [daos/mysql/Database.php:235] DB\SQL->exec()PHP message: [daos/Items.php:24] daos\mysql\Database->__construct()PHP message: [helpers/ContentLoader.php:23] daos\Items->__construct()PHP message: [cliupdate.php:6] helpers\ContentLoader->__construct()" while reading response header from upstream, client: 192.168.7.10, server: , request: "GET /cliupdate.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "selfoss.domain.com"

I tried to add the trigger manually that I found here: https://selfoss.aditu.de/forum/index.php?mode=thread&id=895 But that didn't help, as it got deleted as soon as I refreshed the page.

How can I get it to work?

jtojnar commented 4 years ago

What version of selfoss did you use? The guide seems to recommend 2.15 which is very old. For PHP 7.4, I would recommend the latest development build from https://github.com/fossar/selfoss#download.

The first error is weird – the request says GET while I would expect GET / to be received. That means the URL gets mangled somewhere between nginx and PHP.

Looking up the second error, it appears MySQL does not like non-deterministic triggers when binary logging is enabled. So when you try to create the trigger manually, it will not get created. You will need to make the user SUPER, run SET GLOBAL log_bin_trust_function_creators = 1;, disable binary logging, or switch to PostgreSQL.

https://dev.mysql.com/doc/refman/5.7/en/stored-programs-logging.html

MatthK commented 4 years ago

Thanks for the quick reply.

I have installed version 2.18, I downloaded the last stable release.

I have deleted the database and recreated a new one. I turned off binary logging. Then I changed the database user in the config.ini to one that has all privileges. When I went to cliupdate.php it did create the database including the trigger on the second try. The page didn't show anything, it was just plain empty.

Now when I go to index.php then I still see the "an error occured" and see this in the error.log.

2020/09/25 09:50:39 [error] 22183#22183: *17 FastCGI sent in stderr: "PHP message: HTTP 404 (GET )PHP message: [index.php:80] Base->run()" while reading response header from upstream, client: 192.168.7.10, server: , request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "selfoss.domain.com"

The selfoss/data/logs/default.log just shows this:

[2020-09-25 09:50:39] selfoss.ERROR: HTTP 404 (GET )

BTW, the MySql database is a version 8.0.

MatthK commented 4 years ago

Out of curiosity I tried it with SQLite. I get the same error message when I go to index.php

2020/09/25 10:15:50 [error] 23114#23114: *2 FastCGI sent in stderr: "PHP message: HTTP 404 (GET )PHP message: [index.php:80] Base->run()" while reading response header from upstream, client: 192.168.7.10, server: , request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "selfoss.domain.com"

Is there something wrong with my php settings?

That's what I have in the nginx conf file for the virtual server:

    location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
         fastcgi_read_timeout 20s;
         fastcgi_pass_request_headers on;
jtojnar commented 4 years ago

Something might be wrong with either nginx config, PHP config, or there might be a bug in f3 (the library selfoss uses for routing).

Could you try to change the source code as follows:

--- a/src/common.php
+++ b/src/common.php
@@ -7,6 +7,11 @@ use Monolog\Handler\NullHandler;
 use Monolog\Handler\StreamHandler;
 use Monolog\Logger;

+echo '<pre>';
+echo(htmlspecialchars(print_r($_SERVER, true)));
+echo '</pre>';
+die;
+
 define('BASEDIR', __DIR__ . '/..');

 $autoloader = @include BASEDIR . '/vendor/autoload.php'; // we will show custom error

and share the output from visiting https://selfoss.domain.com/, https://selfoss.domain.com/foo and https://selfoss.domain.com/cliupdate.php?

MatthK commented 4 years ago

Here are the results:

selfoss.domain.com

Array
(
    [USER] => www-data
    [HOME] => /var/www
    [HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.9,de;q=0.8
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36 Edg/85.0.564.51
    [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
    [HTTP_DNT] => 1
    [HTTP_CONNECTION] => keep-alive
    [HTTP_HOST] => selfoss.domain.com
    [PATH_INFO] => 
    [REDIRECT_STATUS] => 200
    [SERVER_NAME] => selfoss.domain.com
    [SERVER_PORT] => 80
    [SERVER_ADDR] => 192.168.7.68
    [REMOTE_PORT] => 58247
    [REMOTE_ADDR] => 192.168.7.10
    [SERVER_SOFTWARE] => nginx/1.18.0
    [GATEWAY_INTERFACE] => CGI/1.1
    [REQUEST_SCHEME] => http
    [SERVER_PROTOCOL] => HTTP/1.1
    [DOCUMENT_ROOT] => /var/www/selfoss
    [DOCUMENT_URI] => /index.php
    [REQUEST_URI] => /
    [SCRIPT_NAME] => /index.php
    [CONTENT_LENGTH] => 
    [CONTENT_TYPE] => 
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => 
    [SCRIPT_FILENAME] => /var/www/selfoss/index.php
    [FCGI_ROLE] => RESPONDER
    [PHP_SELF] => 
    [REQUEST_TIME_FLOAT] => 1601045141.0232
    [REQUEST_TIME] => 1601045141
)

foo

Array
(
    [USER] => www-data
    [HOME] => /var/www
    [HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.9,de;q=0.8
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36 Edg/85.0.564.51
    [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
    [HTTP_DNT] => 1
    [HTTP_CONNECTION] => keep-alive
    [HTTP_HOST] => selfoss.domain.com
    [PATH_INFO] => 
    [REDIRECT_STATUS] => 200
    [SERVER_NAME] => selfoss.domain.com
    [SERVER_PORT] => 80
    [SERVER_ADDR] => 192.168.7.68
    [REMOTE_PORT] => 58247
    [REMOTE_ADDR] => 192.168.7.10
    [SERVER_SOFTWARE] => nginx/1.18.0
    [GATEWAY_INTERFACE] => CGI/1.1
    [REQUEST_SCHEME] => http
    [SERVER_PROTOCOL] => HTTP/1.1
    [DOCUMENT_ROOT] => /var/www/selfoss
    [DOCUMENT_URI] => /index.php
    [REQUEST_URI] => /foo
    [SCRIPT_NAME] => /index.php
    [CONTENT_LENGTH] => 
    [CONTENT_TYPE] => 
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => 
    [SCRIPT_FILENAME] => /var/www/selfoss/index.php
    [FCGI_ROLE] => RESPONDER
    [PHP_SELF] => 
    [REQUEST_TIME_FLOAT] => 1601045184.4956
    [REQUEST_TIME] => 1601045184
)

cliupdate.php

Array
(
    [USER] => www-data
    [HOME] => /var/www
    [HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.9,de;q=0.8
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36 Edg/85.0.564.51
    [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
    [HTTP_DNT] => 1
    [HTTP_CONNECTION] => keep-alive
    [HTTP_HOST] => selfoss.domain.com
    [PATH_INFO] => 
    [REDIRECT_STATUS] => 200
    [SERVER_NAME] => selfoss.domain.com
    [SERVER_PORT] => 80
    [SERVER_ADDR] => 192.168.7.68
    [REMOTE_PORT] => 58247
    [REMOTE_ADDR] => 192.168.7.10
    [SERVER_SOFTWARE] => nginx/1.18.0
    [GATEWAY_INTERFACE] => CGI/1.1
    [REQUEST_SCHEME] => http
    [SERVER_PROTOCOL] => HTTP/1.1
    [DOCUMENT_ROOT] => /var/www/selfoss
    [DOCUMENT_URI] => /cliupdate.php
    [REQUEST_URI] => /cliupdate.php
    [SCRIPT_NAME] => /cliupdate.php
    [CONTENT_LENGTH] => 
    [CONTENT_TYPE] => 
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => 
    [SCRIPT_FILENAME] => /var/www/selfoss/cliupdate.php
    [FCGI_ROLE] => RESPONDER
    [PHP_SELF] => 
    [REQUEST_TIME_FLOAT] => 1601045210.8862
    [REQUEST_TIME] => 1601045210
)
MatthK commented 4 years ago

I'm stumped. After having deleted the changes made in the file common.php I just tried http://selfoss.domain.com/ again and it suddenly works.

I know have the page and could add my first feed to it. I'm quite puzzled as I have definitely not touched the system since last night when I tried it.

Anyway, thank you very much for your help and especially for providing that software. I will now happily try it out.

jtojnar commented 4 years ago

The dumps from above look perfectly fine so it must have gotten fixed before then. The only explanation I can come up with is forgetting to restart nginx or PHP-FPM after the changes of their configs :woman_shrugging:

Anyway, glad to hear it works now and hope you will like it. Feel to open an issue or hit me up on chat (https://github.com/fossar/selfoss#support) if you have any problem.