Version v5.13.24
Environment - Ubuntu Server 24.04.4
Describe the bug
Could not sign in after upgrade to PHP 8.4. Received error 500 in the browser. I solved the problem after troubleshooting and want to share notes for others experiencing the same.
Steps To Reproduce
**** Prerequisites ****
php8.4-bcmath php8.4-intl php8.4-curl php8.4-zip php8.4-gd php8.4-xml php8.4-mbstring php8.4-mysql php8.4-fpm php8.4-mysql php8.4-lapd
**** Select php version ****
sudo update-alternatives --config php
**** update an entry and the socket link ****
/etc/nginx/sites-available/nginx-ninja.conf
client_max_body_size 20M;
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
sudo systemctl reload nginx
**** Modify both php.ini in these locations ****
/etc/php/8.4/cli/php.ini
/etc/php/8.4/fpm/php.ini
upload_max_filesize = 20M
post_max_size = 20M
memory_limit = 2G
sudo systemctl daemon-reload
sudo systemctl restart php8.4-fpm
**** Clear out the php service and restart ****
sudo systemctl stop php8.4-fpm
sudo umount -l /tmp/systemd-private--php8.4-fpm.service- 2>/dev/null || true
sudo rm -rf /tmp/systemd-private--php8.4-fpm.service-
sudo systemctl start php8.4-fpm
**** Set ownership, permissions and writeable ****
*
sudo chown -R www-data:www-data /usr/share/nginx/ninja
*
sudo find /usr/share/nginx/ninja -type d -exec chmod 755 {} ;
sudo find /usr/share/nginx/ninja -type f -exec chmod 644 {} ;
*
sudo chmod -R 775 /usr/share/nginx/ninja/storage
sudo chmod -R 775 /usr/share/nginx/ninja/bootstrap/cache
*** test if a file is accessible***
sudo touch /usr/share/nginx/ninja/storage/logs/test.log
**** Setting up local temp directories to eliminate OS based restrictions ****
sudo rm -rf /usr/share/nginx/ninja/storage/framework/cache/data/*
sudo rm -rf /usr/share/nginx/ninja/storage/framework/views/*
sudo mkdir -p /usr/share/nginx/ninja/storage/framework/cache/data
sudo mkdir -p /usr/share/nginx/ninja/storage/framework/sessions
sudo mkdir -p /usr/share/nginx/ninja/storage/framework/views
sudo mkdir -p /usr/share/nginx/ninja/storage/app/tmp
sudo chmod -R 775 /usr/share/nginx/ninja/storage
sudo chmod -R 777 /usr/share/nginx/ninja/storage/framework/views
sudo chmod -R 777 /usr/share/nginx/ninja/storage/app/tmp
sudo chown -R www-data:www-data /usr/share/nginx/ninja/storage
sudo chown -R www-data:www-data /usr/share/nginx/ninja/storage/framework/views
**** Edit the file entries ****
/usr/share/nginx/ninja/.env
APP_ENV=local // for debugging
APP_DEBUG=âtrueâ // for debugging
QUEUE_CONNECTION=database
TMPDIR=â/usr/share/nginx/ninja/storage/app/tmpâ
TEMP=â/usr/share/nginx/ninja/storage/app/tmpâ
FRAMEWORK_CACHE_DRIVER=file
VIEW_COMPILED_PATH=/usr/share/nginx/ninja/storage/framework/views
**** Edit the file entries to release restrictions or enable file writing ****
/lib/systemd/system/php8.4-fpm.service
ProtectSystem=full
ReadWritePaths=/usr/share/nginx/ninja/
**** Test script to see if the location is served to the browser and files are writeable ****
sudo editor /usr/share/nginx/ninja/public/test-write.php
** Create php file **
$dir = â/usr/share/nginx/ninja/storage/framework/viewsâ;
echo "Testing directory: " . $dir . â
â;
echo "Is writable? " . (is_writable($dir) ? âYESâ : âNOâ) . â
â;
$tmp = tempnam($dir, âtest_â);
echo "Temp file created: " . ($tmp ? $tmp : âFAILEDâ);
*
**** Clear and reconfigure artisan ****
sudo -u www-data php8.4 artisan view:clear
sudo -u www-data php8.4 artisan config:clear
sudo -u www-data php8.4 artisan optimize:clear
sudo -u www-data php8.4 artisan optimize
sudo -u www-data php8.4 artisan config:cache
**** Clear Bootstrap caches ****
sudo rm -f /usr/share/nginx/ninja/bootstrap/cache/config.php
sudo rm -f /usr/share/nginx/ninja/bootstrap/cache/services.php
sudo rm -f /usr/share/nginx/ninja/bootstrap/cache/packages.php