How To Install Laravel on Fedora 44

Install Laravel on Fedora 44

Installing Laravel on Fedora 44 is straightforward when you set up the stack in the right order. This guide shows you how to Install Laravel on Fedora 44 with clear commands, short explanations, and the reasoning behind each step. Laravel 13 requires PHP 8.3 or newer, and Fedora 44 ships with PHP 8.5, so the platform is a strong fit for a modern Laravel setup.

If you want a clean, reliable Install Laravel on Fedora 44 setup, this tutorial walks you through the full path from system updates to a working Laravel app. It also covers the common Fedora-specific issues that many generic Linux server tutorial posts skip, especially SELinux and PHP-FPM permissions.

Prerequisites

  • Fedora 44 installed and updated.
  • A user with sudo access.
  • Internet access for package downloads and Composer dependencies.
  • Basic terminal access.
  • A domain name or local test hostname if you plan to use Nginx virtual hosts.
  • About 20 GB free disk space and at least 2 GB RAM for a smoother setup.

Step 1: Update Your System

Keeping the system current prevents package conflicts later. Fedora moves fast, so this is the safest first move before you install PHP, Nginx, or MariaDB.

Update installed packages

sudo dnf upgrade --refresh -y

This command refreshes repo metadata and updates the system to the latest package versions. Why this matters: it reduces the chance of dependency mismatches when Composer, PHP, or web server packages get installed.

Reboot if needed

sudo reboot

If the kernel or core libraries were updated, rebooting makes sure the new versions are active. That matters because web stack services should start on a stable base.

Step 2: Install Nginx

Nginx handles web traffic and passes PHP requests to PHP-FPM. It is a solid choice for Laravel because it is fast, lightweight, and works well with modern PHP apps.

Install Nginx

sudo dnf install nginx -y

This installs the web server package. Why now: Nginx must exist before you can point it at your Laravel app.

Start and enable Nginx

sudo systemctl enable --now nginx

This starts Nginx immediately and makes sure it launches at boot. That matters if you are building a real server and not just a temporary test box.

Check the service

sudo systemctl status nginx

Expected output should show active (running). If it does, the service is ready.

Open the firewall

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

This opens web traffic on ports 80 and 443. Why this is needed: even a healthy Nginx service will not respond from outside the machine if the firewall blocks it.

Step 3: Install MariaDB

Laravel needs a database for users, sessions, jobs, or your own app data. MariaDB is the standard Fedora-friendly database choice and works well with Laravel’s MySQL driver.

Install MariaDB server

sudo dnf install mariadb-server -y

This installs the database server package. Why: Laravel needs a database engine before you can create app tables or run migrations.

Start and enable MariaDB

sudo systemctl enable --now mariadb

This starts MariaDB now and on every boot. That gives your app a stable backend.

Secure the database

sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disable remote root login, and remove the test database. Why: the default install is meant to be convenient, not hardened.

Create a Laravel database and user

sudo mysql -u root -p

Then run:

CREATE DATABASE laravel_db;
CREATE USER 'laravel_user'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON laravel_db.* TO 'laravel_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

This creates a dedicated account for your app. Why: Laravel should not use the MariaDB root account. A separate user lowers risk and follows the least-privilege rule.

Step 4: Install PHP and Extensions

Laravel 13 requires PHP 8.3 or newer, and Fedora 44 ships PHP 8.5, which fits the requirement well. You also need several PHP extensions for Laravel to work correctly.

Install PHP packages

sudo dnf install php php-fpm php-cli php-common php-mbstring php-xml php-curl php-mysqlnd php-bcmath php-json php-tokenizer php-ctype php-fileinfo php-openssl php-pdo php-dom -y

This installs the PHP runtime, PHP-FPM, and the extensions Laravel expects. Why each one matters:

  • php-fpm lets Nginx send PHP requests to the PHP engine.
  • php-mysqlnd connects Laravel to MariaDB.
  • php-mbstring, php-xml, php-dom, and php-curl support common Laravel features and packages.
  • php-bcmath helps with precise numeric handling.

Start PHP-FPM

sudo systemctl enable --now php-fpm

This makes PHP processing available to Nginx. Without it, your .php files will not run.

Check the PHP version

php -v

Expected output should show PHP 8.5.x on Fedora 44. Why verify here: Composer and Laravel both depend on the correct PHP version.

Step 5: Configure PHP-FPM for Nginx

Fedora often defaults PHP-FPM to the apache user, but Nginx needs matching permissions. This step avoids permission and socket errors.

Edit the PHP-FPM pool config

sudo nano /etc/php-fpm.d/www.conf

Change these lines:

user = nginx
group = nginx

This makes PHP-FPM run under the same web user that Nginx uses. Why: if the users do not match, Nginx may fail with 502 Bad Gateway.

Restart PHP-FPM

sudo systemctl restart php-fpm

This applies the user and group change. It is required after config edits.

Optional PHP safety setting

Check cgi.fix_pathinfo in php.ini:

sudo nano /etc/php.ini

Set it to:

cgi.fix_pathinfo=0

Why: this helps prevent PHP from executing the wrong file path in some Nginx setups.

Step 6: Install Composer

Composer manages Laravel dependencies. Without it, you cannot create a project or install packages cleanly.

Download Composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

