Repository navigation
Preparing the Server
This page installs everything KeyAnyWhere needs on a fresh Debian 13 server: Apache with PHP 8.4, Composer, Git and PostgreSQL. Then it creates the database and the database user the application will use. At the end, the server is ready to receive the code.
You need a Debian 13 server where you can run sudo, and the decisions from the Production Overview made.
This step installs the web server, PHP with the extensions KeyAnyWhere uses, the tools to download the code and PostgreSQL.
sudo apt updatesudo apt install -y apache2 libapache2-mod-php8.4 php8.4-cli php8.4-intl php8.4-mbstring php8.4-pgsql php8.4-xml php8.4-zip composer git unzip acl postgresqlTurn on the Apache modules for URL rewriting, HTTPS and security headers:
sudo a2enmod rewrite ssl headersKeyAnyWhere needs PHP 8.4 or later with the extensions listed in Requirements. This command prints the version and any required extension that is missing:
php -r 'echo PHP_VERSION, PHP_EOL; foreach (["intl","mbstring","pdo_pgsql","sodium","openssl","iconv","json","xml"] as $e) { if (!extension_loaded($e)) echo "MISSING: $e", PHP_EOL; }'The output should be just the version, for example:
8.4.16
The application connects to PostgreSQL with its own user, which owns only the KeyAnyWhere database. This step creates both, with a password you type (it is not shown and not saved in your shell history).
sudo -u postgres createuser --pwprompt kawsudo -u postgres createdb --owner=kaw --encoding=UTF8 keyanywhereKeep this password at hand: it goes into the environment file in Environment Variables.
Tip
For more hardening of PostgreSQL in production (listening addresses, pg_hba.conf, backups), the post PostgreSQL em produção (in Portuguese) is a good complement.
Connect to the new database with the new user, over TCP like the application will. Type the password when asked:
psql "host=127.0.0.1 dbname=keyanywhere user=kaw" -c 'SELECT current_user, version();'The output shows kaw and the PostgreSQL version.
KeyAnyWhere requires an encrypted connection to PostgreSQL (sslmode=require) and refuses a server without SSL. Debian's package turns SSL on by default, with a self-signed certificate. Check it:
psql "host=127.0.0.1 dbname=keyanywhere user=kaw" -tAc 'SHOW ssl;'The answer must be on. If it is off, see Troubleshooting.
Source code · Issues · Releases · Packagist · Online demo · Hosted edition
1. Getting started
2. Installing in production
- Overview
- Preparing the Server
- Installing KeyAnyWhere
- File Permissions
- Generating Security Keys
- Environment Variables
- Configuration Files
- Database Setup
- Insecure Password Catalog
- Web Server and HTTPS
- First-Run Setup
3. Operating your installation
4. Using KeyAnyWhere
5. Security
6. Development
7. Extending