For online games that aren't real-time/twitch-ey, the best way to build them is to build the game as a state machine of sorts.
You define one or more structures (objects with plain data members, NO MEMBER FUNCTIONS) for the different operations the user can take in the game.
Then, you implement the game as some interface or object or library that “loads game state from storage,” then “performs the operation described in the struct,” then “stores the result in storage” and “return the current state of the game.” (Presumably there's a “no-op” operation that just loads the state and returns its presentation.)
Playing the game will then end up being making a series of these requests, and sending them to the game runner instance. The user interface for the game ends up being rendering the game state from presentation, and helping the user construct the next request.
Once all of this works (it could start on the command line if you want,) it should be pretty easy to expose the “do this struct for game instance X” as a web service that serializes structs to/from JSON. You'd need a little bit of login/authorization, and some session state for which particular game you're current operating on, to be able to support many different players/games, and then the rest of the work is building the web page / app that lets players play the game.
If the game needs to scale, the next step up will be to make the “storage” part of the game runner be cached in memory and asynchronously flush game state back, and use state out of memory where possible (as some kind of cache,) and after that you'll want to figure out how to shard the game runner service across many servers, with game-instance based load steering, but that's all for much later. The good news is that, for turn based games, the solutions typically used by business web applications, will likely work alright for the game, too.
If your game needs direct interaction (like an interactive online game – shooter, MOBA, MMORPG, RTS, etc) then you will need very different tools and a very different setup, so knowing which kind of game you want to build ahead of time is quite helpful!
(I tried to figure out how to tag this post with “Networking and Multiplayer” as well as “For Beginners” but couldn't figure out how to make it be in both categories, but feel free to post networking/multiplayer/online/database related questions over in that forum!)