跳至主要内容

在Vultr的CentOS系统安装NodeJS和Express

最近迷上了基于MEAN的开发,加上寒假在给邱小姐做HTML+CSS+JS的培训,小朋友强烈要求弄一台服务器,使她的学习成果可以在公网上展示给小伙伴们看。想到恰好在Vultr上有一台空余的服务器,于是趁春节前的空闲部署了CentOS并搭建一台测试的Web服务器。不想花太多时间教小朋友后端编程语言,所以打了JavaScript的主意,准备前后端处理都用JS搞掂,所以决定用Express+NodeJS来做Web服务器。

在Vultr上安装NodeJS和Express异常简单,基本上用Yum管理器就可以傻瓜式安装完。

1.下载最新版的Node.js

切换到临时目录,用curl从Joylent直接下载最新版本的Node.js.

cd /tmp 

curl -sL https://rpm.nodesource.com/setup | bash -

如下图所示:

Download latest Node.js

2. 安装Node.js

按照提示用yum安装Node.js.

yum install -y nodejs

Install Node.js

3.安装NPM包管理工具(可选)

如果你以后想安装Node的addon包,建议安装NPM包管理工具。运行命令:

yum install gcc-c++ openssl-devel make

Install build toolsInstall build tools
4.更新NPM工具(可选)
如果运行NPM时提示NPM版本低,可以选择更新NPM,按提示运行命令:

npm -g install npm@latest-2

Update NPM tool
5.安装Express

用NPM从仓库中安装Express

npm install -g express-generator

Install Express
6.创建运行服务的非特权用户(建设)

useradd 用户名 
passwd 用户名

创建后登出系统并用新建的用户名重新登录。

7.创建Express项目

express expressproject 
cd expressproject 
npm install

 Create Express Project
8.运行Express

运行Express,启动服务。

DEBUG=expressproject:* npm start

如果一切正常,会出现以下提示

[highlight dark="no"]
> expressproject@0.0.0 start /home/用户名/expressproject
> node ./bin/www
[/highlight]
 
Start Express

至此,你可用[highlight dark="no"]http://IP:3000[/highlight]访问到你的Web服务了,Node.js+Express的环境搭建完成了。

Run Express

评论

此博客中的热门博文

Installing RHEL EPEL Repo on Centos 5.x or 6.x

习惯了用yum来安装东西,试了下这篇文章提到的做法workable,再做一次搬运工。 原文出处: http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x Authored by: Rackspace Support How to install RHEL EPEL repository on Centos 5.x or 6.x The following article will describe how to configure a CentOS 5.x-based or Centos 6.x-based system to use Fedora Epel repos and third party remi package repos. These package repositories are not officially supported by CentOS, but they provide much more current versions of popular applications like PHP or MYSQL. Install the extra repositories The first step requires downloading some RPM files that contain the additional YUM repository definitions. The instructions below point to the 64-bit versions that work with our Cloud Server instances. Centos 5.x wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm sudo rpm -Uvh remi-release-5*.rpm epel...

64位OEL 6安装Oracle RCU报“libXext.so.6: cannot open shared object file: No such file or directory”的解决方法

在64位的Oracle Enterprise Linux 6上时报“ libXext.so.6: cannot open shared object file: No such file or directory ”的错误,已经装了64位x11相关的包,可见是缺少32位的包引起的。 1.libXext.so.6错误信息如下: 无法使用位置 /home/ecm/oinstall/rcuHome/rcu/log/logdir.2011-12-26_09-54/rcu.log 初始化日志记录程序 使用以下位置初始化日志记录程序: /tmp/logdir.2011-12-26_09-54/rcu.log Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/ecm/oinstall/rcuHome/jdk/jre/lib/i386/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory     at java.lang.ClassLoader$NativeLibrary.load(Native Method)     at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1806)     at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1702)     at java.lang.Runtime.load0(Runtime.java:770)     at java.lang.System.load(System.java:1003)     at java.lang.ClassLoader$NativeLibrary.load(Native Method)     at java.lang.ClassLoader.loadLibrar...

How to Convert a VMware Pre-allocated Virtual Disk to a Growable Virtual Disk

受不了动辄几百G的虚机,记给自己看,只是在网络上搬运,来源在这里: http://www.virtuatopia.com/index.php/How_to_Convert_a_VMware_Pre-allocated_Virtual_Disk_to_a_Growable_Virtual_Disk 。 he vmware-vdiskmanager tool The VMware Disk Management Tool is a command line tool which is installed by default with VMware Server. The executable file is named   vmware-vdiskmanager   and is located in   \Program Files\VMware\VMware Server   on Windows hosts, and   /usr/bin   on Linux systems. The tool accepts a number of command-line arguments, a full listing of which can be obtained by running vmware-vdiskmanager with no options. vmware-vdiskmanager Virtual Disk Types The type to which a virtual disk is to be converted is specified using the -t flag, together with the target disk type. This is represented by a number as outlined in the following table: Type Identifier Description 0 Growable (single .vmdk file) 1 Growable (multiple 2GB files) 2 Pre-allocated (single file) 3 Pre...