Simple static website
A static website is just a few html files delivered by httpd. It's safe and fast. That's a good starting point. Let's see how to host you own website.
First, create a directory to store the website :
# mkdir /var/www/htdocs/my_website
Now, copy your website html pages and files in that directory (index.html...). Just make sure httpd is able to read those files by adjusting permissions with "chmod a+r /var/www/htdocs/my_website" or setting owner :
# chown -R www:daemon /var/www/htdocs/my_website
You might change permissions later.
Now you must configure httpd to add a new section for you website. If it is served on "http://athome.tld", you'll edit "/etc/httpd.conf" file so it looks like this :
types { include "/usr/share/misc/mime.types" } server "athome.tld" { listen on * port 80 root "/htdocs/my_website" }
A few notes about the previous lines :
- "types ..." : This first line add more mimetypes to the default known by httpd. It helps clients to open the files you serve on your website with the appropriate software.
- "server "athome.tld" {" : Open a new section concerning the domain "athome.tld". As you might guess, you can serve multiple domains if you add more sections.
- "listen ..." : the server listen on every ip and interfaces ("*") on the default http port.
- "root ..." : location where are the files stored, relative to the chroot. Remember, to httpd, "/var/www" is "/".
You can now enable and start httpd :
# rcctl enable httpd # rcctl start httpd
Check http port (80) is open in your router and firewall, then check your website is reachable.
Every file you add in "/var/www/htdocs/my_website" will be served.
You can use SFTP previously described to upload your website 😉.