The issue
This is more of a general feedback post. I resolved my issues but I feel that what I went through could have been avoided had I known several crucial details. I also have questions as to why certain things are they way they are.
To start: I am using Laravel Forge as the server environment (which I figured wouldn't be a problem since Flarum is supposedly based on it and symfony). VPS is a DigitalOcean 1vcpu/1GB/25GB.
Issues:
- Lots of issues related to missing directories. The php-fpm user is the owner of the root folder where flarum is installed (and all subfolders) with 775 perms as indicated in the docs by running
chmod 0755 -R <dir>
public/assets
, storage/cache
, storage/formatter
, storage/sessions
all had to be created manually because for some reason Flarum would not even attempt to create them. Does Flarum just not try to create these folders? Why not? I have no issues creating directories with Laravel in the exact same environment setup.
- if the above dirs are required to function, why not simply create them. Or a least list them as required in the installation docs.
- Very confusingly, I ran the install via the browser and was automatically logged in (somehow) but could not log out without clearing cookies.... but then I couldn't log back in. All routes complained of CSRF token mismatch, which I think ended up being the
storage/sessions
dir not existing. That said, the expiration of my flarum_session
cookies were at the exact time of the initial page request, so I also updated PHP's timezone to be "America/New_York" as well. I'm not sure which change (or perhaps it was both) fixed this issue.
Some of these issues were likely caused by git not adding empty dirs to the repo when I pushed, however I feel that directories existing is not a safe assumption to make in an application.
I did modify the Forge deploy script as following. This should take care of most of the issues (aside from possible TZ issue) that I encountered.
cd /home/forge/redacted.example.com
git pull origin $FORGE_SITE_BRANCH
$FORGE_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader
( flock -w 10 9 || exit 1
echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock
mkdir -p public/assets
mkdir -p storage/{cache,formatter,less,locale,logs,sessions,tmp,views}
chmod 775 -R ./
if [ -f flarum && -f config.php ]; then
$FORGE_PHP flarum migrate
$FORGE_PHP flarum cache:clear
fi
Questions:
- Why doesn't
php flarum migrate
exist until flarum is installed? I think it would be a better approach for new users to be told that you can't migrate until it's installed and a) please visit your site url to install or b) run php flarum install
instead of just complaining that it's not a command. I thought I had missed something after the composer create-project
instruction.
Flarum information
Flarum core: 1.8.9
PHP version: 8.3.17
MySQL version: 8.0.41-0ubuntu0.24.04.1
Loaded extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, random, Reflection, SPL, session, standard, sodium, mysqlnd, PDO, xml, bcmath, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, gmp, iconv, igbinary, imagick, imap, intl, exif, msgpack, mysqli, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, readline, shmop, SimpleXML, soap, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, memcached, redis, swoole, Zend OPcache
+----------------------+---------+--------+
| Flarum Extensions | | |
+----------------------+---------+--------+
| ID | Version | Commit |
+----------------------+---------+--------+
| flarum-flags | v1.8.2 | |
| flarum-approval | v1.8.2 | |
| flarum-tags | v1.8.3 | |
| flarum-suspend | v1.8.4 | |
| flarum-subscriptions | v1.8.1 | |
| flarum-sticky | v1.8.2 | |
| flarum-statistics | v1.8.1 | |
| flarum-mentions | v1.8.5 | |
| flarum-markdown | v1.8.1 | |
| flarum-lock | v1.8.2 | |
| flarum-likes | v1.8.1 | |
| flarum-lang-english | v1.8.0 | |
| flarum-emoji | v1.8.1 | |
| flarum-bbcode | v1.8.0 | |
+----------------------+---------+--------+
Base URL: https://redacted.example.com
Installation path: /home/forge/redacted.example.com
Queue driver: sync
Session driver: file
Mail driver: mail
Debug mode: ON