How do I make my iMac Apache server always run? I have a password protected Apache server running on my iMac (OS X Sierra 10.12.1) at home for personal purposes. It is accessible by the internet so that I can access my home files when I am outside my home.

I have configured settings on my iMac so that I can lock the screen without making it go into sleep mode. However the web server still doesn't always run. When I try to access it from outside home, it only works about half of the time. I know that my home network being down etc. is not the issue, because connecting to my VPN server running on my Mac mini on the same network always works.

I understand that making an iMac web server always accessible might be problematic, but if anyone know how to solve this or improve the uptime just a little bit I would be very grateful.
so that I can access my home files when I am outside my home


If this is all you really want to do then you are using the wrong tool. 

Go to System Preferences -> Sharing and enable File Sharing.
Then go to Options (same panel) and check the AFP box.
Then forward port 548 on your router.

You can now access your files from the Finder ( Go -> connect to server) with read-write access instead of download only.