centosyumnodejs的簡單介紹

本文目錄一覽:

如何在CentOS 7服務器上安裝NodeJS

Introduction

Node.js is a Javascript platform for server-side programming. It

allows users to easily create networked applications that require

backend functionality. By using Javascript as both the client and server

language, development can be fast and consistent.

In this guide, we will show you a few different ways of getting

Node.js installed on a CentOS 7 server so that you can get started. Most

users will want to use the EPEL installation instructions or the NVM

installation steps.

Install Node from Source

One way of acquiring Node.js is to obtain the source code and compile it yourself.

To do so, you should grab the source code from the project』s website.

On the downloads page, right click on the 「Source Code」 link and click

「Copy link address」 or whatever similar option your browser gives you.

On your server, use wget and paste the link that you copied in order to download the archive file:

wget

Extract the archive and move into the new directory by typing:

tar xzvf node-v* cd node-v*

There are a few packages that we need to download from the CentOS

repositories in order to compile the code. Use yum to get these now:

sudo yum install gcc gcc-c++

Now, we can configure and compile the software:

./configure

make

The compilation will take quite awhile. When it is finished, you can install the software onto your system by typing:

sudo make install

To check that the installation was successful, you can ask Node to display its version number:

node –version

v0.10.30

If you see the version number, then the installation was completed successfully.

Install a Package from the Node Site

Another option for installing Node.js on your server is to simply get

the pre-built packages from the Node.js website and install them.

You can find the Linux binary packages here. Since CentOS 7 only

comes in the 64-bit architecture, right click on the link under 「Linux

Binaries (.tar.gz)」 labeled 「64-bit」. Select 「Copy link address」 or

whatever similar option your browser provides.

On your server, change to your home directory and use the wget

utility to download the files. Paste the URL you just copied as the

argument for the command:

cd ~

wget

Note: Your version number in the URL is likely to be different than

the one above. Use the address you copied from the Node.js site rather

than the specific URL provided in this guide.

Next, we will extract the binary package into our system』s local

package hierarchy with the tar command. The archive is packaged within a

versioned directory, which we can get rid of by passing the

–strip-components 1 option. We will specify the target directory of our

command with the -C command:

sudo tar –strip-components 1 -xzvf node-v* -C /usr/local

This will install all of the components within the /usr/local branch of your system.

You can verify that the installation was successful by asking Node for its version number:

node –version

v0.10.30

The installation was successful and you can now begin using Node.js on your CentOS 7 server.

Install Node from the EPEL Repository

An alternative installation method uses the EPEL (Extra Packages for

Enterprise Linux) repository that is available for CentOS and related

distributions.

To gain access to the EPEL repo, you must modify the repo-list of

your installation. Fortunately, we can reconfigure access to this

repository by installing a package available in our current repos called

epel-release.

sudo yum install epel-release

Now that you have access to the EPEL repository, you can install Node.js using your regular yum commands:

sudo yum install nodejs

Once again, you can check that the installation was successful by asking Node to return its version number:

node –version

v0.10.30

Many people will also want access to npm to manage their Node packages. You can also get this from EPEL by typing:

sudo yum install npm

Install Node Using the Node Version Manager

Another way of installing Node.js that is particularly flexible is

through NVM, the Node version manager. This piece of software allows you

to install and maintain many different independent versions of Node.js,

and their associated Node packages, at the same time.

To install NVM on your CentOS 7 machine, visit the project』s GitHub

page. Copy the curl or wget command from the README file that displays

on the main page. This will point you towards the most recent version of

the installation script.

Before piping the command through to bash, it is always a good idea

to audit the script to make sure it isn』t doing anything you don』t agree

with. You can do that by removing the | bash segment at the end of the

curl command:

curl https//raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh

Take a look and make sure you are comfortable with the changes it is

making. When you are satisfied, run the command again with | bash

appended at the end. The URL you use will change depending on the latest

version of NVM, but as of right now, the script can be downloaded and

executed by typing:

curl | bash

This will install the nvm script to your user account. To use it, you must first source your .bash_profile:

source ~/.bash_profile

Now, you can ask NVM which versions of Node it knows about:

nvm list-remote

. . .

v0.10.29

v0.10.30

v0.11.0

v0.11.1

v0.11.2

v0.11.3

v0.11.4

v0.11.5

v0.11.6

v0.11.7

v0.11.8

v0.11.9

v0.11.10

v0.11.11

v0.11.12

v0.11.13

You can install a version of Node by typing any of the releases you see. For instance, to get version 0.10.30, you can type:

nvm install v0.10.30

You can see the different versions you have installed by typing:

nvm list

– v0.10.30

system

You can switch between them by typing:

nvm use v0.10.30

Now using node v0.10.30

To set this version as the default, type:

nvm alias default v0.10.30

default – v0.10.30

You can verify that the install was successful using the same technique from the other sections, by typing:

node –version

v0.10.30

From the version number output, we can tell that Node is installed on our machine as we expected.

Conclusion

As you can see, there are quite a few different ways of getting

