# Hosting / Deploying Nextjs app using Nginx

**URL:** <http://fluxxset.com/t/hosting-deploying-nextjs-app-using-nginx/41>\
**Category:** sys admin\
**Tags:** hosting\
**Created:** [February 5, 2024, 5:06pm UTC](http://fluxxset.com/t/hosting-deploying-nextjs-app-using-nginx/41 "2024-02-05T17:06:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ServerGuyFluxx](http://fluxxset.com/user_avatar/fluxxset.com/serverguyfluxx/32/12_2.png) [@ServerGuyFluxx](http://fluxxset.com/u/ServerGuyFluxx)\
**Post date:** [February 5, 2024, 5:06pm UTC](http://fluxxset.com/t/hosting-deploying-nextjs-app-using-nginx/41/1 "2024-02-05T17:06:16Z")

</div>

[  
1h](https://fluxxset.com/t/hosting-next-js-application-using-caddy/40)

## [**Get 200$ in Digital Ocean**](https://5f5.in/vH7J)and [**Get 100$ in Vultr**](https://5f5.in/eDGv)

make sure you use ubuntu server and once you logged in you can follow following commands.

_Install Nginx_

```auto
sudo apt install nginx

```

**Install node using NVM**

```auto
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm install node
node --version

```

## Clone Next js sample app and setup

```auto
git clone https://github.com/fluxxset/Sample_next_js.git /var/www/Sample_next_js
cd /var/www/Sample_next_js/sample
npm install 
npm install -g pm2
npm run build
pm2 start npm --name "sample" -- start
pm2 ls

```

test if app is working on port 3000

## Configure Nginx

Update `nano /etc/nginx/sites-available/default`:

```auto
nano nano /etc/nginx/sites-available/default

```

Add the following:

```auto
server {
    listen 80;

    location / {
        include proxy_params;
        proxy_pass 127.0.0.1:3000
    }
}

```

Finally, restart and enable services:

\*\*testing Neginx config \*\*

```auto
sudo nginx -t 

```

# Restart Nginx

sudo service nginx restart

```auto

Now, go to your browser, type the Domain , and you should see your Nextjs website running.
```