This fetches the official installer script. Why use Composer directly: the package version in repos may lag behind what modern Laravel projects expect.

Install Composer globally

php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

This puts Composer on your system PATH. Why: you want to run composer from any directory.

Verify Composer

composer --version

Expected output should show Composer 2.x. If it does, you are ready to create the Laravel project.

Step 7: Create the Laravel Project

Now you can create the application itself. This is the point where the Laravel files, vendor packages, and starter structure are generated.

Move to the web directory

cd /var/www

This keeps your app in the standard web root location. Why: it makes Nginx configuration easier and keeps files organized.

Create the project

sudo composer create-project laravel/laravel myapp

This downloads Laravel and builds a fresh project folder. Why: it creates a clean base with the right structure and dependencies.

Set ownership

sudo chown -R nginx:nginx /var/www/myapp

This gives the web server ownership where needed. Why: Laravel writes cache and log files during runtime.

Set permissions

sudo chmod -R 755 /var/www/myapp
sudo chmod -R 775 /var/www/myapp/storage
sudo chmod -R 775 /var/www/myapp/bootstrap/cache

These permissions let Laravel write to its runtime folders while keeping the rest of the code safer. Why: storage and bootstrap/cache must be writable or the app may fail.

Step 8: Configure Laravel on Fedora 44

Laravel needs a working .env file and app key before it can run properly. This is where you connect the app to the database.

Copy the environment file

cd /var/www/myapp
cp .env.example .env

This creates the active environment file from the template. Why: Laravel reads app settings from .env.

Generate the application key

php artisan key:generate

This creates a unique APP_KEY. Why: Laravel uses it to protect sessions and encrypted data.

Edit database settings

nano .env

Update these values:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=laravel_user
DB_PASSWORD=StrongPassword123!

Why use 127.0.0.1: it forces a TCP connection and often avoids local socket confusion on Linux.

Protect the .env file

chmod 640 .env

This limits who can read the file. Why: .env contains secrets like database credentials and the app key.

Step 9: Configure Nginx for Laravel

Laravel needs Nginx to point at the public directory, not the project root. That keeps the app secure and lets Laravel handle routing properly.

Create a virtual host file

sudo nano /etc/nginx/conf.d/myapp.conf

Add this config:

server {
    listen 80;
    server_name yourdomain.com;
    root /var/www/myapp/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php-fpm/www.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

Why each part matters:

  • root /var/www/myapp/public keeps private files out of the web root.
  • try_files sends requests into Laravel’s front controller.
  • fastcgi_pass connects Nginx to PHP-FPM.

Test and reload Nginx

sudo nginx -t
sudo systemctl reload nginx

This checks the syntax first, then reloads the service. Why: a broken config can take your site offline.

Step 10: Fix SELinux Permissions

This step matters on Fedora because SELinux is often enforcing by default. Many tutorials skip it, but Fedora users need it.

Check SELinux mode

sestatus

If SELinux is enforcing, you may need extra context changes for Laravel to write files.

Allow network access for web services

sudo setsebool -P httpd_can_network_connect 1

This lets web services make outbound connections. Why: Laravel may need this for APIs, mail, or queues.

Set writable file context

sudo chcon -R -t httpd_sys_rw_content_t /var/www/myapp/storage
sudo chcon -R -t httpd_sys_rw_content_t /var/www/myapp/bootstrap/cache

This gives the web process permission to write where Laravel needs it. Why: normal Linux permissions alone are not enough when SELinux blocks access.

Step 11: Run Migrations and Test the App

Now you can confirm that the whole stack works together. This is the real proof that your Install Laravel on Fedora 44 setup is correct.

Run the database migrations

php artisan migrate

This creates the default Laravel tables in MariaDB. Why: it verifies PHP, Composer packages, database login, and permissions in one command.

Open the site

Visit your domain or server IP in a browser. You should see the Laravel welcome page.

Optional CLI test

curl -I http://localhost

This shows the HTTP response headers. Why: it lets you test the site from the terminal without using a browser.

Install Laravel on Fedora 44

Troubleshooting

Here are the most common issues and how to fix them.

1. 502 Bad Gateway

This usually means PHP-FPM and Nginx are not talking correctly. Check that user = nginx is set in /etc/php-fpm.d/www.conf, then restart PHP-FPM.

2. 500 Internal Server Error

This often points to bad permissions in storage or bootstrap/cache. Reapply writable permissions and SELinux file context.

3. Database connection refused

This usually means the .env database settings are wrong. Confirm that DB_HOST=127.0.0.1, the database exists, and the user password is correct.

4. No application encryption key

This means you forgot php artisan key:generate. Run it again from the project folder, then reload the app.

5. Composer fails with PHP version errors

This usually means your PHP version is too old or extensions are missing. Check php -v and install the Laravel-required extensions again.

r00t is a Linux Systems Administrator and open-source advocate with over ten years of hands-on experience in server infrastructure, system hardening, and performance tuning. Having worked across distributions such as Debian, Arch, RHEL, and Ubuntu, he brings real-world depth to every article published on this blog. r00t writes to bridge the gap between complex sysadmin concepts and practical, everyday application — whether you are configuring your first server or optimizing a production environment. Based in New York, US, he is a firm believer that knowledge, like open-source software, is best when shared freely.

Related Posts