diff --git a/README.md b/README.md index 1a0bc48..5123107 100755 --- a/README.md +++ b/README.md @@ -1,46 +1,41 @@
-

www.victorwesterlund.com

-

The source code for victorwesterlund.com

+

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 /src/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 /src/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 🤞

+ +## Local installation + +If someone for whatever reason want to set up their own environment of this. Here's how you do so assuming you have [NGINX](https://nginx.org/en/) up and running: + +1. **Clone this repo** + +``` +git clone https://github.com/VictorWesterlund/victorwesterlund.com +``` + +2. **Create an NGINX site config** + + Create and enable a new site + server config with the `root` pointed to the **/public** folder inside the repo. + +3. **Add support for `.mjs`** + + I'm using the hyped .mjs extension for the ES modules and NGINX does not serve the correct MIME-type for these yet. + + Open **/etc/nginx/mime.types** with your text editor of choice and add `mjs` to the `application/javascript` MIME-type. Save and exit. + + ``` + types { + ... + application/javascript js mjs; + ... + } + ``` + *Psst: if you shiver at the sight of JS using another type than your HTML:s and CSS:ess (you are my kind of nerd), replace **application/javascript** with **text/javascript** and remain [WHATWG compliant](https://mimesniff.spec.whatwg.org/#javascript-mime-type)😚* + +4. **Fire up NGINX with the new config** + + Verify that your changes are valid and restart NGINX. Hop over to your browser and navigate to your set endpoint - fingers crossed 🤞 + ``` + nginx -t + sudo systemctl restart nginx + ```