当前位置: 首页 > news >正文

家用电脑搭建网站西安百度快照优化

家用电脑搭建网站,西安百度快照优化,asp婚纱摄影网站,网站制作素材nextjs项目有多种部署方式,本文介绍最简单的一种方式,将源码上传到云服务器,编译后使用pm2后台运行nextjs工程。 检查node、npm是否安装 查看npm版本,如果版本较低先升级npm版本 npm -v卸载 yum remove nodejs npm -y安装新版…

nextjs项目有多种部署方式,本文介绍最简单的一种方式,将源码上传到云服务器,编译后使用pm2后台运行nextjs工程。

检查node、npm是否安装

查看npm版本,如果版本较低先升级npm版本

npm -v

卸载

yum remove nodejs npm -y

安装新版本

sudo yum install https://rpm.nodesource.com/pub_21.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y 
sudo yum install nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1

部署和编译

  1. 拷贝工程源码目录到服务器,其中node_modules、.git不需要上传

  2. 编译

npm run build

使用pm2后台运行nextjs程序

  1. 安装pm2
npm install -g pm2
  1. 运行
#注意当前是在工程目录下,命令中的名称可以任意命名,pm2管理中起到标识作用,实际运行的程序是当前目录下
pm2 start --name 自定义名称 npm -- start
  1. 查看端口占用,如工程中使用的3000,端口列表中也出现了,说明后台运行成功了
netstat -nultp
  1. 如果服务器开放了对应端口,可以加端口浏览器访问项目,如果只能开放80,继续nginx

安装配置nginx

  1. 安装nginx
yum install nginx -y
  1. nginx配置文件(/etc/nginx/etc/nginx.conf)
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;events {worker_connections 1024;
}http {log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log  /var/log/nginx/access.log  main;sendfile            on;tcp_nopush          on;tcp_nodelay         on;keepalive_timeout   65;types_hash_max_size 2048;autoindex on;autoindex_exact_size off;autoindex_localtime on;include             /etc/nginx/mime.types;default_type        application/octet-stream;# Load modular configuration files from the /etc/nginx/conf.d directory.# See http://nginx.org/en/docs/ngx_core_module.html#include# for more information.include /etc/nginx/conf.d/*.conf;server {listen       80 default_server;listen       [::]:80 default_server;server_name  _;root         /usr/share/nginx/html;# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;location / {}error_page 404 /404.html;location = /40x.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {}}include /etc/nginx/vhosts/*.conf;
}
  1. 多工程配置
    创建 /etc/nginx/vhosts/工程名.conf,自行修改域名,确保域名映射已设置好
server {listen       80;#443;server_name  xxx.xxxx.com;root html;index index.html index.htm;location / {proxy_pass http://127.0.0.1:3000;#设置主机头和客户端真实地址,以便服务器获取客户端真实IPproxy_set_header Host $host;proxy_set_header X-Real-Ip $remote_addr;proxy_set_header X-Forwarded-For $remote_addr;}
}
  1. 启动nginx
# 启动
systemctl start nginx
# 停止
systemctl stop nginx
# 重启
systemctl restart nginx 
# 重新加载配置文件
nginx -s reload
  1. 使用域名访问测试

pm2命令介绍

# 查看任务
pm2 list/# 重启
pm2 restart app_name# 停止
pm2 stop app_name|app_id# 停止所有
pm2 stop all# 删除
pm2 delete app_name|app_id# 删除所有
pm2 delete all# 日志
pm2 logs app_name|app_id# 查看所有日志
pm2 logs
http://www.hkea.cn/news/581168/

相关文章:

  • wordpress儿童卡通主题兰州网站seo服务
  • 8网站建设做网站sem优化师是什么意思
  • 设计师个人网站怎么做百度优化培训
  • 广东海外建设监理有限公司官方网站2345网址导航是病毒吗
  • 深圳网站制作培训宁波网络营销公司
  • 网站建设方案书 模板长清区seo网络优化软件
  • 简述网站的推广策略产品设计
  • 商贸有限公司网站建设此网站服务器不在国内维护
  • 常州个人做网站制作小程序的软件
  • 郑州做网站公司dz论坛如何seo
  • 十堰商城网站建设网络营销seo优化
  • 小欢喜林磊儿什么网站做家教福州seo推广外包
  • 许昌网站开发博客营销
  • 做网站用jquery爱站网关键词挖掘
  • wordpress手动裁剪seo营销推广服务公司
  • 英文网站建设网站海南网站制作公司
  • 网页设计与网站建设主要内容软文营销的特点
  • 一起做网站17广州最新小组排名
  • 最专业的网站设计公司有哪些论坛企业推广
  • 单页网站怎么做外链个人网页
  • 宁波城乡住房建设局网站有效的网络推广
  • 网站建设 深圳销售crm客户管理系统
  • 高端网站开发设计站长之家字体
  • 免费网站建站工具购买域名的网站
  • 淘宝联盟怎么做网站百度网站提交
  • 前端做用vue做后台多还是做网站多青岛网站快速排名优化
  • 岳阳网站开发公司海淀区seo多少钱
  • 2017年做网站维护总结百度搜索软件
  • 南京网站建设公司点击器原理
  • 网站怎么编辑搜狗网站提交入口