Installing Django using nginx-unit

SaeedTJ

Verified User
Joined
Aug 20, 2017
Messages
39
I want to deploy a django app using nginx-unit
my project structure is like this:
Code:
domains/meno.digital/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        asgi.py
        wsgi.py

I do not know what should I do to create or run the application and there is not an example about deploying it or any tutorial video.
can anyone help how to configure it.
 

Attachments

  • Screenshot 2025-02-27 103352.png
    Screenshot 2025-02-27 103352.png
    42.3 KB · Views: 6
  • Screenshot 2025-02-27 103533.png
    Screenshot 2025-02-27 103533.png
    36.4 KB · Views: 6
Do not have much information either. You might find what we have here: https://help.poralix.com/tags/nginx-unit
Unfortunately, this link did not help.
Let's check again with another scenario.
1) I uploaded a nextjs app in this directory:
Code:
/home/meno/domains/meno.digital/meno

2) I made a server.js file in that directory and put this codes in it as config:
Code:
process.env.NEXT_RUNTIME = "nodejs";

import { createServer } from "http";
import { parse } from "url";
import next from "next";

const PORT = process.env.PORT || 3000;
const app = next({ dev: false });
const handle = app.getRequestHandler();

app.prepare().then(() => {
    createServer((req, res) => {
        const parsedUrl = parse(req.url, true);
        handle(req, res, parsedUrl);
    }).listen(PORT, "127.0.0.1", () => {
        console.log(`✅ Ready on http://127.0.0.1:${PORT}`);
    });
});

3) I clicked on create application and set the working directory on /home/meno/domains/meno.digital/meno
4)
set the script field on server.js
5)
set the routes on this:
Code:
[
  {
    "action": {
      "share": "/home/meno/domains/meno.digital/meno$uri",
      "fallback": {
        "proxy": "http://127.0.0.1:3000"
      }
    }
  }
]
6) I entered into /home/meno/domains/meno.digital/meno using ssh and run the command node server.js &
7) I can see the app and It works perfectly

Problem:
when I close the terminal the session will be closed and nohup or any other ways does not work. and the nginx unit does not run server.js
 
I don't need Nginx UNIT for my projects, I configured it for my customers only, and I shared issues which I faced and solved by the link in the previous post. When I need Nginx UNIT for my own or my customers, or I have free time, I will dive deeper in the subject of course. But not now.

As far as I can you use your custom way to run the application (as if you don't have Directadmin at all), and this is not the official way to use Nginx UNIT in DirectAdmin. Probably other guys on the forums can help you more. Or search internet how to run nodejs as a daemon without nginx unit.
 
Please ensure to disable "jailshell" from the user account before do this, otherwise background process will terminate after close the terminal.


Login via ssh into user account.

1: Install "nvm" and "nodejs"

2: Install "pm2"
Code:
npm install pm2 -g

3: Install pm2-logrotate
Code:
pm2 install pm2-logrotate

4: start process
Code:
pm2 start server.js
pm2 save
 
Back
Top