PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 1, 2022

[FIXED] How to deploy Laravel + Nuxt application?

 August 01, 2022     hosting, javascript, laravel, nuxt.js, vps     No comments   

Issue

I have built Web application using Laravel As API and Nuxt As Front and. These 2 built desperately. When the development ongoing Its isn't an issue. Because i can run them using their own development servers. Then i have bought a VPS server for host this. Now the question in how i deploy these two apps on my VPS. Specially How i can deploy nuxt app correctly in vps. Its not static side. It is ssr app.


Solution

Essentially, you are going to need a few things:

  • A server (which you already have)
  • nginx
  • PM2
  • Node/NPM installed

The tricky part of this, is to make sure the server continues running and auto-restarts in case of a crash. PM2 solves that issue, and you can read more information on how to use it here: https://nuxtjs.org/docs/2.x/deployment/deployment-pm2

You can install it by:

npm install -g pm2

Which will install PM2 globally on your server and you'll have access to the pm2 command.

Follow the documentation above, and all you gotta do is run:

pm2 start all

This will start the Nuxt service and it will run on whichever port you've defined on your nuxt.config.js or package.json files.

Now that you've got your Nuxt instance running, you need to make sure that requests that come through the browser end up on the port that Nuxt is running on, that's achievable by using nginx's reverse proxy feature that you can read more about: https://nuxtjs.org/docs/2.x/deployment/nginx-proxy/

That documentation provides you with an example of an nginx config file, and you shouldn't really have to change anything other than the server_name, and the proxy_pass in case you've changed the default Nuxt port from 3000 to something else.

Additionally make sure that you have allowed port 80 to be listen on your server.



Answered By - Filipe Neves
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing