Installing NodeJS, Grunt, and Bower with cPanel and CentOS or CloudLinux

NodeJS is a powerful platform built on Chrome's Javascript Runtime that can be used to build fast and scalable web applications (https://www.nodejs.org/).  

We recently wanted to start working more closely with Bootstrap and LESS code on cPanel based web servers.  For this the "grunt" tool is recommended.  With CloudLinux things needed additional configuration to work with CageFS.  I hope this helps someone wanting to use Bootstrap with cPanel and CentOS or CloudLinux.  Enjoy!

To install NodeJS, Grunt, and Bower on CloudLinux

1.  Login to your server as root

2.  Create a a directory and move into it:
mkdir ~/nodejs-install; cd ~/nodejs-install

3.  Copy the install files. These install the repository that is currently maintained for the rpms  

git clone https://github.com/nodesource/distributions.git

4.  Move to rpm install folder and run the setup  

cd distributions/rpm; sh setup

5.  Install nodejs

yum install nodejs

6.  Install grunt and bower

npm install -g grunt-cli; npm install -g bower

 At this point if you are not using CageFS with CloudLinux you are done. Your nodejs, grunt, and bower commands should all work in the shell.  If you are using CageFS please follow the additional instructions.

Configuring NodeJS, Grunt, and Bower for CageFS

7.  Configure cagefs for nodejs

touch /etc/cagefs/conf.d/nodejs.cfg

Using your favorite editor copy the following into the nodejs.cfg file:

[nodejs]
comment=Nodejs
paths=/usr/bin/node, /usr/bin/npm, /usr/lib/node_modules/npm

8.  Configure cagefs for grunt.  

touch /etc/cagefs/conf.d/grunt.cfg

Using your favorite editor copy the following into the grunt.cfg file:

[grunt]
comment=Grunt tools
paths=/usr/bin/grunt, /usr/local/bin/grunt, /usr/lib/node_modules/grunt-cli 

9.  Configure cagefs for bower.

touch /etc/cagefs/conf.d/bower.cfg

Using your favorite editor copy the following into the bower.cfg file:

[bower]
comment=Bower web tools
paths=/usr/bin/bower, /usr/local/bin/bower, /usr/lib/node_modules/bower

10.  Now re-initialize cagefs.

cagefsctl --force-update

11.  Your nodejs, grunt, and bower commands should be available on cPanel accounts.

 

Blogs: 
Technical

你可能感兴趣的:(Installing NodeJS, Grunt, and Bower with cPanel and CentOS or CloudLinux)