# aliyun **Repository Path**: coding-vip8/aliyun ## Basic Information - **Project Name**: aliyun - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-06-28 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README windows10 : powershell windows其它版本:下载 xshell vscode : 终端 连接阿里云服务器 ssh root@39.100.24.2 ## Nodejs安装 ``` #安装nodejs yum install nodejs # 确认版本 node -v #升级nodejs版本 npm install -g n n lts PATH="$PATH" ``` 安装pm2 npm install -g pm2 ## 上传文件 ``` cd / mkdir www ``` 下载ftp软件:https://filezilla-project.org/ 用 filezilla 上传 ![](https://tva1.sinaimg.cn/large/007S8ZIlly1gg8avv1vvfj319i0pu4a6.jpg) 启动应用 cd /www/lagouadmin 启动应用 pm2 start /www/lagouadmin/bin/www pm2 reload all (重启) 开启端口 本实例安全组-》添加安全组规则 ![](https://tva1.sinaimg.cn/large/007S8ZIlly1gg8banw6olj31ee0u0wmw.jpg) ## mongodb数据库安装 下载 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.18.tgz 解压: tar -zxvf mongodb-linux-x86_64-rhel70-3.6.18.tgz cd /usr/local mv /www/mongodb-linux-x86_64-rhel70-3.6.18.tgz mongodb 创建数据存储文件夹 cd /usr/local/mongodb/ mkdir data 创建日志文件 touch /usr/local/mongodb/mongod.log 启动mongodb数据库 cd /usr/local/mongodb/bin ./mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/mongod.log --logappend --port=27017 --fork --bind_ip 0.0.0.0 启动成功: ``` about to fork child process, waiting until server is ready for connections. forked process: 11793 child process started successfully, parent exiting ``` 在安全组规则里面添加端口:27017 ![](https://tva1.sinaimg.cn/large/007S8ZIlly1gg8buhsbtij30u00x8diu.jpg) ## nginx 部署 yum install epel-release -y yum install nginx -y 启动nginx systemctl start nginx systemctl enable nginx 停止 service nginx stop / nginx -s stop 重启 nginx -s reload 删除 rm -rf /usr/sbin/nginx rm -rf /etc/nginx rm -rf /etc/init.d/nginx (如果存在的话,也需要删除) yum erase nodejs yum remove nginx ## 域名 ![](https://tva1.sinaimg.cn/large/007S8ZIlly1gg8ck5j3ejj31si0s078d.jpg) ``` server { listen 80 default_server; listen [::]:80 default_server; server_name web678.xyz; # root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_pass http://127.0.0.1:3000; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } ``` ## 穿透配置 ``` upstream tunnel { server 127.0.0.1:7788; } server { listen 80; server_name web678.xyz; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://tunnel; } } ``` ## SSH通道:将服务器请求转发给本地 在本地计算机命令行里执行: ``` 混合开发jsdk,weapp穿透用(**本地执行**): ssh -vnNt -R 7788:localhost:3000 root@39.100.24.209 ``` **输入密码后重新访问应用 !!!: 穿透时不要忘记在阿里云服务器上配置端口:实例安全组>内网方向全部规则 添加 7000-8000端口**