nodeJS not working and stopping Apache

I wanted to use the nodeJS script installer but have several issues/problems with it. This might be based on the fact that there seems to be no documentation on this. Pretty hard to understand things then. (Problem 1)

  1. So I went to the script installer section and installed it.
  2. I tried to install it in the root directory of my webspace, but it got installed in the public_html directory. (Problem 2)
  3. I found the server.js and found out it is running on port 3000
  4. Tried to access it by using domain.com:3000. I got a Connected reset error. (Problem 3)
  5. Most severe issue: Apache was stopped after nodeJS was activated on one server and couldn't be restarted! (Problem 4) It was needed to uninstall the installed nodeJS script using the script installer to get Apache running again.

Btw: Is there any way to allow the use of npm?

Could you please tell me how to use it properly or fix the problems reported?

Status: 
Closed (fixed)

Comments

Howdy -- the Install Scripts can only be installed into public_html, and sub-folders under that. When it mentions installing it into the top-level, it's referring to the public_html folder.

Regarding the errors you're seeing --

Do you see any errors in /var/log/apache2/error_log around the time that you were trying to start Apache? Also, what about in $HOME/logs/error_log?

Those may contain some clues as to why Apache wasn't starting up (we'll get to the other problems you shared shortly).

Is it really a good idea to install node and node scripts into a public directory, where you might be able to download these scripts? I think it is not. That seems to be a potential (security) risk...

That's what is in the /var/log/apache2/error_log for the relevant time frame:

[Tue Jun 28 00:37:03.094772 2016] [mpm_prefork:notice] [pid 4692] AH00171: Graceful restart requested, doing restart
[Tue Jun 28 00:37:03.225358 2016] [auth_digest:notice] [pid 4692] AH01757: generating secret for digest authentication ...
[Tue Jun 28 00:37:03.236868 2016] [proxy:crit] [pid 4692] AH02432: Cannot find LB Method: byrequests
[Tue Jun 28 00:37:03.236898 2016] [:emerg] [pid 4692] AH00020: Configuration Failed, exiting
[Tue Jun 28 01:09:18.868062 2016] [ssl:warn] [pid 12049] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Jun 28 01:09:18.868086 2016] [suexec:notice] [pid 12049] AH01232: suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
[Tue Jun 28 01:09:18.885259 2016] [auth_digest:notice] [pid 12050] AH01757: generating secret for digest authentication ...
[Tue Jun 28 01:09:18.895830 2016] [proxy:crit] [pid 12050] AH02432: Cannot find LB Method: byrequests
[Tue Jun 28 01:09:18.895861 2016] [:emerg] [pid 12050] AH00020: Configuration Failed, exiting
[Tue Jun 28 01:12:34.252393 2016] [ssl:warn] [pid 12854] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Jun 28 01:12:34.252410 2016] [suexec:notice] [pid 12854] AH01232: suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
[Tue Jun 28 01:12:34.269509 2016] [auth_digest:notice] [pid 12855] AH01757: generating secret for digest authentication ...
[Tue Jun 28 01:12:34.282208 2016] [ssl:warn] [pid 12855] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Jun 28 01:12:34.282283 2016] [core:warn] [pid 12855] AH00098: pid file /var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Tue Jun 28 01:12:34.284282 2016] [mpm_prefork:notice] [pid 12855] AH00163: Apache/2.4.7 (Ubuntu) SVN/1.8.8 mod_fcgid/2.3.9 PHP/5.5.9-1ubuntu4.17 OpenSSL/1.0.1f configured -- resuming normal operations
[Tue Jun 28 01:12:34.284302 2016] [core:notice] [pid 12855] AH00094: Command line: '/usr/sbin/apache2'

And from /home/m-mohr/logs/error_log:

[Tue Jun 28 00:37:03.236880 2016] [proxy_balancer:emerg] [pid 4692] (22)Invalid argument: AH01183: Cannot share balancer
[Tue Jun 28 01:09:18.895841 2016] [proxy_balancer:emerg] [pid 12050] (22)Invalid argument: AH01183: Cannot share balancer

I think I installed nodejs around 00:37. At 01:09 / 01:12 I was trying to restart the Apache server.

I'm eagerly awaiting your response.

Ah, it looks like there is a missing Apache module.

Try running this command:

a2enmod lbmethod_byrequests

And then restart Apache.

After that, are you able to setup NodeJS?

Yes, that helped. Now apache and NodeJS are running side-by-side. So this module should be enabled by default (by the installer?) when Virtualmin is running, right?

Seems Problems 2 and 3 are also solved by this. The directory redirects all requests to node and the file in the directory can't be downloaded as expected, right? A port doesn't needs to be specified to.

So the serious problems are solved.

Is there a way to let users use npm via SSH to install scripts? Is there any documentation on the nodeJS stuff and how it is implemented / to be used in Virtualmin?

Thank you.

Yeah it sounds like a bug that this particular module isn't enabled at installation time; I'll talk to Jamie when he returns from traveling about having Virtualmin set that up automatically.

But yes it shouldn't be a problem to have users use npm.

The Virtualmin installer just installs NodeJS into the specified directory -- once that's done, it should then act like any manually installed version.

If you have any questions regarding the setup, we'd be happy to answer them... and we'll make a list of what your questions are, and perhaps create some documentation on that within Virtualmin.

Oddly, I never ran into the problem with this missing module during my testing. I will update our installer to enable it.

Status: Active ยป Fixed

Thank you! Some (user) documentation on how to use NodeJS and NPM with Virtualmin would be highly appreciated.