We’ll show you, how to install ExpressJS on CentOS. Express 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, running CentOS as an operating system, and create a sample project.
Table of Contents
1. Update the system
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
2. Install required dependencies
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"
3. Download Node.js
Next, go ahead and download the latest stable release of NodeJS. We are going to download node-v0.12.7.
4. Extract the archive and install Node.js
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
5. Install Express.js
The installation of NodeJS could take a few minutes. After the installation is completed, you can continue and install Express.js. Run the following command:
npm install -g express express-generator
6. Create new system user and log in
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/
7. Set up your first project
To set up your first project, run the following command:
Now just $43 .99
8. Start your application
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 220.127.116.11 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 Express website. 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 install Express.js on CentOS if you use one of our CentOS Optimized VPS hosting services, in which case you can simply ask our expert Linux admins to install Node.js and Express.js for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post, on how to install Express.js on CentOS, please share it with your friends on social networks or simply leave a reply below. Thanks.