#Nextjs deployment with plesk
33 messages · Page 1 of 1 (latest)
Hi
Hi, how are you?
How can I help you?
hi thx for reaching out
where should I put my project and install it ?
in var/www/vhosts/my-domain-name/httpdocs
or should put it outside the httpdocs and install it manually with nginx and pm2
@lethal bluff
Sorry for late reply.
Since you're deploying a custom application (not a standard PHP app), the best practice is not to place it inside the httpdocs directory.
ok i will tell you the steps i did :
- install nginx
- configure nginx file :
server {
listen 8080;
server_name 51.38.239.237;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
i used 8080 so it doesnot conflict with apache2 - deleted the default nginx config
- created a symbolic link with this command :
sudo ln -s /etc/nginx/sites-available/nextjs.conf /etc/nginx/sites-enabled/
-restart nginx and checked the status and it is active - cloned my project inside var/www/nextjs so the directory is var/www/nextjs/(myreponame)
- cd into my repo then npm install then npm build and npm start
all works fine till this
after this i install pm2 and start the app with this command pm2 start npm --name "nextjs" -- start
then i go for my ip address but i cannot find my project
@lethal bluff
Sorry again.
It was sleep.
It was midnight in our country
That setup looks good overall.
Running the app on port 3000 and reverse proxying via nginx on 8080 avoids conflict with Apache.
Just make sure your firewall allows traffic on port 8080, or we can switch nginx to proxy via a subdomain or integrate fully with Apache using Plesk's nginx settings.
Actually it worked on 8080 port
But i want it to work on the domain instead i will try to change the config nginx file and see if it is going to work
Yes, to make it work on the domain, you can update the nginx config to use your domain name in server_name and set it to listen on port 80 (or 443 for HTTPS).
The problem is i cannot make it work on 80 because apache2 is using that so will it be a problem if i used 8080? Cuz for now the url is myip:8080 so if I use the domain will it be only the domain as the url or it will be the domain:8080?
Sorry for late reply.
If Apache is using port 80, then yes — if nginx stays on 8080, the domain URL will be yourdomain.com:8080, unless you either:
- Disable Apache and let nginx handle port 80, or
- Use Apache as a reverse proxy to forward yourdomain.com to nginx on 8080.
Let me know which option you'd prefer — I can help set it up either way.
I can not disable apache2 because plesk runs internally with it
I broke plesk when i did that yesterday
So i guess option 2
I understand.
you are right!
You (or your server admin) can set up Apache in Plesk to proxy the domain to nginx on port 8080 — that way, users can just access yourdomain.com without needing :8080.
i want to make it work on mydomain:8080 for now atleast just to test it and it doesnot so when i hit matech-x.com:8080 in my browser it doesnot work is there something wrong on my nginx conf? and the app is running fine on my (ipaddress:8080)
@lethal bluff
Hi, sorry for late reply.
If yourdomain.com:8080 isn't working but your-ip:8080 is, the issue is likely DNS or firewall-related.
The nginx config looks fine.
Please make sure:
- The domain matech-x.com is pointing to your server's IP (check DNS A records).
- Port 8080 is open in your server's firewall and hosting provider's panel.
- Your hosting provider isn’t blocking public access to custom ports (some do for security).
Once DNS resolves and the port is open, matech-x.com:8080 should work just like the IP.
sorry i meant it works on myip:8080 not my domain
iam confused now because when i run ping matech-x.com it return back my ip address which is good but when i run ping matech-x.com 8.8.8.8(google dns) in plesk it doesnot return my ip but it returns my ip on my local machine with the google dns
so iamnot sure if the domain is connected to the ip
It sounds like your domain DNS is set up correctly externally (since ping returns your IP on your local machine), but inside your Plesk server, it might be using a different DNS resolver or caching old records.
Try running:
dig matech-x.com @8.8.8.8
or
nslookup matech-x.com 8.8.8.8
on the server to confirm the public DNS resolution.
If it still doesn't show your IP, the domain isn’t fully propagated or your server is caching old DNS.
Give it some time or flush the DNS cache.
are u using ai to respond to me ?