Skip to content

Instantly share code, notes, and snippets.

@JulianLlanten8
Forked from tickstudiu/deploy.md
Created September 9, 2022 22:20
Show Gist options
  • Save JulianLlanten8/e193a845afefd3986b6a2c0992c5ea04 to your computer and use it in GitHub Desktop.
Save JulianLlanten8/e193a845afefd3986b6a2c0992c5ea04 to your computer and use it in GitHub Desktop.
Deploy Nuxtjs on linux server

Deploy Nuxtjs on linux server

Table of Contents

Setup

Update server:

sudo apt-get update

Install nginx:

sudo apt-get install nginx

Install nodejs(14.x):

# Install the PPA
curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh

# Run the PPA
sudo bash nodesource_setup.sh

# Install the Node.js package
sudo apt install nodejs

# Verify that you’ve installed
node -v

# Output
v14.2.0

Project

In case I installed a project that /ver/www/html

Clone the repo:

git clone https://github.com/tickstudiu/<repo name>.git
cd <repo name>

Install the dependencies:

npm install

Generate static project:

npm run generate

shold have folder /dist in <repo_name>

Config

cd /etc/nginx/sites-enabled

Config:

server {
	listen 80 default_server;
	listen [::]:80 default_server;

	root /var/www/html/<repo_name>/dist;

	index index.html index.htm index.nginx-debian.html;

	server_name _;

	location / {
		try_files $uri $uri/ =404;
	}
}

Check nginx and restart:

# check nginx
sudo ngnix -t

# restart nginx
sudo service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment