[Vuejs]-How to deploy SSR Nuxt app to Plesk web server?

2👍

you need to have server.js file in root directory and run with plesk node

const express = require('express');
const { Nuxt, Builder } = require('nuxt');

const config = require('./nuxt.config.js');

// Create new express app
const app = express();

// Listen to port 3000 or PORT env if provided
app.listen(process.env.PORT || 3000);

// Enable production mode
config.dev = false;

// Create instance of nuxt
const nuxt = new Nuxt(config);

// Add nuxt middleware
app.use(nuxt.render);

// Build on start
// new Builder(nuxt).build().catch(err => {
//   console.error(err);
//   process.exit(1);
// });

-2👍

I did not check Plesk Onyx

But I assume that Plesk Onyx gives you VPN with root access
What you need to do is this

VPN OS is ubuntu

  • access the vpn using ssh (read about putty if you like) or just ssh root@serverip
  • sudo apt update
  • sudo install nginx
  • cd ~
  • sudo curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
  • sudo bash nodesource_setup.sh
  • sudo apt install nodejs
  • sudo vim /etc/nginx/sites-available/nuxt_config (Search about nuxtjs nginx configration)
  • sudo ln -s /etc/nginx/sites-available/nuxt_config /etc/nginx/sites-enable
  • sudo nginx -s reload (to reload your nginx settings)
  • cd /var/www/
  • mkdir nuxt-site && cd nuxt-site
  • install you nuxtjs files using git clone and run npm i and npm run build if you don’t have dist folder in your repo
  • install pm2 (read about PM2) npm i -g pm2
  • make sure that you are in the project folder and run sudo pm2 start --name YourApplicationName npm -- start

PS: if you push any updates in the future you should pull it and then restart or reload your pm2 like sudo pm2 reload 0 where 0 is the index of your project in pm2 you can do pm2 list to see what index your project have <3

Leave a comment