I have followed the below steps to resolve this error on my website https://code2devops.com
1. Check if Composer is Installed: Make sure Composer is installed on your server. Run:
composer -V
If Composer is not installed, you can install the composer first.
2. Run Composer Install: Navigate to your Flarum directory and run:
cd /var/www/html/flarum
composer install --no-dev
This command will install all the required dependencies and generate the vendor/autoload.php file.
3. Set Correct Permissions: Ensure that the flarum folder has the correct permissions:
sudo chown -R www-data:www-data /var/www/html/flarum
sudo chmod -R 755 /var/www/html/flarum
4. Enable Apache Rewrite Module: Flarum requires the Apache rewrite module to be enabled:
sudo a2enmod rewrite
sudo systemctl restart apache2
5. Check Apache Configuration: Update your Apache configuration file (/etc/apache2/sites-available/000-default.conf) to include the following settings:
<Directory /var/www/html/flarum>
AllowOverride All
</Directory>
Then, restart Apache:
sudo systemctl restart apache2
6. Clear Flarum Cache: Clear the Flarum cache to ensure changes take effect:
php flarum cache:clear