Laravel is a popular PHP framework that lets you build modern web apps quickly and cleanly. This tutorial walks you—step by step—through installing Laravel 5.5 on CentOS 7 with Apache and PHP 7.1. If you’d rather use the latest Laravel release (Laravel 11.x as of 2025), we’ll also cover what PHP versions you need and how to install on Ubuntu, Debian or Fedora.

Who is this for?

* You’ve seen “artisan” and “composer” but never used them.

* You know basic Linux commands like yum or apt-get.

Prerequisites

  • A CentOS 7 (64-bit) server with root or sudo access

  • Minimum 2 GB RAM (1 GB can work but may be slow)

  • A fresh install of Apache (httpd)

  • Internet access to download packages

Part 1: Installing Laravel 5.5 on CentOS 7

1. Enable EPEL & Remi Repositories

sudo yum install -y epel-release
sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm

2. Enable PHP 7.1 from Remi

sudo yum install -y yum-utils
sudo yum-config-manager --enable remi-php71

3. Install Apache, PHP 7.1 and Required Extensions

sudo yum install -y httpd php php-fpm php-mbstring php-xml php-mcrypt php-zip php-gd php-cli

4. Start and Enable Apache

sudo systemctl start httpd
sudo systemctl enable httpd

5. Install Composer (PHP Dependency Manager)

Verify with composer --version.

cd /usr/local/bin
sudo curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar composer

6. Create a Laravel 5.5 Project

By default Composer will pull the latest Laravel, so we force version 5.5:

cd /var/www
sudo composer create-project --prefer-dist laravel/laravel myapp "5.5.*"

7. Set Directory Permissions

sudo chown -R apache:apache /var/www/myapp
sudo chmod -R 775 /var/www/myapp/storage /var/www/myapp/bootstrap/cache

8. Configure Apache Virtual Host

Create /etc/httpd/conf.d/laravel.conf:

 <VirtualHost *:80>
ServerName your-domain.com
DocumentRoot /var/www/myapp/public
AllowOverride All Require all granted ErrorLog /var/log/httpd/laravel_error.log CustomLog /var/log/httpd/laravel_access.log combined

Reload Apache:

 sudo systemctl reload httpd 

Visit http://your-domain.com—you should see the Laravel welcome page.

Part 2: Installing the Latest Laravel on Other Distros

If you want Laravel 11.x or newer, you need PHP 8.1+. Below are quick commands for Ubuntu, Debian and Fedora.

Ubuntu 20.04 / 22.04 & Debian 11 / 12

  1. Add ppa:ondrej/php (for Ubuntu):

sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
  1. Install PHP 8.1+ and Extensions:

sudo apt-get install -y apache2 php8.1 php8.1-cli php8.1-fpm php8.1-mbstring php8.1-xml php8.1-zip php8.1-gd libapache2-mod-php8.1
  1. Enable Apache mods:

sudo a2enmod rewrite
sudo systemctl restart apache2
  1. Install Composer:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
  1. Create Latest Laravel Project:

cd /var/www
sudo composer create-project --prefer-dist laravel/laravel myapp
sudo chown -R www-data:www-data myapp
  1. Set up Virtual Host (similar to CentOS example, but /etc/apache2/sites-available/laravel.conf) and a2ensite laravel.

Fedora 36 / 37

sudo dnf install -y httpd php php-cli php-fpm php-mbstring php-xml php-zip php-gd composer
sudo systemctl enable --now httpd php-fpm
cd /var/www
sudo composer create-project --prefer-dist laravel/laravel myapp
sudo chown -R apache:apache myapp

Configure /etc/httpd/conf.d/laravel.conf, then

sudo systemctl reload httpd

Next Steps

  1. Environment File: Copy .env.example.env and set your database and APP_KEY.

  2. Generate App Key:

cd /var/www/myapp
sudo -u apache php artisan key:generate
  1. Database Migration (if you have migrations):

sudo -u apache php artisan migrate

Conclusion

You now have Laravel 5.5 running on CentOS 7 with PHP 7.1 and Apache—plus guidance on installing the latest Laravel versions on Ubuntu, Debian and Fedora. Whether you’re launching your first Laravel project or upgrading to Laravel 11.x, these clear steps will get you coding in no time.

If you need fast, reliable hosting for Laravel, check out our VPS Hosting or Premium Shared Hosting plans optimized for PHP frameworks and backed by expert support.

 

¿Le ha resultado útil esta respuesta? 219 Los usuarios encontraron esto útil (220 Votos)