mongoDB in cPanel
Hello,
We know that mongoDB is not supported in cPanel. But we need to develop a Laravel project with mongoDB and that's why we have installed mongoDB 3.6. Everything is working fine as expected through root user. Below are the mongoDB info:
Only one things we are facing that we are unable to run 'mongo' command via cPanel user terminal, we are getting "-bash: mongo: command not found". Below are the few information of our server, kindly go through and help us. Installed cPanel Version Details root@server1 [/]# /usr/local/cpanel/cpanel -V 78.0 (build 20) ================== Current cPanel Environment: root@server1 [/]# cat /var/cpanel/envtype standard ================== OS Version: root@server1 [/]# cat /etc/redhat-release CloudLinux release 7.6 (Vladimir Lyakhov) Any suggestion would be appreciated. Thanks, Tarak Nath
==========
root@server1 [/]# mongod -version
db version v3.6.12
git version: c2b9acad0248ca06b14ef1640734b5d0595b55f1
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
distmod: rhel70
distarch: x86_64
target_arch: x86_64
----------------------------
root@server1 [/]# systemctl status mongod
? mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2019-04-18 07:21:47 EDT; 2h 5min ago
Docs: The MongoDB 4.0 Manual " MongoDB Manual
Main PID: 21425 (mongod)
CGroup: /system.slice/mongod.service
??21425 /usr/bin/mongod -f /etc/mongod.conf
Apr 18 07:21:45 server1.mydomain.com systemd[1]: Starting High-performance, schema-free document-oriented database...
Apr 18 07:21:45 server1.mydomain.com mongod[21423]: about to fork child process, waiting until server is ready for connections.
Apr 18 07:21:45 server1.mydomain.com mongod[21423]: forked process: 21425
Apr 18 07:21:47 server1.mydomain.com mongod[21423]: child process started successfully, parent exiting
Apr 18 07:21:47 server1.mydomain.com systemd[1]: Started High-performance, schema-free document-oriented database.
----------------------------
root@server1 [/]# mongo
MongoDB shell version v3.6.12
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("04a2eb10-8ee6-4ca3-bc7c-55bc00510047") }
MongoDB server version: 3.6.12
Server has startup warnings:
2019-04-18T07:21:45.974-0400 I STORAGE [initandlisten]
2019-04-18T07:21:45.974-0400 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-04-18T07:21:45.974-0400 I STORAGE [initandlisten] ** See Production Notes " MongoDB Manual
2019-04-18T07:21:47.098-0400 I CONTROL [initandlisten]
2019-04-18T07:21:47.098-0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-04-18T07:21:47.098-0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-04-18T07:21:47.098-0400 I CONTROL [initandlisten]
2019-04-18T07:21:47.098-0400 I CONTROL [initandlisten]
2019-04-18T07:21:47.098-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-04-18T07:21:47.098-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2019-04-18T07:21:47.098-0400 I CONTROL [initandlisten]
2019-04-18T07:21:47.098-0400 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-04-18T07:21:47.098-0400 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2019-04-18T07:21:47.098-0400 I CONTROL [initandlisten]
>
==========
Only one things we are facing that we are unable to run 'mongo' command via cPanel user terminal, we are getting "-bash: mongo: command not found". Below are the few information of our server, kindly go through and help us. Installed cPanel Version Details root@server1 [/]# /usr/local/cpanel/cpanel -V 78.0 (build 20) ================== Current cPanel Environment: root@server1 [/]# cat /var/cpanel/envtype standard ================== OS Version: root@server1 [/]# cat /etc/redhat-release CloudLinux release 7.6 (Vladimir Lyakhov) Any suggestion would be appreciated. Thanks, Tarak Nath
-
Since you are running CloudLinux does that mean you have also enabled cagefs? I'm not sure what all would be involved but you can either take this user out of cagefs or you can add the mongo command to the cage skeleton. 0 -
Thank you @GOT for your response. No, I have not enabled cagefs yet. Should I enable so that we can run "mongo" command from cPanel terminal? Thanks, Tarak Nath 0 -
If you don't have cagefs enabled then that would not be interfering. It's more likely in this case that mongo is in a path that the user does not have in their default path. Make sure the users shell is set to bash and not jailshell and then use the full path to the mongo binary when executing it. The user may also not have per.issikns on the command either 0 -
Hello @Tarak Nath, First, execute the following command as root to find the full path to Mongo: which mongo
Then, access SSH as the user and enter the full path (e.g. /usr/local/bin/mongo) when executing a mongo command. Let me know if this helps. Thank you.0 -
Hello @cPanelMichael , Below is the output as root: root@server1 [~]# which mongo /usr/bin/mongo
And below is out put as cPanel user:user@server1# /usr/bin/mongo bash: /usr/bin/mongo: No such file or directory
We are facing same issue. Thanks, Tarak Nath0 -
user@server1# /usr/bin/mongo bash: /usr/bin/mongo: No such file or directory
Hello @Tarak Nath, You mentioned using CloudLinux with CageDS disabled. Are you positive that CageFS is disabled? You can review the CageFS document below to verify if it's installed or uninstalled: Command-line Tools If it's installed, you'll need to perform the steps noted on the following document (replacing "java" with "mongo"): How to add java to CageFS Let me know if this helps. Thank you.0 -
Hello, I meant to say that said user is in the CageFS not out of CageFS. For testing purposes I have removed the said user from CageFS and noticed that said user able to run 'mongo' command. Is it best practices to remove the user from CageFS for security reasons? Or add the 'mongo' command to CageFS? What you suggest us? Thanks, Tarak Nath 0 -
Is it best practices to remove the user from CageFS for security reasons? Or add the 'mongo' command to CageFS?
Hello @Tarak Nath, Making the "mongo" command available to CageFS is generally the better approach compared to disabling CageFS completely for a user. Thank you.0 -
Hi @cPanelMichael , Thank you for your suggestion. As per the document How to add java to CageFS we made the "mongo" command available to CageFS and its perfectly working from cPanel user's terminal which we wanted. Again thank you very much for your suggestion & support. Really its very appreciated. Kindly mark this thread as 'SOLVED'. Regards, Tarak Nath 0 -
Hello @Tarak Nath, I'm happy to see that helped. I've marked this thread as solved. Thanks! 0 -
We can go with the @Tarak Nath code which is very useful. 0
Please sign in to leave a comment.
Comments
11 comments