So I’ve encountered some issues with installing Laravel 5 on Fedora and finally resolved all of them. I have decided to make this blog post just for you so that I can share the knowledge and experience I have gained with you. Please note that this guide is not recommended for production purposes as I will be disabling SELinux and editing Apache configuration file.
This is a LAMP stack Laravel 5 installation guide. You will need to fulfill the following prerequisites:
- Fedora 20+ Linux Server
- 1GB RAM
- 1 CPU
- 10GB disk space
Cloudshards offers really affordable virtual private servers which fulfill the above specifications stated for just $5/monthly. So feel free to order one if you would like to. Alternatively, Openshift offers free Laravel hosting but installation steps for Openshift is not covered in this guide.
First off, we’ll need to install the necessary server software to run a web and SQL server. So, let’s begin with installing Apache, PHP and MariaDB using dnf. Login to your server via your preferred SSH terminal and run the following command.
sudo dnf install php php-pdo php-mysqlnd php-common php-mbstring php-mcrypt php-zip php-xml git httpd mariadb mariadb-server
Laravel 5 offers several ways of installation. In this guide, we’ll be doing it through composer as it offers simplicity and ease. Download and install composer.
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Run the Laravel installation using composer.
composer create-project laravel/laravel --prefer-dist
Update directory permissions and disable SELinux.
chmod 0775 bootstrap/cache chmod 0775 storage sudo setenforce 0
To disable SELinux permanently, edit your SELinux configuration file and change ‘SELINUX=enforcing’ to ‘SELINUX=disabled’.
sudo vi /etc/selinux/config
This is to allow Laravel to do the necessary writing and logging to the directories. If you ever experience blank pages on a fresh installation of Laravel, it is most likely due to incorrect permissions of your Laravel directories. Sometimes, SELinux is preventing Laravel from doing certain operations. So remember to always check your permissions if that ever happens!
Allow .htaccess rewrite so that Laravel will be able to display clean urls.
Open up your Apache configuration file and edit it
sudo vi /etc/httpd/conf/httpd.conf
Find the following line in your configuration file
<Directory /var/www/html > Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
and change it to
<Directory /var/www/html > Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
And that’s it! It’s really that simple.
If you still encounter issues with installing or running Laravel 5 on Fedora, please feel free to leave your questions in the comment section below!