Help a noob - getting my hugo website to work with a webserver (Apache 2)

Hey, you’ve made some good progress so far.

  • No domain name: No problem, wherever it says the domain name, substitute the IP address. If it talks about DNS anywhere, just ignore it. DNS is what converts domain names to IP addresses.

  • Site folder: When you do a Hugo build, by default, you get a folder /public that contains all the files you need Apache to serve. Either direct the hugo build command to output to the folder you want to use or simply copy/move the files.

    Note that typically, Apache installations will create /var/www as you’ve seen. You want your folder there.

    So if you have your source under ~/hugo/mysite, and use a simple hugo command to build.

    A command something like cp ~/hugo/mysite/public/ /var/www/mysite/ should be used. You might need to tweak that though, I don’t use Linux day-to-day.

    You will need to make sure that the folders and files are owned by the “user” that runs the Apache server. Typically something like www or www-data, I can’t quite remember, been a while since I used Apache.

    Something like sudo chown -R www:www /var/www/mysite should do the job.

    Finally, you will need to add something to the Apache configuration files so that it links your folder to a website it will serve. You should find those instructions online readily enough.

  • As for the last point, as mentioned, you use your public IP address - and yes, it does matter.

Without wishing too much to confuse you even more, you would be better off using NGINX rather than Apache, especially if you are using a cheap VPS for hosting since NGINX will perform a lot better than Apache with limited resources. Personally, I also find NGINX easier to configure than Apache.

1 Like