coc*_*cco 2 ssh ubuntu samba node.js
我发现了一台旧PC,我想将它用作专用的Node.js测试机.
基本上我想在win机器上编写我的应用程序然后将它们通过samba复制到节点文件夹并通过ssh启动它们.稍后,我将添加一个upstart脚本并将其与samba一起复制到服务器,这样当我重新启动时,应用程序每次都会自动启动.
sudo apt-get install nodejs npm
.编辑
经过一些测试后,我现在处于一个好点,这就是我所做的:
3 - 更新系统
sudo apt-get update && sudo apt-get upgrade
Run Code Online (Sandbox Code Playgroud)
4-依赖关系
sudo apt-get install g++ curl libssl-dev apache2-utils git-core make
Run Code Online (Sandbox Code Playgroud)
5安装节点
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
Run Code Online (Sandbox Code Playgroud)
6-setup samba sudo nano /etc/samba/smb.conf
[nodejs]
comment = nodejs
workgroup = WG
security = USER
path = /var/nodejs
server string =Node JS
browsable = yes
read only = no
writeable = yes
create mask = 0777
Run Code Online (Sandbox Code Playgroud)
7- testApp.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.js\n');
}).listen(80, "192.168.0.1");
console.log('Server running at http://192.168.0.1:80/');
Run Code Online (Sandbox Code Playgroud)
8-现在一切都应该运行......但是:
您可以仅在管理员在启动命令前添加"sudo"时运行nodejs,否则作为普通用户,您无法访问1000以下的大多数端口.
A.如何在不使用sudo的情况下在端口80上启用我的应用程序?
很明显,如果你启动应用程序,command sudo node /var/nodejs/testApp.js
如果你关闭终端,应用程序将停止.
为此,我们使用init脚本.
经过一番阅读后,我发现upstart本身安装在ubuntu服务器中,这可能是启动应用程序的最佳方式.
B.我知道你需要把你的appname和.conf扩展名放到/ etc/init /中.但是这怎么办?
ver*_*loc 13
我需要安装什么来在我的网络上在专用的ubuntu服务器上正确运行node.js应用程序?
您只需要安装nodejs.nodejs可以在任何端口上运行,因此您不需要Apache或其他任何东西.
如何在ubuntu服务器上安装最新的nodejs,npm和init文件
请尝试按照本指南中列出的步骤操作:http://howtonode.org/how-to-install-nodejs.使用Ubuntu的说明.
当我重新启动应用程序每次自动启动
一种方法是编写一个将在引导时运行的小脚本.该脚本将包含以下指令:
nodejs /path/to/app/app.js
Run Code Online (Sandbox Code Playgroud)
查看有关如何在启动时运行脚本的SO答案:https://stackoverflow.com/questions/3036/files-and-scripts-that-execute-on-boot
归档时间: |
|
查看次数: |
11511 次 |
最近记录: |