Node.js up and running on your CentOS 7 server. If one of the

installation methods is giving you problems, try one of the other

options.

如何在centos下部署Node環境

你可以通過運行以下命令。 sudo yum install epel-release現在可以使用yum命令安裝Node.js了。 sudo yum install nodejs因為在開發過程中我需要管理節點包,我還要安裝新公共管理的軟件包管理器,使用以下命令。 sudo yum install npm

node.js怎麼安裝node modules

1、首先,在CentOS上使用命令yum install nodejs可以直接安裝,但是這樣可能無法安裝最新版本。

2、安裝好之後,可以使用node -v命令和npm -v命令查看Node.js的版本和包管理器的版本。

3、接着可以使用yum uninstall nodejs卸載舊版本的nodejs。同時也會自動卸載npm。

4、接着,再次使用yum install命令安裝nodejs,這時候安裝的就是新版本了。

5、安裝完畢後,使用npm -v查看包管理器版本,也是新版本。

6、如果只是要運行node.js,直接node回車即可。在裡邊輸入javascript代碼。

如何在CentOS / RHEL 7/6/5上安裝最新的Nodejs和NPM

1、如果對nodejs環境有比較高的要求,建議選擇源碼安裝的方式進行安裝。

你可以到nodejs org官網上面找到相對的tar.gz文件包。

通過wget命令下載到centos服務器上, 然後進行源碼安裝。

2、如果對版本要求不高,可以直接用centos的包管理器yum進行安裝

yum install nodejs npm

3、nodejs版本也可以通過nvm等工具去控制,期待深入研究。

學習Linux運維的知識,可以參考《Linux就該這麼學》

原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/312804.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
小藍的頭像小藍
上一篇 2025-01-06 15:17
下一篇 2025-01-06 15:17

相關推薦

  • Python簡單數學計算

    本文將從多個方面介紹Python的簡單數學計算,包括基礎運算符、函數、庫以及實際應用場景。 一、基礎運算符 Python提供了基礎的算術運算符,包括加(+)、減(-)、乘(*)、除…

    編程 2025-04-29
  • Python滿天星代碼:讓編程變得更加簡單

    本文將從多個方面詳細闡述Python滿天星代碼,為大家介紹它的優點以及如何在編程中使用。無論是剛剛接觸編程還是資深程序員,都能從中獲得一定的收穫。 一、簡介 Python滿天星代碼…

    編程 2025-04-29
  • Python海龜代碼簡單畫圖

    本文將介紹如何使用Python的海龜庫進行簡單畫圖,並提供相關示例代碼。 一、基礎用法 使用Python的海龜庫,我們可以控制一個小海龜在窗口中移動,並利用它的「畫筆」在窗口中繪製…

    編程 2025-04-29
  • Python櫻花樹代碼簡單

    本文將對Python櫻花樹代碼進行詳細的闡述和講解,幫助讀者更好地理解該代碼的實現方法。 一、簡介 櫻花樹是一種圖形效果,它的實現方法比較簡單。Python中可以通過turtle這…

    編程 2025-04-28
  • Python大神作品:讓編程變得更加簡單

    Python作為一種高級的解釋性編程語言,一直被廣泛地運用於各個領域,從Web開發、遊戲開發到人工智能,Python都扮演着重要的角色。Python的代碼簡潔明了,易於閱讀和維護,…

    編程 2025-04-28
  • 用Python實現簡單爬蟲程序

    在當今時代,互聯網上的信息量是爆炸式增長的,其中很多信息可以被利用。對於數據分析、數據挖掘或者其他一些需要大量數據的任務,我們可以使用爬蟲技術從各個網站獲取需要的信息。而Pytho…

    編程 2025-04-28
  • 如何製作一個簡單的換裝遊戲

    本文將從以下幾個方面,為大家介紹如何製作一個簡單的換裝遊戲: 1. 遊戲需求和界面設計 2. 使用HTML、CSS和JavaScript開發遊戲 3. 實現遊戲的基本功能:拖拽交互…

    編程 2025-04-27
  • Guava Limiter——限流器的簡單易用

    本文將從多個維度對Guava Limiter進行詳細闡述,介紹其定義、使用方法、工作原理和案例應用等方面,並給出完整的代碼示例,希望能夠幫助讀者更好地了解和使用該庫。 一、定義 G…

    編程 2025-04-27
  • 2的32次方-1:一個看似簡單卻又複雜的數字

    對於計算機領域的人來說,2的32次方-1(也就是十進制下的4294967295)這個數字並不陌生。它經常被用來表示IPv4地址或者無符號32位整數的最大值。但實際上,這個數字卻包含…

    編程 2025-04-27
  • 製作一個簡單的管理系統的成本及實現

    想要製作一個簡單的管理系統,需要進行技術選型、開發、測試等過程,那麼這個過程會花費多少錢呢?我們將從多個方面來闡述製作一個簡單的管理系統的成本及實現。 一、技術選型 當我們開始思考…

    編程 2025-04-27

發表回復

登錄後才能評論