stefanzweifel / screeenly

📸 Screenshot as a Service
https://secure.screeenly.com
MIT License
495 stars 102 forks source link

How to install it under Apache2 #299

Closed TimoHess closed 4 years ago

TimoHess commented 5 years ago

/var/www/screeenly# node -v v11.15.0 /var/www/screeenly# npm -v 6.7.0

I want it reachable under DOMAIN.TLD/screeenly

I followed the guide and I came to the point:

npm install

> puppeteer@1.20.0 install /var/www/screeenly/node_modules/puppeteer
> node install.js

ERROR: Failed to download Chromium r686378! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
{ Error: EACCES: permission denied, mkdir '/var/www/screeenly/node_modules/puppeteer/.local-chromium'
  -- ASYNC --
    at BrowserFetcher.<anonymous> (/var/www/screeenly/node_modules/puppeteer/lib/helper.js:111:15)
    at Object.<anonymous> (/var/www/screeenly/node_modules/puppeteer/install.js:64:16)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
    at internal/main/run_main_module.js:21:11
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/var/www/screeenly/node_modules/puppeteer/.local-chromium' }
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! puppeteer@1.20.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the puppeteer@1.20.0 install 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!     /root/.npm/_logs/2019-09-14T21_08_16_294Z-debug.log

/etc/apache2/sites-avaible/screeenly.conf looks like:

Alias /screeenly "/var/www/screeenly/public"

DocumentRoot /var/www/screeenly/public/
<Directory /var/www/screeenly/public/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 SetEnv HOME /var/www/screeenly/public
 SetEnv HTTP_HOME /var/www/screeenly/public

</Directory>
        ErrorLog ${APACHE_LOG_DIR}/screeenly_error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/screeenly_access.log combined

Looks like this:

grafik

The hyperlinks are going to Domain.tld/[try]

[for example] and not to Domain.tld/screeenly/try

Thx for help

stefanzweifel commented 5 years ago

Hm, I have no experience with installing a Laravel app in a sub-folder. Could you post the value for APP_URL in your .env-file?

I think this should be domain.tld/screeenly.

The npm install problem seems to be permission based.

permission denied, mkdir '/var/www/screeenly/node_modules/puppeteer/.local-chromium'

Can you manually create the folder?

TimoHess commented 4 years ago

Here a litte overview what I´ve tested:

CLICK ME

``` npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2019-09-16T20_55_55_114Z-debug.log root@nextcloud:/var/www/screeenly# service apache2 restart root@nextcloud:/var/www/screeenly# mkdir /var/www/screeenly/node_modules/puppeteer/.local-chromium mkdir: cannot create directory '/var/www/screeenly/node_modules/puppeteer/.local-chromium': No such file or directory root@nextcloud:/var/www/screeenly# mkdir /var/www/screeenly/node_modules/puppeteer/.local-chromium mkdir: cannot create directory '/var/www/screeenly/node_modules/puppeteer/.local-chromium': No such file or directory root@nextcloud:/var/www/screeenly# mkdir /var/www/screeenly/node_modules/ Display all 702 possibilities? (y or n) root@nextcloud:/var/www/screeenly# mkdir /var/www/screeenly/node_modules/pu public-encrypt/ pump/ pumpify/ punycode/ purgecss/ purgecss-webpack-plugin/ root@nextcloud:/var/www/screeenly# mkdir /var/www/screeenly/node_modules/pu public-encrypt/ pump/ pumpify/ punycode/ purgecss/ purgecss-webpack-plugin/ root@nextcloud:/var/www/screeenly# mkdir /var/www/screeenly/node_modules/puppeteer root@nextcloud:/var/www/screeenly# mkdir /var/www/screeenly/node_modules/puppeteer/.local-chromium root@nextcloud:/var/www/screeenly# npm install puppeteer@1.20.0 install /var/www/screeenly/node_modules/puppeteer node install.js ERROR: Failed to download Chromium r686378! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download. { Error: EACCES: permission denied, mkdir '/var/www/screeenly/node_modules/puppeteer/.local-chromium' -- ASYNC -- at BrowserFetcher. (/var/www/screeenly/node_modules/puppeteer/lib/helper.js:111:15) at Object. (/var/www/screeenly/node_modules/puppeteer/install.js:64:16) at Module._compile (internal/modules/cjs/loader.js:816:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10) at Module.load (internal/modules/cjs/loader.js:685:32) at Function.Module._load (internal/modules/cjs/loader.js:620:12) at Function.Module.runMain (internal/modules/cjs/loader.js:877:12) at internal/main/run_main_module.js:21:11 errno: -13, code: 'EACCES', syscall: 'mkdir', path: '/var/www/screeenly/node_modules/puppeteer/.local-chromium' } npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! puppeteer@1.20.0 install: `node install.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the puppeteer@1.20.0 install 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! /root/.npm/_logs/2019-09-16T20_57_41_049Z-debug.log root@nextcloud:/var/www/screeenly# ```

/etc/apache2/sites-avaible/006-screenly.conf

``` # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. ServerName screen.DOMAIN.tld ServerAdmin admin@Domain.tld DocumentRoot /var/www/screeenly/public # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf RewriteEngine on RewriteCond %{SERVER_NAME} =screen.Domain.tld RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] # vim: syntax=apache ts=4 sw=4 sts=4 sr noet ```

I also get the permission error. How you see even after creating the directories.

After chown www-data:www-data /var/www/screeenly/ it finally looks like it.

grafik

But now I get the problem, that only the design is back, but the 4 links on the page gives 404 back. https://screen.DOMAIN.tld/try for example.

stefanzweifel commented 4 years ago

Thanks for your logs. The error during npm install is puppeteer related; so it's probably better to search for solutions on their repo.

A quick search gave me the following possible solutions:

Running the following command seems to fix the problem.

sudo npm install puppeteer --unsafe-perm=true

Concerning links pointing not to the sub-directory: All links in the navigation are hardcoded to use / at the beginning. See the try-link here.

You would have to manually update the _navigation.blade.php-file on your server, or fork the project.

TimoHess commented 4 years ago

I just forgot to add this to vhost configuration:

<Directory /var/www/screeenly/>
        Options +FollowSymlinks
        AllowOverride All
</Directory>

Thanks for your help with npm install puppeteer.

Then I guessed how the github callback link is defined.

For all others:

GITHUB_REDIRECT_URL=https://DOMAIN.tld/oauth/github/handle

stefanzweifel commented 4 years ago

Glad everything works now. 👍🚀

TimoHess commented 4 years ago

I thought it is working now. But when I try to reach the ".tld/api/v1" I got a 404. Any ideas?

When I do composer install and npm install, all works fine.

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName screen.DOMAIN.TLD

        ServerAdmin admin@DMN.TLD
        DocumentRoot /var/www/screeenly/public

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

<Directory /var/www/screeenly/>
        Options +FollowSymlinks
        AllowOverride All
</Directory>

RewriteEngine on
RewriteCond %{SERVER_NAME} =screen.DOMAIN.TLD
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Is it, because I´m using subdomain?

stefanzweifel commented 4 years ago

The API endponit is /api/v1/fullsize not just /api/v1. (Docs) Could you test your installation with the correct endpoint?

What exactly do you mean with "When I do composer install and npm install, all works fine."? Are you trying to run the application without running these commands? Do you delete vendor and node_modules regularly?!

Is it, because I´m using subdomain?

This shouldn't have any impact.