Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794
{"id":2554,"date":"2019-12-06T14:22:41","date_gmt":"2019-12-06T14:22:41","guid":{"rendered":"https:\/\/support.aklwebhost.com\/?post_type=manual_kb&p=2554"},"modified":"2019-12-27T07:17:14","modified_gmt":"2019-12-27T07:17:14","slug":"installing-nodejs-and-express-on-centos","status":"publish","type":"manual_kb","link":"https:\/\/support.aklwebhost.com\/knowledgebase\/installing-nodejs-and-express-on-centos\/","title":{"rendered":"Installing NodeJS and Express on CentOS"},"content":{"rendered":"

This tutorial will show you\u00a0how to install Node.js and Express.js on CentOS 6 (or CentOS 7)<\/strong>. You can use\u00a0Node.js to build rapid<\/strong>, scalable web apps with JavaScript.\u00a0Installation is very easy<\/strong>\u00a0– just follow the steps below. Most of the work is done for you by the\u00a0YUM package<\/strong>\u00a0manager.<\/p>\n

1. Download Node.js<\/strong><\/h3>\n

You will want to download the latest stable version of Node.js, which can be done\u00a0by running the command below<\/strong>. It runs a script that\u00a0automatically steps you through the installation process.<\/strong>\u00a0The script is downloaded directly from Joylent\u00a0(the makers of Node.js)<\/strong>\u00a0at their NodeSource repository.<\/p>\n

 cd \/tmp\r\n curl -sL https:\/\/rpm.nodesource.com\/setup | bash -\r\n<\/code><\/pre>\n

2. Install Node.js<\/strong><\/h3>\n

Once the script detects\u00a0that you do not have Node.js installed<\/strong>, enter the following command to begin the install via the yum package manager.<\/p>\n

 yum install -y nodejs\r\n<\/code><\/pre>\n

3. Install build tools (optional, but recommended)<\/strong><\/h3>\n

To compile and install native Node.js<\/strong>\u00a0addons from npm\u00a0(node package manager)<\/strong>, you will need to install these build tools.\u00a0It is not essential<\/strong>, but it will save you some\u00a0headaches<\/strong>\u00a0when doing\u00a0npm install package<\/code>\u00a0in the future.<\/p>\n

 yum install gcc-c++ openssl-devel make\r\n<\/code><\/pre>\n

4. Install Express.js<\/strong><\/h3>\n

This will\u00a0pull Express.js<\/strong>\u00a0from the repository in npm and\u00a0automatically install<\/strong>\u00a0it globally (that’s what the\u00a0-g<\/code>\u00a0is for).<\/p>\n

 npm install -g express-generator\r\n<\/code><\/pre>\n

5. Create a non-privileged user (recommended)<\/strong><\/h3>\n

For security reasons, create a regular\u00a0system user<\/strong>\u00a0and run node under that account.\u00a0This will help secure your server in the event that a vulnerability is exploited in Node.js.<\/strong><\/p>\n

 useradd username\r\n passwd username\r\n<\/code><\/pre>\n

This creates a user and\u00a0sets the password<\/strong>\u00a0for that account. Now, log back out and log back in as the new user.<\/p>\n

6. Create a project<\/strong><\/h3>\n
 express expressproject\r\n cd expressproject\r\n npm install\r\n<\/code><\/pre>\n

If all went well, you should see something similar to this:<\/strong><\/p>\n

 > expressproject@0.0.0.0 start \/exampleuser\/expressproject\r\n > node .\/bin\/www\r\n<\/code><\/pre>\n

To fully test it, launch your web-browser and type the IP address of your VPS at port 3000 in the URL bar. It should look similar to this (replace 0.0.0.0 with your VPS IP):<\/strong><\/p>\n

 http:\/\/0.0.0.0:3000\r\n<\/code><\/pre>\n

When you navigate to that URL, you will see the message\u00a0Welcome to Express<\/code>\u00a0on the page.<\/p>\n

Congratulations! You’ve now setup Node.js with Express! Go forth and create awesome things!<\/strong><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[109,231,242],"manual_kb_tag":[347],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2554"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2554"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2554\/revisions"}],"predecessor-version":[{"id":2555,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2554\/revisions\/2555"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2554"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2554"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}