C
C#2y ago
REAPER

✅ Hosting Asp.Net Core 3.1 website on Ubuntu VPS

Hi, I've been trying to host my website on my Ubuntu 20.04 Cloud VPS but when I try using the command sudo systemctl start scuffed.service the status keeps giving me this error: ExecStart=/usr/bin/dotnet /root/Website/ScuffedManagerWeb.dll (code=exited, status=217/USER) I can see the files in their path locations but maybe I've messed up somewhere anyways rooF If anyone out there got any experience hosting websites then please post in here or feel free to DM me. rooHappy
70 Replies
REAPER
REAPER2y ago
My scuffed.service looks like this:
[Unit]
Description=scuffed-manager

[Service]
WorkingDirectory=/root/Website
ExecStart=/usr/bin/dotnet /root/Website/ScuffedManagerWeb.dll
Restart=always
RestartSec=10
SyslogIdentifier=REAPER
User=REAPER

[Install]
WantedBy=multi-user.target
[Unit]
Description=scuffed-manager

[Service]
WorkingDirectory=/root/Website
ExecStart=/usr/bin/dotnet /root/Website/ScuffedManagerWeb.dll
Restart=always
RestartSec=10
SyslogIdentifier=REAPER
User=REAPER

[Install]
WantedBy=multi-user.target
Henkypenky
Henkypenky2y ago
upon some quick google searching 217 means the user doesn't exist at the time service tried to start do you have some logs?
canton7
canton72y ago
Checked the logs? journalctl -ru scuffed Can you run it normally from the command line? Or yeah, doss the user REAPER exist on your system?
REAPER
REAPER2y ago
If I type dotnet /root/Website/ScuffedManagerWeb.dll then it starts the website.
REAPER
REAPER2y ago
This is the log I'm getting when typing journalctl -ru scuffed
Henkypenky
Henkypenky2y ago
is your user REAPER like this?
REAPER
REAPER2y ago
To be honest I'm not 100% sure
Henkypenky
Henkypenky2y ago
show me console what does it say
REAPER
REAPER2y ago
Like this? root@somethingcp-7176:~# journalctl -ru scuffed
Henkypenky
Henkypenky2y ago
you are using root as the user
REAPER
REAPER2y ago
Oh...
Henkypenky
Henkypenky2y ago
please type this awk -F: '{ print $1}' /etc/passwd wait
REAPER
REAPER2y ago
That makes more sense then...
Henkypenky
Henkypenky2y ago
yes type that or this cut -d: -f1 /etc/passwd
REAPER
REAPER2y ago
What does it do?
Henkypenky
Henkypenky2y ago
lists all users
REAPER
REAPER2y ago
Henkypenky
Henkypenky2y ago
no REAPER user
REAPER
REAPER2y ago
So I should just change REAPER to root in the service file?
Henkypenky
Henkypenky2y ago
just remove it and it will run as root
REAPER
REAPER2y ago
Ok thanks, I'll try that
canton7
canton72y ago
Although, you probably don't want to run it as root. Create a dedicated user for it
Henkypenky
Henkypenky2y ago
yeah also that
REAPER
REAPER2y ago
How do I make a user then? rooThink
REAPER
REAPER2y ago
Ok so I added a new user named "REAPER" and kept the User = REAPER in my scuffed.service. Then I did sudo systemctl daemon-reload => sudo systemctl start scuffed.service => sudo systemctl status scuffed.service and it gives me this new error rooThink scuffed.service - scuffed-manager Loaded: loaded (/etc/systemd/system/scuffed.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Sun 2023-02-05 01:16:09 CET; 6s ago Process: 1528970 ExecStart=/usr/bin/dotnet /root/Website/ScuffedManagerWeb.dll (code=exited, status=200/CHDIR) Main PID: 1528970 (code=exited, status=200/CHDIR)
Henkypenky
Henkypenky2y ago
that means the user doesn't have permissions i thinik
REAPER
REAPER2y ago
I was just reading up on it as well and I came to the same conclusion Btw I just tried to run the website with the root user and it works rooHappy really sure how to give the REAPER user permissions though 😅
Henkypenky
Henkypenky2y ago
just run it like services by default for now while your read more on linux and some of it's weird ways that take time to get used to
REAPER
REAPER2y ago
Yeah read something about groups and stuff and it seemed a bit complicated for now 🙂 Thanks a lot for the help 😄 Is Apache2 a good way to host a website? Or are there some better ways to use?
Henkypenky
Henkypenky2y ago
depends on the app i would say: apache: more flexibility, feature rich, large volume of traffic nginx: faster, lightweight, scalable
jcotton42
jcotton422y ago
it's failing b/c non-root users aren't allowed to be in root's home folder
REAPER
REAPER2y ago
When hosting through Apache2, how long does it usually take before I can see the website on my own computer? rooThink I'm asking because I'm not sure if my website is setup correctly or if it just takes time before it's live
Angius
Angius2y ago
Apache should just work immediately The DNS resolvers might take some time to register your domain, though
REAPER
REAPER2y ago
How does it work again with domains. I have to pay for one right? Or is it possible to have a name for free rooThink
Angius
Angius2y ago
Yeah, you need to pay a yearly fee
REAPER
REAPER2y ago
That might be my problem then... There aren't any weird .ladwl to have at the end to get a free domain?
Angius
Angius2y ago
Uh, there's Freenom I guess But they can just revoke your domain at any time And direct it to a page with ads So not really trustworthy lol
Angius
Angius2y ago
Domains aren't expensive, tho
REAPER
REAPER2y ago
I guess you got a point there rooThink so let's say I buy the domain "scuffed-manager.shop". Do I then just have to change my Apache2.conf file? Because I feel like there got to be some kind of login to prove you're the owner of the domain (I just don't want to buy a domain and not know how to use it 😅).
Angius
Angius2y ago
Plenty of tutorials around, you'll surely find something
REAPER
REAPER2y ago
So it's not too advanced?
Angius
Angius2y ago
Nah, super simple
REAPER
REAPER2y ago
Ok, thanks I'll try looking into it 😄 Oh yeah one more thing. The price of this domain is 1,78 dollars but if I buy 2 years the price goes to 32,76 dollars. Does this mean that there's a discount on the first year or is it to prevent people locking on to a domain for a low price without having a chance of losing it? Seems a bit weird to me rooThink
Angius
Angius2y ago
Some registrars, yeah, lure you in with low initial prices and then raise them Cloudflare will offer constant prices The registrars that offer initial discount are cool if you need a domain for some small project for a year or so But after that... they can get really expensive Google Domains is another registrar that's trustworthy and doesn't discount the first year Cloudflare is the cheapest tho
REAPER
REAPER2y ago
This website is just a small one which is being used by me and 2 others to select movies on 😅 So I'm thinking if it might be worth going for a 1 year domain and then just switching to a new domain name rooThink
Angius
Angius2y ago
Yeah, that would work lol Or you could try just using the IP maybe
REAPER
REAPER2y ago
But I'm struggling to find the prices on CloudFlare domains rooKek
Angius
Angius2y ago
Need to log in first, go to registrar in the left menu
REAPER
REAPER2y ago
Dumb question but how do I use the ip? Is that just to replace the domain name in my conf files with the vps ip? rooThink
Angius
Angius2y ago
Enter domain name, press enter, will show all available TLDs and prices Yeah http://123.456.78.90
REAPER
REAPER2y ago
Let me try and see if that works because I'm very curious if my setup actually works 😉 To find my ip I just have to type ifconfig and find get the number from inet right?
Angius
Angius2y ago
Probably? It's the IP you use to SSH into the server Might need to add the port too
Henkypenky
Henkypenky2y ago
if you have a credit card you can get 200 bucks on azure for free, which should give you hosting for about a year for free they give you subdomain in the form of: foo.azurewebsites.net with ssl and everything
REAPER
REAPER2y ago
That might be a solution as well. Right now it won't even show me the website if I'm running it on ip instead of a domain name 😅 Slowly dying inside
Henkypenky
Henkypenky2y ago
azure is very easy, if you get that, you press one button on visual studio and your app gets published in like 10 seconds or rider
REAPER
REAPER2y ago
The are very pricy after that 1 year right?
Henkypenky
Henkypenky2y ago
50 bucks a month i think for the basic tier
REAPER
REAPER2y ago
Jeez
Henkypenky
Henkypenky2y ago
but that year is enough for you to start then you can migrate somewhere else
REAPER
REAPER2y ago
Was kind of hoping for a more steady solution now, so I don't have to think about it in the future 😅 Plus I think I used my credits on a Discord bot some years ago, so I'm not sure if there's any credits left rooF
Henkypenky
Henkypenky2y ago
what's your budget? per month
REAPER
REAPER2y ago
I'm not entirely sure but I would probably say as low as possible 😅
Henkypenky
Henkypenky2y ago
so like 10 bucks?
REAPER
REAPER2y ago
What are we talking about here? 10 bucks for a domain or a vps to host on?
Henkypenky
Henkypenky2y ago
vps hosting
REAPER
REAPER2y ago
I already got one of those which I'm hosting my Discord bot on and was hoping to host my website on that as well It's sadly not from Azure so I can't use the easy setup system they got rooCry on the other hand it's only 4 euro each month
Henkypenky
Henkypenky2y ago
read what ZZ said again there lies the key
REAPER
REAPER2y ago
I'm pretty sure I haven't setup a SSH, that's not a requirement right? I tried changing the domain name in my files to my ip and in my browser i searched for: http://{ip}:{different ports} and I wasn't able to find it rooThink (different ports because I'm not 100% sure about what port it uses but it should be allowing multiple once in the firewall)
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.