Okay, well, I sort of went down the rabbit hole of errors, beginning by attempting to change my newly-made directory ownerships (/var/www/documents and /var/www/projects) to the point where I’m at in the question title above. For reference, I have read the related question, but all seemed fine on that front.
Changing Directory Permissions
First, I visited this piece on GitHub and followed their instructions to chmod 701 user_home
. Files I placed in my newly-made directories above would produced a 403 error—I couldn’t read them. If I do resolve the below, this problem still remains.
Unable to Resolve Host
Since that, upon trying to sudo service nginx restart
, I’ve been getting the above host resolution error. I’m running Ghost. Now, I have an ERR_CONNECTION_REFUSED, and nothing is loading.
Server + Site Information My /etc/hosts and /etc/hostname contents are below respectively. My droplet’s name is Dizaztrous.
/etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4```
```::1 Dizaztrous Dizaztrous
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6```
/etc/hostname
`ghost`
My site is [www.fromthehiptoss.com](http://fromthehiptoss.com). The realm of server-side maintenance is something I've been barely scraping by with, and it's finally hit me now. I'll be happy to answer any questions you may have, as I'm at a bit of a loss with my site down. Thank you!
**TLDR
Sorry, I'm a bit lengthy—tried to change directory permissions and ended up downing my entire website.**
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
@Dizazter
First up, just for the sake of keeping “junk” out of your
/etc/hosts
file, the entries below can be safely removed as they do nothing at all :-).If you’re not specifically using IPv6, you can remove the rest of the IPv6 too:
In fact, the only thing you really need to define in that file is your
hostname
with and without your domain attached andlocalhost
, like so:If you’re not sure what your hostname is, you can execute the following from the CLI:
… and it’ll output what you currently have it set as. If you’d like to change it, you can use the same command and pass a new hostname to it.
With that out of the way, directories should be
chmod 755
and fileschmod 644
, though setting up these permissions won’t do any good unless your directories are owned by the user who’s executing the scripts (read: files) from said directories.Note: For the next bit, I’d recommend heading over to PasteBin and copying the requested information to a new PasteBin for each, just to keep things organized :-).
Browse to your home directory, execute the command below and save it to a PasteBin. This command simply lists the files and directories in the directory you run it from and tells us who owns them and what their permissions are set to.
Next, if you would, please post the contents of:
and
Where
yoursite.conf
is the configuration file for your website (note: you may use another directory to store configuration files – this is the default, so please feel free to substitute as needed :-) ).I’m mainly looking to see who you’re running NGINX as and to also make sure everything in both the NGINX configuration file and your website configuration file looks good so perhaps we can knock out two things at once :-).
@Dizazter
First up, just for the sake of keeping “junk” out of your
/etc/hosts
file, the entries below can be safely removed as they do nothing at all :-).If you’re not specifically using IPv6, you can remove the rest of the IPv6 too:
In fact, the only thing you really need to define in that file is your
hostname
with and without your domain attached andlocalhost
, like so:If you’re not sure what your hostname is, you can execute the following from the CLI:
… and it’ll output what you currently have it set as. If you’d like to change it, you can use the same command and pass a new hostname to it.
With that out of the way, directories should be
chmod 755
and fileschmod 644
, though setting up these permissions won’t do any good unless your directories are owned by the user who’s executing the scripts (read: files) from said directories.Note: For the next bit, I’d recommend heading over to PasteBin and copying the requested information to a new PasteBin for each, just to keep things organized :-).
Browse to your home directory, execute the command below and save it to a PasteBin. This command simply lists the files and directories in the directory you run it from and tells us who owns them and what their permissions are set to.
Next, if you would, please post the contents of:
and
Where
yoursite.conf
is the configuration file for your website (note: you may use another directory to store configuration files – this is the default, so please feel free to substitute as needed :-) ).I’m mainly looking to see who you’re running NGINX as and to also make sure everything in both the NGINX configuration file and your website configuration file looks good so perhaps we can knock out two things at once :-).
Alright, so permissions of
701
is very weird. By default in Linux systems, file permissions are644
and directories755
. But701
basically says anyone can execute but only that user can do everything. Very insecure to have a file with a7
in the permission when you don’t need it (or a1
for that matter). Basically, how you want to go about this is change those permissions back to the defaults (when they were originally created, they might’ve not all been the Linux defaults).Going from there, it depends on what your running. Could you give me an idea so I know what specific permissions sound good for it?
More information and a handy tool to learn octal “number” permissions.