pm2命令,端口查询,mongodb服务启动,nginx服务启动,n模块的使用,搭建nodejs服务器环境,搭建oracledb服务器环境 linux的环境搭建

pm2命令

pm2 ls //查询pm2 启动的列表
pm2 start app.js //启动文件
pm2 restart app //重启项目
pm2 logs app //监控项目执行日志打印
pm2 stop app //停止项目执行
pm2 flush //清除日志
pm2 flush && pm2 restart app && pm2 logs app

端口查询

netstat -tunlp // 用于查看端口号的进程情况
netstat -tunlp |grep 80 查看80端口的情况

mongodb服务启动

1.先无权限启动数据库                   /usr/local/mongodb/bin/mongod   --dbpath=/data/db --fork --logpath=/data/db/mongodb.log
 2.进入数据库                           use admin
 3.创建角色                             db.createRole({role:'sysadmin',roles:[],privileges:[{resource:{anyResource:true},actions:['anyAction']}]})
 4.在admin中创建超级管理员              db.createUser({user:'admin',pwd:'password123',roles:[{role:'sysadmin',db:'admin'}]})
 5.在主数据库下关闭数据库               db.shutdownServer();
 6.有权限启动数据库                     /usr/local/mongodb/bin/mongod  --auth --dbpath=/data/db --fork --logpath=/data/db/mongodb.log
                                        /usr/local/mongodb/bin/mongod --auth --dbpath=/data/db --fork --logpath=/data/db/mongodb.log --storageEngine wiredTiger --journal --maxConns=50000 --bind_ip 0.0.0.0

 创建数据集合                           use newdb
 创建普通管理员                         db.createUser({user:'userName',pwd:'password123',roles:[{role:'readWrite',db:'admin'}]});
 登陆数据集合                           db.auth("userName","password123");

把指定的数据库备份到指定目录            ./mongodump -u lzt -p dgxkkg -h 127.0.0.1:27017 -d lwx -o /data/dump

nginx服务启动

启动服务:   /usr/local/nginx/sbin/nginx
重启服务:   /usr/local/nginx/sbin/nginx  -s  reload
停止服务:   /usr/local/nginx/sbin/nginx  -s  stop
编辑配置:   vi  /usr/local/nginx/conf/nginx.conf
查看配置:   cat  /usr/local/nginx/conf/nginx.conf

按键 i 进入编辑模式
完成编辑后,先按 Esc 键 然后同时按 Shift 和 :号键 然后 wq 保存(w 写入 q 推出) (q!立即退出)


proxy_pass   设置动态文件端口,唯一           //http://127.0.0.1:8080;

#开发版
server{
    listen 80;                                    #统一用 80 端口
    server_name dev.abcde.cn;                     #这里配置二级域名
    client_max_body_size 100M;
    charset utf-8;
    location ~* ^.+.(html)$ {
    proxy_pass http://127.0.0.1:8888;            #这里指向代码中监听的端口
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location ~* ^.+.(htm|js|css|ico|gif|bmp|jpg|jpeg|png|swf|apk|xls|xlsx|woff|ttf|eot|otf|svg|json|manifest|mp3|apk)$ {
        root   /website/dev/web;                  #这里指向开发版文件夹
        access_log off;
        expires 8h;
    }
    location /{
    proxy_pass http://127.0.0.1:8888;           #这里指向代码中监听的端口
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    client_max_body_size 100M;
  }
}

n模块的使用 

nodejs的版本管理,几个命令就可以完成nodejs的升级操作。仅仅只有下面几个简单的步骤就可以完成:
1、首先安装n模块别看它名字很短,用途却很大,可以用短小精悍来形容。n模块是专门用来管理nodejs版本的。这里需要全局安装,命令如:npm install -g n
2、升级node.js到最新稳定版命令如:n stable
没错,就这么简单!!!当然,也可以利用它升级到指定版本。比如:n v0.12.2

搭建nodejs服务器环境

1:yum update
2:yum -y install gcc gcc-c++ openssl-devel zlib-devel openssl-devel pcre-devel bzip2* make

3:下载安装nginx  nginx-1.10.2
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar -zxvf nginx-1.10.2.tar.gz && cd nginx-1.14.0 && ./configure  && make && make install
wget https://www.openssl.org/source/openssl-1.0.2o.tar.gz
tar -zxvf /openssl-1.0.2o.tar.gz && cd /openssl-1.0.2o && ./configure  && make && make install

4:安装node.js
wget http://nodejs.org/dist/v10.13.0/node-v10.13.0.tar.gz
tar -zxvf node-v10.13.0.tar.gz && cd node-v10.13.0 && ./configure && make && make install


5:安装mongodb
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.3.tgz
tar -zxvf mongodb-linux-x86_64-3.2.3.tgz&&mv mongodb-linux-x86_64-3.2.3 /usr/local/mongodb
设置数据文件路径,建立/data/db的目录,
mkdir –p /data/db


6:安装GraphicsMagick(图片处理) 安装前需要先安装    yum install libjpeg* libpng*
wget http://jaist.dl.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.20/GraphicsMagick-1.3.20.tar.gz
tar -zxvf GraphicsMagick-1.3.20.tar.gz && cd GraphicsMagick-1.3.20 && ./configure && make && make install


7安装redis
wget http://download.redis.io/releases/redis-3.2.3.tar.gz
tar -zxvf redis-3.2.3.tar.gz && cd redis-3.2.3 && make PREFIX=/usr/local/redis/ install && make install

下面步骤按顺序执行
cd /usr/local/redis
mkdir etc logs var db  //这里直接同时mkdir 四个文件夹
cp /soft/redis-3.2.3/redis.conf etc
cp /soft/redis-2.8.19/redis.conf etc

启动服务:
nohup /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf &
执行后提示  nohup: ignoring input and appending output to ‘nohup.out’
回车 用ps aux 查看 /usr/local/redis/bin/redis-server 127.0.0.1:6379 是否存在


进入website文件,在里面安装
npm install formidable@latest        安装node.js后可安装
npm install redis                    需要安装redis后再安装
npm install mongodb                  需要安装mongodb后再安装
npm install gm                       需要安装GraphicsMagick后再安装
npm install q
npm install  iconv-lite




ps aux  查询全部进程
kill 进程编码
============
-9 是最大权限 尽量少用,容易引起数据不稳定
kill -9 进程编码
=========

搭建oracledb服务器环境

yum install libaio*
yum -y install gcc gcc-c++
http://ahk2016.oss-cn-shenzhen.aliyuncs.com/docker/instantclient-basic-linux.x64-12.2.0.1.0.zip  下载到/soft
http://ahk2016.oss-cn-shenzhen.aliyuncs.com/docker/instantclient-sdk-linux.x64-12.2.0.1.0.zip     同上

unzip instantclient-basic-linux.x64-12.2.0.1.0.zip
unzip instantclient-sdk-linux.x64-12.2.0.1.0.zip
mv instantclient_12_2 instantclient
cd instantclient
ln -s libclntsh.so.12.1 libclntsh.so
# 设置环境变量
vi /etc/profile
#编辑添加内容如下

export LD_LIBRARY_PATH=/soft/instantclient:$LD_LIBRARY_PATH
export OCI_LIB_DIR=/soft/instantclient
export OCI_INC_DIR=/soft/instantclient/sdk/include

#保存退出

#重启用profile文件
source /etc/profile
2.4 安装oracledb
  之前安装都已经完成了,这一步会非常简单。
 npm install oracledb
原文地址:https://www.cnblogs.com/caiyt/p/10118630.html