How to install ExpressJS on a CentOS VPS


express_jsExpress is a NodeJS web application framework. It provides robust set of features and can be used for building single-page, multi-page as well as hybrid web-based applications. Express is a part of the MEAN stack backend. Today we will show you how to install Express on a Linux VPS and create a sample project.

First of all, you need to connect to your server via SSH and upgrade all your system software to the latest version available by executing the following command:

yum -y update

Since we are going to install NodeJS from source, you will need to install all the required dependencies on your server. For that purpose you can use the following command:

yum -y groupinstall "Development Tools"

Next, go ahead and download the latest stable release of NodeJS from https://nodejs.org/download/. We are going to download node-v0.12.7.

wget https://nodejs.org/download/release/latest-v0.12.x/node-v0.12.7.tar.gz

Once NodeJS is downloaded on your CentOS VPS, you can move on to the next step. To extract the archive and install NodeJS from source execute the following commands one by one:

tar -xzvf node-v0.12.7.tar.gz
cd node-v0.12.7
./configure
make
make install

The installation of NodeJS could take a few minutes. After the installation is completed, you can continue and install Express. Run the following command:

npm install -g express express-generator

Once you are done, create a new system user.

useradd expressuser
passwd expressuser

Log out from your system and log in again using the newly created system user.

To ensure that you are logged as the newly created system user you can run the command:

whoami

Create a directory for your first Express project and navigate to that directory:

mkdir first_project
cd first_project/

To set up your first project, run the following command:

express

And then:

npm install

The last thing you need to do is to start your application and access it using a web browser. For that purpose, you can execute the following command:

node ./bin/www &

Congratulations, you have successfully set up your first Express application. By default, your Express application should listen on port 3000. Therefore, open your favorite web browser and navigate to:

http://111.111.111.111:3000

Please note, you need to replace 111.111.111.111 with the actual IP address of your CentOS VPS. If you are not sure what the IP address of your server is, you can execute the following command to find it out:

ip addr show

A good way to start using Express is to visit the official web site at http://expressjs.com/. There you can find more information about how to use this NodeJS web application framework to build single-page, multi-page or hybrid web applications.

Of course you don’t have to do any of this if you use one of our Linux VPS hosting services, in which case you can simply ask our expert Linux admins to install NodeJS and Express for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Tutorials
Install GrandCMS on an Ubuntu VPS
Tutorials
How to easily secure and protect your WordPress website
Tutorials
How to install and configure dkim with OpenDKIM and Exim on a CentOS 7 VPS
There are currently no comments.