安装nodeJS

先到官网下载压缩包,上传到服务器上

nodeJs下载地址

安装nodeJs - 图1

解压缩,使用node

  1. #解压缩到 /usr/local/
  2. tar xf node-v12.10.1-linux-x64.tar.gz -C /usr/local/
  3. # 进入文件夹后 ll 然后发现多一个node-v12.10.1-linux-x64文件 bin目录下是node可执行文件
  4. cd /usr/local/
  5. #建立全局映射 可全局使用node npm 命令
  6. ln -s /usr/local/node-v12.10.1-linux-x64/bin/node /usr/local/bin
  7. ln -s /usr/local/node-v12.10.1-linux-x64/bin/npm /usr/local/bin

按装pm2 可用npm按照

命令:npm install -g pm2

映射:ln -s /usr/local/node-v12.10.1-linux-x64/bin/pm2 /usr/local/bin

  1. $ pm2 list
  2. -------------
  3. __/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
  4. _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
  5. _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
  6. _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
  7. _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
  8. _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
  9. _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
  10. _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
  11. _\///______________\///______________\///__\///////////////__
  12. Runtime Edition
  13. PM2 is a Production Process Manager for Node.js applications
  14. with a built-in Load Balancer.
  15. Start and Daemonize any application:
  16. $ pm2 start app.js
  17. Load Balance 4 instances of api.js:
  18. $ pm2 start api.js -i 4
  19. Monitor in production:
  20. $ pm2 monitor
  21. Make pm2 auto-boot at server restart:
  22. $ pm2 startup
  23. To go further checkout:
  24. http://pm2.io/
  25. -------------
  26. [PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
  27. [PM2] PM2 Successfully daemonized
  28. ┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
  29. id name mode status cpu memory
  30. └────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘

文件操作命令

  1. #查看文件夹内容
  2. $ ll
  3. #切换文件夹
  4. $ cd /usr
  5. #创建文件夹
  6. $ mkdir 新建文件夹
  7. #删除文件
  8. $ rm -f 新建文件夹
  9. #打开文件 a或i编辑文件 ESC切换正常模式 正常模式下输入(:)进入命令行
  10. $ vim 文件

rm命令扩展

-f:—force强制删除文件,从不给出提示,但是会忽略不存在的文件

-i:—interactive 进行交互式删除

-r, -R:—recursive 指示rm将参数中列出的全部目录和子目录均递归地删除。

-r 就是向下递归,不管有多少级目录,一并删除

-f 就是直接强行删除,不作任何提示的意思

-rf

yum命令

yum install softwarename 安装

yum repolist 列出设定yum源的信息

yum remove softwarename 卸载

yum list softwarename 查看软件源中是否有此软件

yum list all 列出所有软件名称

yum list installd 列出已经安装的软件名称

yum list available 列出可以用yum安装的软件名称

yum clean all 清空yum缓存

yum search softwarename 根据软件信息搜索软件名字

yum whatprovides filename 在yum源中查找包含filename文件的软件包

yum update 更新软件

yum history 查看系统软件改变历史

yum reinstall softwarename 重新安装

yum info softwarename 查看软件信息

yum groups list 查看软件组信息

yum groups info softwaregroup 查看软件组内包含的软件

yum groups install softwaregroup 安装组件

nginx

rpm -c --query nginx查看安装目录

安装完成一般常用命令

进入安装目录中,

命令: cd /usr/local/nginx/sbin

启动,关闭,重启,命令:

./nginx 启动

./nginx -s stop 关闭

./nginx -s reload 重启

  1. # nginx.conf
  2. http{
  3. server {
  4. listen 80;
  5. server_name www.tongxinzai.com; #请求到80端口的host
  6. location / {
  7. proxy_set_header X-Real-IP $remote_addr;
  8. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  9. proxy_set_header Host $http_host;
  10. proxy_set_header X-Nginx-Proxy true;
  11. proxy_set_header Connection "";
  12. proxy_pass http://localhost:8081;
  13. }
  14. }
  15. }

杀死进程

1、查看占用端口的pid

lsof -i:9000

2、杀死占用端口的进程

kill -9 5891