Alright, so I had this in my drafts for quite a bit now. Note that by drafts I mean it was written almost entirely on a notebook without really passing it over to here — don't worry, I won't reuse the draft, since it was meant for the rewrite of my other site (of which I didn't finish). I'll still provide somewhat nice examples you can use.
Before I forget! The jail(8) configuration
files for this site are provided over on [here]
if you want to see them. Those reading from Codeberg probably
won't get a directory listing, but the source should include
them. Another note: this page will tell how I set up a
nginx jail(8) in order to use it
properly in here.
So, essentially, what we'll do is: one; set up a few directories
for usage with the jail.conf(5) file:
# mkdir -p /www/site /usr/jails/nginx # I actually use /repositories, but choose whatever. # Oh, this too: you can use /usr/local/jails too, I believe. # pw group mod www -m myneatuser # The above is so you can edit any jail files, as per the below command: # chown -R root:www /www /usr/jails # And, after you added your files, so the webserver doesn't complain: # find /www -type f -exec chmod 664 ';' # find /www -type d -exec chmod 775 ';' # Do take in mind that it will make anything readable by the user! `chmod` any file you'd like to have no others permisson!So now you set the file structure up! We'll also use
nullfs(4) from now on, so check if your machine supports it
or not. Usually, though, it should.
Now it is the jail(8) structure. Since I like things small, we'll have to set up a manual master.passwd(5)
and then generate the required files with pwd_mkdb(8). Note that this command is very harsh, so make sure you pass the
correct options (otherwise you will overwrite your system passwd(5) files):
# cd /usr/jails/nginx # mkdir bin dev etc srv # ln -s bin sbin # cd etc; $EDITOR master.passwd root:*:0:0::0:0::/root:/bin/nologin www:*:80:80::0:0::/srv:/bin/nologin # chmod 400 master.passwd # pwd_mkdb -d . master.passwd # Make sure -d always points here! If not present, it overwrites the files in /etc!
Now we have to actually install the web server, of which will be freenginx:
$ git clone --depth=1 https://github.com/freenginx/nginx $ cd nginx $ ./auto/configure --user=www --group=www \ --prefix=/usr/jails/nginx/srv \ --sbin-path=/usr/jails/nginx/sbin \ --with-ld-opt=-static $ make # make installThat should install all the files over to the
/usr/jails/nginx directory, making you (hopefully) able
to start it via service jail start nginx (guessing you set up the /etc/jail.conf already, that is).