fossar / selfoss

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

Can't run selfoss on Raspberry Pi 1B #1346

Closed Razorfang closed 1 year ago

Razorfang commented 1 year ago

I have an old raspberry pi that I want to install selfoss on. I'm part way through the installation process, having created a postgresql database, installed PHP, and set up an nginx web server.

I have the following message when I visit my feed, and nothing else:

Please build the assets using `npm run build` or obtain a pre-built packages from https://selfoss.aditu.de.

I know the message says there's pre-built packages, but my raspberry pi uses the armv6l architecture, so that won't work.

Seeing this, I installed nodejs on the pi. I'm running node version 11.9 and npm version 6.5.

$ node -v
v11.9.0
$ npm -v
6.5.0
$

Here's what I get when I run npm run build as selfoss suggests:

> selfoss@ build /var/www/rss.getty
> npm run --prefix assets/ build

> @ build /var/www/rss.getty/assets
> parcel build index.html opml.html hashpassword.html --dist-dir ../public/ --public-url ./

/var/www/rss.getty/node_modules/@parcel/core/lib/Parcel.js:150
  #requestTracker
  ^

SyntaxError: Invalid or unexpected token
    at new Script (vm.js:84:7)
    at NativeCompileCache._moduleCompile (/var/www/rss.getty/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/var/www/rss.getty/node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (/var/www/rss.getty/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/var/www/rss.getty/node_modules/@parcel/core/lib/index.js:81:39)
/var/www/rss.getty/node_modules/@parcel/logger/lib/Logger.js:41
  #logEmitter
  ^

SyntaxError: Invalid or unexpected token
    at new Script (vm.js:84:7)
    at NativeCompileCache._moduleCompile (/var/www/rss.getty/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/var/www/rss.getty/node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at _logger (/var/www/rss.getty/node_modules/parcel/lib/cli.js:54:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ build: `parcel build index.html opml.html hashpassword.html --dist-dir ../public/ --public-url ./`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/webby/.npm/_logs/2022-07-17T03_01_20_463Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! selfoss@ build: `npm run --prefix assets/ build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the selfoss@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/webby/.npm/_logs/2022-07-17T03_01_20_815Z-debug.log

Two log files are shown. Here's the contents of /home/webby/.npm/_logs/2022-07-17T03_01_20_463Z-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   '--prefix',
1 verbose cli   'assets/',
1 verbose cli   'build' ]
2 info using npm@6.5.0
3 info using node@v11.9.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle @~prebuild: @
6 info lifecycle @~build: @
7 verbose lifecycle @~build: unsafe-perm in lifecycle true
8 verbose lifecycle @~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/rss.getty/assets/node_modules/.bin:/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/rss.getty/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
9 verbose lifecycle @~build: CWD: /var/www/rss.getty/assets
10 silly lifecycle @~build: Args: [ '-c',
10 silly lifecycle   'parcel build index.html opml.html hashpassword.html --dist-dir ../public/ --public-url ./' ]
11 silly lifecycle @~build: Returned: code: 1  signal: null
12 info lifecycle @~build: Failed to exec build script
13 verbose stack Error: @ build: `parcel build index.html opml.html hashpassword.html --dist-dir ../public/ --public-url ./`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:197:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:197:13)
13 verbose stack     at maybeClose (internal/child_process.js:978:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
14 verbose pkgid @
15 verbose cwd /var/www/rss.getty
16 verbose Linux 5.15.32+
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "--prefix" "assets/" "build"
18 verbose node v11.9.0
19 verbose npm  v6.5.0
20 error code ELIFECYCLE
21 error errno 1
22 error @ build: `parcel build index.html opml.html hashpassword.html --dist-dir ../public/ --public-url ./`
22 error Exit status 1
23 error Failed at the @ build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

And here's the contents of /home/webby/.npm/_logs/2022-07-17T03_01_20_815Z-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm@6.5.0
3 info using node@v11.9.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle selfoss@~prebuild: selfoss@
6 info lifecycle selfoss@~build: selfoss@
7 verbose lifecycle selfoss@~build: unsafe-perm in lifecycle true
8 verbose lifecycle selfoss@~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/rss.getty/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
9 verbose lifecycle selfoss@~build: CWD: /var/www/rss.getty
10 silly lifecycle selfoss@~build: Args: [ '-c', 'npm run --prefix assets/ build' ]
11 silly lifecycle selfoss@~build: Returned: code: 1  signal: null
12 info lifecycle selfoss@~build: Failed to exec build script
13 verbose stack Error: selfoss@ build: `npm run --prefix assets/ build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:197:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:197:13)
13 verbose stack     at maybeClose (internal/child_process.js:978:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
14 verbose pkgid selfoss@
15 verbose cwd /var/www/rss.getty
16 verbose Linux 5.15.32+
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v11.9.0
19 verbose npm  v6.5.0
20 error code ELIFECYCLE
21 error errno 1
22 error selfoss@ build: `npm run --prefix assets/ build`
22 error Exit status 1
23 error Failed at the selfoss@ build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
jtojnar commented 1 year ago

I know the message says there's pre-built packages, but my raspberry pi uses the armv6l architecture, so that won't work.

By pre-built package, it is meant that the client-side JavaScript and CSS is built and PHP libraries installed. There should be no platform-specific binaries so I see no reason why it should not work with ARM.

/var/www/rss.getty/node_modules/@parcel/core/lib/Parcel.js:150
  #requestTracker
  ^

Looking at the error, it looks like your Node.js does not like private properties syntax, which is only supported since Node 12. And that is a minimum required Node version for Parcel as well: https://github.com/parcel-bundler/parcel/blob/a9193ce0b19e93415f264b3295ceee093ddeb8c7/packages/core/core/package.json#L19

Razorfang commented 1 year ago

Alright, I tried unzipping the compressed files instead. Now instead of an error, I get a blank page. I feel this could be a performance bottleneck due to the fact I'm using an old raspberry pi, since the load average gets very high on the pi when I go to the page. I don't know if this is the issue for sure though.

Here is the contents of my config.ini file. I manually created a postgresql database instead of using the default sqlite.

; see https://selfoss.aditu.de for more information about
; the configuration parameters
[globals]
db_type=pgsql
db_host=localhost
db_database=webbyselfoss
db_username=***
db_password=***
db_port=5432
db_prefix=
logger_destination=file:data/logs/default.log
logger_level=ERROR
items_perpage=50
items_lifetime=30
base_url=
username=
password=
salt=lkjl1289
public=
html_title=selfoss
rss_title=selfoss feed
rss_max_items=300
rss_mark_as_read=0
homepage=newest
language=0
auto_mark_as_read=0
auto_collapse=0
auto_stream_more=1
anonymizer=
use_system_font=
share=gtfpde
wallabag=
wallabag_version=1
allow_public_update_access=
unread_order=
load_images_on_mobile=0
auto_hide_read_on_mobile=0
env_prefix=selfoss_
camo_domain=
camo_key=
scroll_to_article_header=1

Here is the database information, which shows the webbyselfoss database I created.

     Name     |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
--------------+----------+----------+-------------+-------------+-----------------------
 postgres     | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 |
 template0    | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres          +
              |          |          |             |             | postgres=CTc/postgres
 template1    | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres          +
              |          |          |             |             | postgres=CTc/postgres
 webbyselfoss | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 |

Blank

Are there any log files I can refer to for more information? Also, is a node version greeater than 11.9 required to run selfoss, or is that just for the postman package?

jtojnar commented 1 year ago

You can see logs in data/logs/default.log. You can increase the verbosity by setting logger_level config key to DEBUG and by adding debug=1 to the config.

Node.js is only required to build selfoss, not to run it.

Razorfang commented 1 year ago

Here's my updated config file. I added in debug=1 and logger_level=DEBUG as requested.

; see https://selfoss.aditu.de for more information about
; the configuration parameters
[globals]
db_type=pgsql
db_host=localhost
db_database=webbyselfoss
db_username=***
db_password=***
db_port=5432
db_prefix=
debug=1
logger_destination=file:data/logs/default.log
logger_level=DEBUG
items_perpage=50
items_lifetime=30
base_url=
username=
password=
salt=lkjl1289
public=
html_title=selfoss
rss_title=selfoss feed
rss_max_items=300
rss_mark_as_read=0
homepage=newest
language=0
auto_mark_as_read=0
auto_collapse=0
auto_stream_more=1
anonymizer=
use_system_font=
share=gtfpde
wallabag=
wallabag_version=1
allow_public_update_access=
unread_order=
load_images_on_mobile=0
auto_hide_read_on_mobile=0
env_prefix=selfoss_
camo_domain=
camo_key=
scroll_to_article_header=1

No log file was generated when I tried to visit the page, and the screen is still pure white. I even restarted the pi after the config changes just to be safe, but no luck.

$ ls data/logs/
$
jtojnar commented 1 year ago
Razorfang commented 1 year ago

I am running PHP 7.4.30

$ php -v
PHP 7.4.30 (cli) (built: Jul  7 2022 15:51:43) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.30, Copyright (c), by Zend Technologies

The version of selfoss that I am using was downloaded from the main website: https://github.com/SSilence/selfoss/releases/download/2.18/selfoss-2.18.zip

I took parts of the attached configuration and placed them into my own nginx.conf file. Now I am working on an nginx configuration issue, because instead of index.php being executed by the pi, it is downloaded by the browser.

server {
   server_name rss.getty.nz;
   root /var/www/rss.getty;
   access_log /var/www/rss.getty/rss.accesss.log;
   error_log /var/www/rss.getty/rss.error.log;

   location / {
      index index.php;
      try_files $uri  /public/$uri /index.php$is_args$args =404;
   }

   location ~ \.php$ {
      include snippets/fastcgi-php.conf ;
      fastcgi_pass unix:/run/php/php7.4-fpm.sock ;
   }

    location ~* \ (gif|jpg|png) {
        expires 30d;
    }
    location ~ ^/(favicons|thumbnails)/.*$ {
        try_files $uri /data/$uri;
    }
    location ~* ^/(data\/logs|data\/sqlite|config\.ini|\.ht) {
        deny all;
    }

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/rss.getty.nz/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/rss.getty.nz/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    if ($host = rss.getty.nz) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

   listen 80;
   listen [::]:80;
   server_name rss.getty.nz;
    return 404; # managed by Certbot
}

Yes, I did restart nginx and hit ctrl-shift-r to clear the browser cache after each change.

jtojnar commented 1 year ago

The nginx config looks about right to me as long as snippets/fastcgi-php.conf works.

I would recommend using the latest development release instead of 2.18 as it has much better error handling: https://github.com/fossar/selfoss#download

Razorfang commented 1 year ago

Okay, I've updated the config and removed the =404 from the location / block. Now I get a white page again instead of downloading the index file, but I get the following errors:

2022/07/22 21:52:15 [error] 3571#3571: *1113 FastCGI sent in stderr: "PHP message: file_put_contents(/var/www/rss.getty/public/all.js): failed to open stream: Permission deniedPHP message: [helpers/View.php:205] file_put_contents()PHP message: [helpers/View.php:31] helpers\View->genMinified()PHP message: [controllers/BaseController.php:22] helpers\View->__construct()PHP message: [index.php:80] Base->run()PHP message: The stream or file "data/logs/default.log" could not be opened: failed to open stream: Permission denied [/var/www/rss.getty/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107]PHP message: [vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php:37] Monolog\Handler\StreamHandler->write()PHP message: [vendor/monolog/monolog/src/Monolog/Logger.php:337] Monolog\Handler\AbstractProcessingHandler->handle()PHP message: [vendor/monolog/monolog/src/Monolog/Logger.php:616] Monolog\Logger->addRecord()PHP message: [common.php:69] Monolog\Logger->error()PHP message: [helpers/View.php:205] file_put_contents()PHP message: [helpers/View.php:31] helpers\View->genMinified()PHP message: [controllers/BaseController.php:22] helpers\View->__construct()PHP message: [index.php:80] Base->run()" while reading response header from upstream, client: 192.168.1.254, server: rss.getty.nz, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "rss.getty.nz", referrer: "https://getty.nz/"

2022/07/22 21:52:15 [error] 3571#3571: *1113 FastCGI sent in stderr: "PHP message: file_put_contents(/var/www/rss.getty/public/all.js): failed to open stream: Permission deniedPHP message: [helpers/View.php:205] file_put_contents()PHP message: [helpers/View.php:31] helpers\View->genMinified()PHP message: [controllers/BaseController.php:22] helpers\View->__construct()PHP message: [index.php:80] Base->run()PHP message: The stream or file "data/logs/default.log" could not be opened: failed to open stream: Permission denied [/var/www/rss.getty/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107]PHP message: [vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php:37] Monolog\Handler\StreamHandler->write()PHP message: [vendor/monolog/monolog/src/Monolog/Logger.php:337] Monolog\Handler\AbstractProcessingHandler->handle()PHP message: [vendor/monolog/monolog/src/Monolog/Logger.php:616] Monolog\Logger->addRecord()PHP message: [common.php:69] Monolog\Logger->error()PHP message: [helpers/View.php:205] file_put_contents()PHP message: [helpers/View.php:31] helpers\View->genMinified()PHP message: [controllers/BaseController.php:22] helpers\View->__construct()PHP message: [index.php:80] Base->run()" while reading response header from upstream, client: 192.168.1.254, server: rss.getty.nz, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "rss.getty.nz", referrer: "https://getty.nz/"
Razorfang commented 1 year ago

Never mind, I fixed by making www-data the owner of the website folder

sudo chown -R www-data:www-data /var/www/rss.getty/
Razorfang commented 1 year ago

I think everything is working now