Node Service Terminal--nvmhome

Source: Internet
Author: User
Tags node server ssh port

> This article is designed to give you the speed to build node server (any project)

```
$ whoami
Name:kelvin
Email: [Email protected]
Homepage:www.kelvv.com
Github:https://github.com/kelvv
```
****
This article uses Docker to build a pre-installed:
* PM2--node app's process Manager
* Git--code management
* SSH--Telnet
* NVM--node version management
* NPM--node package installation
* Node--so,you know

* * This item github:[here] (https://github.com/kelvv/nvmhome-docker) * *, Welcome to start

**>, of course, can use the image directly: * *
```
$ Docker Pull Kelvv/nvmhome-docker
```

****

The project consists of a dockerfile and. BASHRC:
```
#Dockerfile

From ubuntu:14.04

RUN apt-get Update
#安装git SSH
RUN apt-get install-y Curl Git-all openssh-server
ADD. BASHRC/ROOT/.BASHRC

#nvm安装
RUN curl-o-https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | Bash
RUN. /ROOT/.BASHRC;NVM Install 4.3.1;NVM use 4.3.1;NPM install PM2-G;PM2 startup ubuntu

RUN mkdir/var/run/sshd
RUN echo ' Root:myssh ' | chpasswd
RUN sed-i ' s/permitrootlogin without-password/permitrootlogin yes/'/etc/ssh/sshd_config

# SSH Login
RUN sed ' [email protected]\s*required\s*[email protected] optional [email protected] '-i/etc/pam.d/sshd

ENV notvisible "in Users Profiles"
RUN echo "Export Visible=now" >>/etc/profile

#对外开放端口
EXPOSE 22
EXPOSE 80

#启动ssh服务
CMD ["/usr/sbin/sshd", "-D"]
```

The above gives a simple comment, the following supplementary explanation
1. Why does Add. BASHRC/ROOT/.BASHRC need to add. bashrc? The PM2 environment variable takes effect because it removes the * * interaction.
2. The default SSH password is: ' Myssh ', if necessary, self-added SSH non-secret login, I have articles on the technology: [Portal] (http://www.jianshu.com/p/27d8b8d1d571)
3. The image is open to two ports,
* **22:SSH Port * *
* **80: Default Web Port * *
4. You can continue to write the dockerfile that belongs to your application based on the dockerfile. Happy Node

# #使用

* Use this image
Connect to the server and execute the following command
```
$ Docker Pull Kelvv/nvmhome-docker
$ docker run-p 0.0.0.0:3000:22-p 0.0.0.0:80:80-d Kelvv/nvmhome-docker
```
You can go back to your computer and use SSH [email protected] to connect to the app server you just created and play it free.

* Improvements to the image that need to be rebuilt
Connect to the server, download Dockerfile, modify and execute the following command
```
$ docker build-t name.
$ docker run-p 0.0.0.0:3000:22-p 0.0.0.0:80:80-d name
```

# #总结

The above has established a good foundation, the next article will say: How to use NVMHOME+PM2, a key to publish, manage their own applications, is a very simple personal homepage, I hope you like!

This is how my personal homepage is deployed: [Homepage Portal] (http://www.kelvv.com/)

Node Service Terminal--nvmhome

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.