From 31f44818e76bfaf76ea561545dededa5eeb6b64e Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Mon, 1 Nov 2021 12:45:15 +0100 Subject: [PATCH] Update README.md --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.md b/README.md index e9fcd58..5df3583 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,44 @@

www.victorwesterlund.com

The source code for victorwesterlund.com

+

How to install

+

This guide is for Unix-based systems with NGINX, PHP 8.0 and MariaDB installed and configured.

+
    +
  1. Clone this repo.
    git clone https://github.com/VictorWesterlund/victorwesterlund.com /var/www
  2. +
  3. Expose the directory /public to the web.
    This can be done in multiple ways, but an NGINX location block or symlink should do the trick.
  4. +
  5. Rewrite api.php to api/*.
    All requests to example.com/api/* should be routed to the PHP file at /public/api.php.
    Just like the previous step, this can be done in multiple ways. Here is one way with an NGINX location block:
    +
    location ~ /api/* {
    +     try_files /public/api.php =503;
    +     include snippets/fastcgi-php.local.conf;
    +     fastcgi_pass unix:/run/php/php8.0-fpm.sock;
    +}
  6. +
  7. Add support for the .mjs extension.
    NGINX doesn't have an entry for the ECMAScript module (.mjs) file extension in its default /etc/nginx/mime.types file. We need to add this manually:
    +
    +types {
    +     ...
    +     application/javascript                js mjs;
    +     ...
    +}
    +
    PS: If you want to make your Content-Type WG compliant, replace application/javascript with text/javascript
  8. +
  9. Import the standard structure to a MariaDB database.
    A MySQL-compatible .sql can be downloaded here and imported into a database with this command:
    mysql -u username -p database_name < db_structure.sql
    You will have to create an empty database if you don't have one already.
  10. +
  11. Add your MariaDB connection details to /src/database/config.json.
    You can add as many fallback servers as you want +
    +{
    +  "servers": [
    +      {
    +         "host": "db.example.com",
    +         "user": "mysql_user",
    +         "pass": "mysql_pass",
    +         "db": "mysql_db"
    +      },
    +      {
    +         "host": "fallback.db.example.com",
    +         "user": "mysql_user",
    +         "pass": "mysql_pass",
    +         "db": "mysql_db"
    +      }
    +  ]
    +}
    +
  12. +
+

That was a lot, but now we're done! Navigate to the location you exposed in step 2 and cross your fingers 🤞