linux指令 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. linux指令:
  2. wget 安装
  3. rm -r/-rf 删除文件/文件夹下所有内容
  4. vi ... 打开文件,进入编辑器模式
  5. 编辑器模式: i => 开始插入 ; esc 停止插入 ; : x/wq 保存并退出
  6. mv a b 移动文件a 至 b
  7. tar -zxvf 解压
  8. touch 新建文件
  9. mkdir 创建文件夹
  10. pwd 当前路径
  11. du -sh 统计当前文件夹的占用 h:以人类能读的方式显示
  12. crontab -l 查看定时任务
  13. mongodb 启动 ./mongod --config ./mongodb.conf
  14. 查看目录下的文件夹占用磁盘资源: du -sh * | sort -n
  15. 重启后,首先关闭防火墙:
  16. systemctl stop firewalld.service
  17. systemctl start nginx.service
  18. systemctl start mongodb.service
  19. mongodb:
  20. [root@localhost bin]# ./mongod -f /usr/local/mongodb/mongodb.conf
  21. mongodb的配置文件使用绝对地址
  22. 创建用户:
  23. 进入mongodb的shell
  24. use admin
  25. db.createUser({user:"admin",pwd:"111111",roles:[{role:"root",db:"admin"}]})
  26. 登陆:
  27. db.auth("admin","111111")
  28. 如果不能直接使用mongo,说明没有配置环境变量
  29. 进入 /etc,查看profile
  30. sudo vi/vim /etc/profile
  31. 添加:export PATH=/usr/local/mongodb/bin:$PATH
  32. 保存=>执行
  33. source /etc/profile
  34. 创建systemctl指令:
  35. 进入/etc/systemd/system
  36. 创建mongodb.service
  37. 写入:
  38. [Unit]
  39. Description=mongodb
  40. After=network.target
  41. [Service]
  42. # 注意这个地方是个坑,如果你的mongodb配置文件中设置的作为守护线程运行,下面这一>行一定要加上
  43. Type=forking
  44. ExecStart=/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/mongodb.conf
  45. [Install]
  46. WantedBy=multi-user.target
  47. 保存即可使用
  48. nodejs:
  49. 官网复制地址=>wget/curl下载=>tar解压=>改名
  50. 软连接,全局使用:
  51. ln -s /usr/local/nodejs/bin/node /usr/bin/node
  52. ln -s /usr/local/nodejs/bin/npm /usr/bin/npm
  53. 配置nodejs缓存和本地库:
  54. 在nodejs根目录下:
  55. mkdir node_global && mkdir node_cache
  56. 修改node设置:
  57. npm config set prefix "node_global" && npm config set cache "node_cache"
  58. 配置nginx:
  59. 前端:
  60. location ^~/${prefix} {
  61. root ${position};
  62. index index.html index.htm;
  63. try_files $uri $uri/ /${prefix}/index.html;
  64. }
  65. 服务端:
  66. location ^~ ${apiPrefix} {
  67. proxy_pass http://127.0.0.1:${port};
  68. }
  69. 静态目录:
  70. location /${prefix}/ {
  71. root ${position};
  72. rewrite ^/${prefix}/(.*)$ /$1 break;
  73. try_files $uri @fs;
  74. }
  75. @fs:为上传服务端配置
  76. mq:
  77. location /ws {
  78. proxy_pass http://127.0.0.1:15674;
  79. proxy_set_header host $host:$server_port;
  80. proxy_http_version 1.1;
  81. proxy_set_header Upgrade $http_upgrade;
  82. proxy_set_header Connection "upgrade";
  83. }
  84. rpm等包管理器安装,tar解压则需要自己配置:
  85. vi /etc/nginx/nginx.conf 打开nginx配置文件
  86. 启动:systemctl start nginx.service
  87. 停止:systemctl stop nginx.service
  88. 重启:systemctl restart nginx.service
  89. 证书:
  90. .crt,.key放到哪里都行,反正在nginx.conf中配置好就行
  91. 放开https部分,没有自己扒一个
  92. 关键点:
  93. server_name:域名,不加前缀,直接写域名
  94. ssl on;
  95. ssl_certificate: 证书位置,就是上面的.crt的路径(用绝对的.只要不写错,准没问题)
  96. ssl_certificate_key: 私钥,同上
  97. 然后配置使用https的服务端,前端啥的
  98. 文件上传:
  99. 由服务端发起,指令:
  100. rz:上传,选择文件,然后到指定目录再执行 rz,就存在当前位置了
  101. sz:下载
  102. sftp方式:
  103. ls,cd:远程服务器
  104. lls,lcd:本机
  105. put xxx 上传文件
  106. get xxx 下载服务器 ls的位置
  107. 所有访问都是502:
  108. getsebool httpd_can_network_connect 允许外部访问 如果是off,用下面改成on
  109. setsebool -P httpd_can_network_connect on
  110. ubuntu:
  111. 用户名:lrf
  112. 密码:1qaz2wsx
  113. linux:
  114. 用户名:root
  115. 密码:1327542758