I set up website hosting for a friend – this time using nginx. This was set up in a similar fashion to Caddy except I installed nginx instead of Caddy.
The challenge was to get it shoehorned into one of Google Cloud Engine’s e2-micros. Most of the site was static so could be served from Cloudflare, but there were too many images so I decided to offload them onto an AWS bucket and mount using s3fs fuse. Unfortunately s3fs is very slow and searching for alternatives I happened upon JuiceFS.
In common with a lot of open source projects they offer a community edition which can be used for free and is extensively documented here: https://juicefs.com/docs/community/introduction/
Installation is detailed here: https://juicefs.com/docs/community/getting-started/installation and I installed via their PPA:
sudo apt install software-properties-common sudo add-apt-repository ppa:juicefs/ppa sudo apt install juicefs sudo ln -s /usr/bin/juicefs /usr/local/bin/
I then formatted my aws s3 storage using: https://juicefs.com/docs/community/getting-started/standalone#hands-on-practice-2
# Replace relevant options with the actual object storage being used
juicefs format --storage s3 \
--bucket https://myjfs.s3.us-west-1.amazonaws.com \
--access-key ABCDEFGHIJKLMNopqXYZ \
--secret-key ZYXwvutsrqpoNMLkJiHgfeDCBA \
sqlite3://myjfs.db myjfs
Unfortunately sqlite kept crashing so I installed redis for the metadata storage. Fortunately you can reconfigure your metadata storage without having to reformat s3: https://juicefs.com/docs/community/metadata_dump_load#recovery-and-migration
apt install redis-server juicefs dump sqlite3://myjfs.db meta-dump juicefs load redis://127.0.0.1:6379 meta-dump juicefs config --storage s3 --bucket https://myjfs.s3.us-west-1.amazonaws.com --access-key ABCDEFGHIJKLMNopqXYZ --secret-key ZYXwvutsrqpoNMLkJiHgfeDCBA redis://127.0.0.1:6379
It can generate an fstab entry which is nice:
juicefs mount --update-fstab --cache-size 2048 --cache-partial-only redis://127.0.0.1:6379 /var/www/html/wordpress/wp-content/uploads/