Installing Laravel 5 on Fedora

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

selinux

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>

httpd
It is not really recommended to edit your Apache configuration file with the above mentioned method but it is good enough for a small project.

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!

Author: Woo Huiren

Howdy, I'm a IT student who is currently pursuing a diploma at Ngee Ann Polytechnic. I do lots of things related to IT but I have an exceptionally great love for the web and opensource, so expect me to blog a lot about it! :)

5 thoughts on “Installing Laravel 5 on Fedora”

  1. Weird.. I get blank space .. I already have httpd and mysqld services installed. All required component are installed too..
    $ sudo dnf install php php-pdo php-mysqlnd php-common php-mbstring php-mcrypt php-zip php-xml git
    Last metadata expiration check performed 2:30:01 ago on Fri Mar 4 05:18:10 2016.
    Package php-5.6.18-1.fc23.x86_64 is already installed, skipping.
    Package php-pdo-5.6.18-1.fc23.x86_64 is already installed, skipping.
    Package php-mysqlnd-5.6.18-1.fc23.x86_64 is already installed, skipping.
    Package php-common-5.6.18-1.fc23.x86_64 is already installed, skipping.
    Package php-mbstring-5.6.18-1.fc23.x86_64 is already installed, skipping.
    Package php-mcrypt-5.6.18-1.fc23.x86_64 is already installed, skipping.
    Package php-pecl-zip-1.13.1-1.fc23.x86_64 is already installed, skipping.
    Package php-xml-5.6.18-1.fc23.x86_64 is already installed, skipping.
    Dependencies resolved.
    Nothing to do.
    Complete!

    my httpd configured too :

    #
    # Possible values for the Options directive are “None”, “All”,
    # or any combination of:
    # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that “MultiViews” must be named *explicitly* — “Options All”
    # doesn’t give it to you.
    #
    # The Options directive is both complicated and important. Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be “All”, “None”, or any combination of the keywords:
    # Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted

    Any idea?

    1. Hi, could you send an output of the error log? Take a look under Laravel – `storage/logs`.

      Other than that, I would also advise you to take a look at the httpd error logs (sudo tail /etc/httpd/logs/error_log).

      1. Seem issue this command solve the blank page (error code 500)
        $ cd laravel_project
        $ php artisan cache:clear
        $ chmod -R 777 storage
        $ composer dump-autoload

        I set SElinux to permissive, should be ok right?

  2. Instead of disabling SELinux or setting it to permissive, why not apply the correct tags to the storage folder? Much safer :)

    Example
    # semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/html/storage(/.*)?’

Leave a Reply