markdown 01.初始服务器设置数字海洋

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 01.初始服务器设置数字海洋相关的知识,希望对你有一定的参考价值。

# Inicial Setup

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04

# Connect SSH

`ssh root@SERVER_IP_ADDRESS`

https://www.digitalocean.com/community/tutorials/how-to-connect-to-your-droplet-with-ssh?utm_source=Customerio&utm_medium=Email_Internal&utm_campaign=Email_UbuntuDistroNginxWelcome&mkt_tok=eyJpIjoiTlRCaU1HVTFPV1ZoTURObCIsInQiOiJvXC9NNUhmM1BYUFd4QjlsYUw2R0hGYnJJNDg5akZMK0dUN1U0YmFjMVVvTldOVEFFUk5OTTg1clJJOXlsbURlVmY3NUhGU2p1Sk1md2ZUSkxcL25zTHY5Rm54a09hOE5tQnFNZVVWY3VFWHF2OHdrdkd4XC9CTDVwQUdZc0pzTTZaRSJ9

# Update Ubuntu 

```
sudo apt-get update && sudo apt-get upgrade -y

apt-get install
```

# Upgrade Ubuntu

```
apt list --upgradable -a

apt update

apt upgrade
```

# Install Node v.9.x

```
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
```

https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

# Install Nginx

```
sudo apt-get update
sudo apt-get install -y nginx
```

Now test your serve by accessing your server's ip adress on Google Chrome.

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04

# Install Mongo DB v.3.6

```
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

sudo apt-get update

sudo apt-get install -y mongodb-org

```

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

# Configure MongoDB

`sudo nano /etc/systemd/system/mongodb.service`

Paste this code
```
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target
```
Inicia o MongoDB

`sudo systemctl start mongodb`

Checa o Status do MongoDB

`sudo systemctl status mongodb`

Configura para o MongoDB iniciar automaticamente

`sudo systemctl enable mongodb`

https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04

# Config Remote Access to MongoDb

Set the permission that enables mongo to be accessed through this user@serverIP 

```
mongo
ssh -L 4321:localhost:27017 user@your.ip.address -f -N
mongo --port 4321
```

Edit your `/etc/mongod.conf` configuration

Replace

`bindIp: 127.0.0.1`

For

`bindIpAll: true`

> This will enable acces at IPv4 and IPv6

Reboot your server

`reboot`

> Don't forget to change your DB address at the backEnd
`'mongodb://your.ip.address/your.db.name'`

Try access with [MongoDB Compass](https://www.mongodb.com/download-center?filter=enterprise#compass)

https://www.digitalocean.com/community/tutorials/how-to-use-the-mongodb-one-click-application

# Install PM2

`sudo npm install -g pm2`

Navigate util your folder and run

`pm2 startup upstart`

`pm2 save`

## Check Versions Installed

```
node -v

nginx -v

mongo --version

pm2 -v
```

## Extra

`service --status-all`

以上是关于markdown 01.初始服务器设置数字海洋的主要内容,如果未能解决你的问题,请参考以下文章

markdown 03.初始NGINX服务器设置数字海洋

markdown 设置一个新的数字海洋 - OpenLiteSpeed Wordpress Droplet

markdown Django部署 - 数字海洋

markdown Ubuntu部署数字海洋

markdown 数字海洋促销优惠券代码

markdown 数字海洋访问和操作