Search code examples
haskellweb-hostinghappstack

(How) can I host a Haskell website build on Windows on CentOS / Ubuntu?


I've built a website in Haskell (using Happstack) that I now want to host somewhere. I built it on Windows, using ghc to produce a file called website.exe. It's my first program in Haskell, and first website, but works very well when I run the .exe in Windows and type localhost:8000 into my browser.

I understand (from Q 51064865) that I need a VPS to host it, but what kind of OS do I need? I'd guess Windows, but that seems very expensive. Would my exe run on CentOS or Ubuntu? (tbh I'm not 100% sure what these are - but it seems a lot cheaper to get a VPS with them!) Can I make ghc compiler (running on Windows) generate an executable that would?

My objective is to host the website cheaply (I'm not expecting any income from it), and am open to any suggestions.

Sorry if the question is dumb/already answered somewhere.


Solution

  • Your .exe would not run on CentOS/Ubuntu without some kind of emulation. I would not recommend going down this path as it tends to run really slow in my experience. It has something to do with how thunks are allocated on Windows vs how thunks are allocated on Linux, and emulating one of them on the other is just asking for trouble.

    If you google around, you can find people talking about cross compiling Haskell from Windows to Linux, but it seems rough.

    If you want to run your website on CentOS or Ubuntu, then you should compile it on one of those distributions. If you aren't using anything that's Windows specific in your code, then you should just be able to compile your code for your target without changing anything (Haskell is much easier to work with on Linux in my experience).

    Someone else suggested downloading a "live" distro, and that would probably be the easiest way to get started compiling your code for CentOS/Ubuntu.