Encryption is hardly the right approach to this problem. If only the webserver should have access to the database, then simply set the file permissions accordingly (e. g. 0600 with the webserver being the file owner). If you need fine-grained access control for multiple websites, use a “real” database system like PostgreSQL or MySQL; SQLite wasn’t made for this scenario.
Mcrypt is also a bad choice, because it’s a low-level library with dozens of pitfalls. Unless you’re an expert cryptographer (which you obviously aren’t), you should stay away from it. Use a high-level library like libsodium. But again: Encryption isn’t the right approach to begin with.