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.
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:
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:
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:
Please note, you need to replace 184.108.40.206 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 CentOS Optimized 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.