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

  • 相关阅读:
    easyui 后台系统引入富文本编辑器的使用
    easyui datagrid 表格动态隐藏部分列的展示
    java ArrayList源码分析(转载)
    propertychange方法
    CSS margin-top 属性
    easyui-textbox input输入框的一种取值方式
    jquery next()方法
    jquery children()方法
    一段简单的表格样式
    常用的排序算法的时间复杂度和空间复杂度
  • 原文地址:https://www.cnblogs.com/xxsl/p/6124064.html
Copyright © 2011-2022 走看看