Nuxt has two packaging modes. The nuxt.config.js file needs to be configured for different packaging modes

Target: 'server', //build server, generate static default serverCopy the code

The generate packaging

This is static deployment, which is relatively simple

npm run generate
Copy the code

You generate the dist folder, you put it directly on the server and you can access it but if you modify the data in the background, the front end still displays the data that you packaged before

Build packaging

npm run build
Copy the code

1| .nuxt

2| static

3| nuxt.config.js

4| package.json

Install the node CMD folder on the remote server and execute

npm install
npm run start
Copy the code

Can generate a local link to access

Nginx Reverse proxy nginx download :nginx.org/en/download…

Server_name = server_name = domain name of your proxy. Do not enter http:// proxy_pass for your node server address

Project nuxt.config.js configures the server

Server: {port: 3000, host: '0.0.0.0', timing: false}, upstream {server: 0.0.0.0:3000; keepalive 64; } server { listen 86; server_name xxx.com; location / { proxy_pass http://nodenuxt; }}Copy the code

Start nginx by opening CMD in the nginx.exe directory

Start nginx // Start nginxCopy the code

The general nginx commands are as follows

Start nginx nginx -s stop // stop // close nginx nginx -s reload // restart nginx nginx -t // check nginx writing problems taskkill /f /t /im Nginx. exe // Clears all nginx processesCopy the code

You can access the IP address or domain name with port number 86

The nginx extranet cannot be accessed

If you want the domain name to be accessible from the Internet, you need to configure the firewall on the server. Open control Panel \ System and Security \Windows Defender Firewall path To Allow applications to communicate through Windows Defender Firewall. Click Allow Other Applications. Browse the specified nginx.exe file and then add

Pm2 daemon

npm install pm2 -g
Copy the code

Pm2 can close the Node server window and continue to access the link server to create a new file.config.js file in the root directory of the server project

module.exports = {
  apps: [
    {
      name: 'NuxtAppName',
      exec_mode: 'cluster',
      instances: 'max', // Or a number of instances
      script: './node_modules/nuxt/bin/nuxt.js',
      args: 'start'
    }
  ]
}
Copy the code

Execute in project directory

pm2 start
Copy the code

Pm2 general command

Pm2 delete ID // Delete the SPECIFIED PM2 process. Pm2 delete all // Delete all processes. Pm2 list // View all PM2 processesCopy the code

These articles are recommended for iis deployment at blog.csdn.net/qq_24821757… Blog.csdn.net/cplvfx/arti… If you do not have the Application Request Routing Cache for IIS, you need to install it -> Install it at www.iis.net/downloads/m…

If the server error occurs in the “/” application when opening the website and the solution needs to configure web.config to be added later

  <system.web>
      <customErrors mode="Off"/>
      <httpRuntime requestPathInvalidCharacters="" />
  </system.web>
Copy the code