zoukankan      html  css  js  c++  java
  • Centos7中源码安装Nodejs

    Step 1、确认服务器有nodejs编译及依赖相关软件,如果没有可通过运行以下命令安装。

    [root@BobServerStation local]# yum -y install gcc gcc-c++ openssl-devel


    Step 2、下载NodeJS源码包并解压。

    [root@BobServerStation local]# wget http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz

    [root@BobServerStation local]# tar zxvf node-v0.10.24.tar.gz
    [root@BobServerStation local]# cd node-v0.10.24
    Step 3、配置、编译、安装。

    [root@BobServerStation node-v0.10.24]# ./configure --prefix=/usr/local/node

    [root@BobServerStation node-v0.10.24]# make && make install
    将持续3-4min....
     
    Step 4、接下来配置Node环境

    [root@BobServerStation node-v0.10.24]# vim /etc/profile

    #set nodejs env
    export NODE_HOME=/usr/local/node
    export PATH=$NODE_HOME/bin:$PATH
    export NODE_PATH=$NODE_HOME/lib/node_modules:$PATH
     
    [root@BobServerStation node-v0.10.24]# source /etc/profile       --重启生效
     
    Step 5、测试是否安装成功

    [root@BobServerStation node-v0.10.24]# node -v

    v0.10.24

    出现NodeJS版本号则表示OK。
     
    Step 6、NodeJS之Hello World

    [root@BobServerStation node-v0.10.24]# node

    > console.log(”Hello NodeJS, I'm Bob.Z“);

    Hello NodeJS, I'm Bob.Z

    undefined

    输出:Hello NodeJS, I'm Bob.Z
     
    Step 7、安装Express开发框架

    [root@BobServerStation local]# npm install express -g

     
    Step 8、创建Demo项目

    [root@BobServerStation local]# express DemoApp

    [root@BobServerStation local]# cd DemoApp

    [root@BobServerStation DemoApp]# 

     
    Step 9、进入项目目录并安装项目依赖组件

    [root@BobServerStation local]# cd DemoApp

    [root@BobServerStation DemoApp]# npm install

     
    Step 10、依赖组件安装完成后启动app

    [root@BobServerStation DemoApp]# node app

    Express server listening on port 3000

     
    最后通过浏览器访问服务器3000端口,页面显示,

    Express

    Welcome to Express

  • 相关阅读:
    Winform—C#读写config配置文件
    C# 中Web.config文件的读取与写入
    Redis配置文件详解
    三层架构之泛型抽象
    Linq To Sql语法及实例大全
    junit单元测试(keeps the bar green to keeps the code clean)
    观 GT Java语言管理系统的感悟
    java考核完的心得
    15个C++项目列表
    C++文件操作(fstream)
  • 原文地址:https://www.cnblogs.com/xxsl/p/6124064.html
Copyright © 2011-2022 走看看