Skip to content

Instantly share code, notes, and snippets.

@tickstudiu
Last active August 31, 2023 06:29
Show Gist options
  • Save tickstudiu/85c4e3f44b766ce852a69956f190a81f to your computer and use it in GitHub Desktop.
Save tickstudiu/85c4e3f44b766ce852a69956f190a81f 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
@zaralX
Copy link

zaralX commented Aug 31, 2023

fix this:
sudo ngnix -t to sudo nginx -t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment