C
Join ServerC#
help
✅ Hosting Asp.Net Core 3.1 website on Ubuntu VPS
RREAPER2/4/2023
Hi, I've been trying to host my website on my Ubuntu 20.04 Cloud VPS but when I try using the command
I can see the files in their path locations but maybe I've messed up somewhere anyways
If anyone out there got any experience hosting websites then please post in here or feel free to DM me.
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

If anyone out there got any experience hosting websites then please post in here or feel free to DM me.

RREAPER2/4/2023
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
HHenkypenky2/4/2023
upon some quick google searching 217 means the user doesn't exist at the time service tried to start
HHenkypenky2/4/2023
do you have some logs?
Ccanton72/4/2023
Checked the logs?
journalctl -ru scuffed
Ccanton72/4/2023
Can you run it normally from the command line?
Ccanton72/4/2023
Or yeah, doss the user REAPER exist on your system?
RREAPER2/5/2023
If I type
dotnet /root/Website/ScuffedManagerWeb.dll
then it starts the website.RREAPER2/5/2023
This is the log I'm getting when typing
journalctl -ru scuffed
HHenkypenky2/5/2023
is your user REAPER
HHenkypenky2/5/2023
like this?
RREAPER2/5/2023
To be honest I'm not 100% sure
HHenkypenky2/5/2023
show me console
HHenkypenky2/5/2023
what does it say
RREAPER2/5/2023
Like this?
root@somethingcp-7176:~# journalctl -ru scuffed
root@somethingcp-7176:~# journalctl -ru scuffed
HHenkypenky2/5/2023
you are using root
HHenkypenky2/5/2023
as the user
RREAPER2/5/2023
Oh...
HHenkypenky2/5/2023
please type this
HHenkypenky2/5/2023
awk -F: '{ print $1}' /etc/passwd
HHenkypenky2/5/2023
wait
RREAPER2/5/2023
That makes more sense then...
HHenkypenky2/5/2023
yes
HHenkypenky2/5/2023
type that
HHenkypenky2/5/2023
or this
HHenkypenky2/5/2023
cut -d: -f1 /etc/passwd
RREAPER2/5/2023
What does it do?
HHenkypenky2/5/2023
lists all users
RREAPER2/5/2023

HHenkypenky2/5/2023
no REAPER
HHenkypenky2/5/2023
user
RREAPER2/5/2023
So I should just change REAPER to root in the service file?
HHenkypenky2/5/2023
just remove it
HHenkypenky2/5/2023
and it will run as root
RREAPER2/5/2023
Ok thanks, I'll try that
Ccanton72/5/2023
Although, you probably don't want to run it as root. Create a dedicated user for it
HHenkypenky2/5/2023
yeah also that
RREAPER2/5/2023
How do I make a user then? 

RREAPER2/5/2023
Ok so I added a new user named "REAPER" and kept the User = REAPER in my scuffed.service.
Then I did
● 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)
Then I did
sudo systemctl daemon-reload
=> sudo systemctl start scuffed.service
=> sudo systemctl status scuffed.service
and it gives me this new error 
● 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)
HHenkypenky2/5/2023
that means the user doesn't have permissions i thinik
RREAPER2/5/2023
I was just reading up on it as well and I came to the same conclusion
RREAPER2/5/2023
Btw I just tried to run the website with the root user and it works 

RREAPER2/5/2023
Not really sure how to give the REAPER user permissions though 😅
HHenkypenky2/5/2023
just run it like services by default for now while your read more on linux and some of it's weird ways
HHenkypenky2/5/2023
that take time to get used to
RREAPER2/5/2023
Yeah read something about groups and stuff and it seemed a bit complicated for now 🙂
RREAPER2/5/2023
Thanks a lot for the help 😄
RREAPER2/5/2023
Is Apache2 a good way to host a website? Or are there some better ways to use?
HHenkypenky2/5/2023
depends on the app
HHenkypenky2/5/2023
i would say:
apache: more flexibility, feature rich, large volume of traffic
nginx: faster, lightweight, scalable
apache: more flexibility, feature rich, large volume of traffic
nginx: faster, lightweight, scalable
Jjcotton422/5/2023
it's failing b/c non-root users aren't allowed to be in root's home folder
RREAPER2/5/2023
When hosting through Apache2, how long does it usually take before I can see the website on my own computer?
I'm asking because I'm not sure if my website is setup correctly or if it just takes time before it's live

I'm asking because I'm not sure if my website is setup correctly or if it just takes time before it's live
AAngius2/5/2023
Apache should just work immediately
AAngius2/5/2023
The DNS resolvers might take some time to register your domain, though
RREAPER2/5/2023
How does it work again with domains. I have to pay for one right? Or is it possible to have a name for free 

AAngius2/5/2023
Yeah, you need to pay a yearly fee
RREAPER2/5/2023
That might be my problem then...
RREAPER2/5/2023
There aren't any weird .ladwl to have at the end to get a free domain?
AAngius2/5/2023
Uh, there's Freenom I guess
AAngius2/5/2023
But they can just revoke your domain at any time
AAngius2/5/2023
And direct it to a page with ads
AAngius2/5/2023
So not really trustworthy lol
AAngius2/5/2023
Domains aren't expensive, tho

RREAPER2/5/2023
I guess you got a point there 

RREAPER2/5/2023
Ok so let's say I buy the domain "scuffed-manager.shop". Do I then just have to change my Apache2.conf file?
RREAPER2/5/2023
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 😅).
AAngius2/5/2023
Plenty of tutorials around, you'll surely find something
RREAPER2/5/2023
So it's not too advanced?
AAngius2/5/2023
Nah, super simple
RREAPER2/5/2023
Ok, thanks I'll try looking into it 😄
RREAPER2/5/2023
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?
RREAPER2/5/2023
Seems a bit weird to me 

AAngius2/5/2023
Some registrars, yeah, lure you in with low initial prices and then raise them
AAngius2/5/2023
Cloudflare will offer constant prices
AAngius2/5/2023
The registrars that offer initial discount are cool if you need a domain for some small project for a year or so
AAngius2/5/2023
But after that... they can get really expensive
AAngius2/5/2023
Google Domains is another registrar that's trustworthy and doesn't discount the first year
AAngius2/5/2023
Cloudflare is the cheapest tho
RREAPER2/5/2023
This website is just a small one which is being used by me and 2 others to select movies on 😅
RREAPER2/5/2023
So I'm thinking if it might be worth going for a 1 year domain and then just switching to a new domain name 

AAngius2/5/2023
Yeah, that would work lol
AAngius2/5/2023
Or you could try just using the IP maybe
RREAPER2/5/2023
But I'm struggling to find the prices on CloudFlare domains 

AAngius2/5/2023
Need to log in first, go to registrar in the left menu
RREAPER2/5/2023
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? 

AAngius2/5/2023
Enter domain name, press enter, will show all available TLDs and prices
AAngius2/5/2023
Yeah
AAngius2/5/2023
http://123.456.78.90
RREAPER2/5/2023
Let me try and see if that works because I'm very curious if my setup actually works 😉
RREAPER2/5/2023
To find my ip I just have to type
ifconfig
and find get the number from inet right?AAngius2/5/2023
Probably?
AAngius2/5/2023
It's the IP you use to SSH into the server
AAngius2/5/2023
Might need to add the port too
HHenkypenky2/5/2023
if you have a credit card you can get 200 bucks on azure for free, which should give you hosting for about a year
HHenkypenky2/5/2023
for free
HHenkypenky2/5/2023
they give you subdomain in the form of: foo.azurewebsites.net
HHenkypenky2/5/2023
with ssl and everything
RREAPER2/5/2023
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 😅
RREAPER2/5/2023
Slowly dying inside