Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»PHP Framework»How to Install Laravel 8 on CentOS/RHEL 7

    How to Install Laravel 8 on CentOS/RHEL 7

    By RahulDecember 27, 20213 Mins Read

    Laravel is an open source PHP framework designed for the faster development of MVC web applications in PHP. This article will help you to install Laravel 8 PHP Framework on CentOS/RHEL 7 system.

    Advertisement

    Step 1 – Setup Yum Repositories

    First of all, you need to add REMI and EPEL rpm repositories in your system. these repositories have updated packages. Use one of the below commands as per your OS version and system architecture.

    rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-14.noarch.rpm
    rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
    

    Step 2 – Install Apache, MySQL and PHP

    Here is short instruction for the installation of LAMP stack. Its required to run the Laravel framework on your CentOS system. Use this guide for the detailed LAMP setup on CentOS

    Install Apache

    yum --enablerepo=remi,epel install httpd
    

    Install MySQL

    yum --enablerepo=remi,epel install mysql-server
    service mysqld start
    /usr/bin/mysql_secure_installation
    

    Install PHP

    yum --enablerepo=remi,epel install php php-zip php-mysql php-mcrypt php-xml php-mbstring
    service httpd restart
    

    Step 3 – Install Composer

    Composer is required for installing Laravel dependencies. So use below commands to download and use as a command in our system.

    curl -sS https://getcomposer.org/installer | php
    mv composer.phar /usr/bin/composer
    chmod +x /usr/bin/composer
    

    Step 4 – Install Laravel on CentOS 7

    To download latest version of Laravel, Use below command to clone master repo of laravel from github.

    cd /var/www
    git clone https://github.com/laravel/laravel.git
    

    Navigate to the Laravel code directory and use the composer to install all dependencies required for the Laravel framework.

    cd /var/www/laravel
    composer install
    

    Dependency installation will take some time. After that set proper permissions on files.

    chown -R apache.apache /var/www/laravel
    chmod -R 755 /var/www/laravel
    chmod -R 755 /var/www/laravel/storage
    

    SELinux enabled systems also run the below command to allow writing on the storage directory.

    chcon -R -t httpd_sys_rw_content_t /var/www/laravel/storage
    

    Step 5 – Set Encryption Key

    Laravel uses a .env file for environment configuration. Use .env file for configuring all the environment variables for your application like the database, SMTP, security key, etc.

    cp .env.example .env
    

    Now set the 32-bit long random number encryption key, which is used by the Illuminate encrypter service.

    php artisan key:generate
    
    Application key set successfully.
    

    You can view the .env file to find the Application key that is configured.

    Step 6 – Create Apache VirtualHost

    Now add a Virtual Host in your Apache configuration file to access Laravel framework from web browser. To do it edit Apache configuration file /etc/httpd/conf/httpd.conf and add below code at end of file

    vim /etc/httpd/conf/httpd.conf
    
    File: /etc/httpd/conf/httpd.conf
    <VirtualHost *:80>
           ServerName laravel.example.com
           DocumentRoot /var/www/laravel/public
    
           <Directory /var/www/laravel>
                  AllowOverride All
           </Directory>
    </VirtualHost>
    

    Restart Apache service and access the Laravel framework using your favorite web browser and start developing a great web application.

    service httpd restart
    

    Now access the Laravel website in a web browser.

    install laravel on centos

    Laravel MVC PHP php framework PHP MVC
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Installing PHP on Pop!_OS

    How to Install PHP 8.x on Pop!_OS

    Managing Dependencies with Composer: A Beginner’s Guide

    Setting up CodeIgniter on Ubuntu: A guide for web developers

    View 16 Comments

    16 Comments

    1. akho on December 22, 2021 5:06 pm

      how to install laravel fremwork version 8.5.4 on apache centos 7

      Reply
    2. nanda on August 5, 2020 9:43 am

      Thaaankss bro its worked for me several times

      Reply
    3. Paul on July 21, 2020 3:32 pm

      how to remove the /public in front of the server name?

      Reply
      • Rahul on July 22, 2020 4:28 am

        Hi Paul,

        Just point your web server DucumentRoot to the /public directory.

        Reply
    4. humphrey on July 21, 2020 12:41 pm

      Thanks @Rahul this tutorial worked for me.

      Reply
    5. Jerome on May 13, 2020 1:48 am

      After all this is done we try to create a laravel project with the command laravel new project name

      But we get -bash: laravel: command not found

      How do we make the laravel command globally available in these steps ?

      Reply
    6. restroika on April 27, 2020 1:55 am

      before step2 do this:
      1. sudo yum-config-manager –disable remi-php54
      2. sudo yum-config-manager –enable remi-php73

      because as default centos enable remi-php73

      Reply
    7. Haider on February 6, 2020 12:12 am

      Here are the link I needed to use to make install

      rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-12.noarch.rpm

      yum –enablerepo=remi,epel install mariadb-server mariadb-libs mariadb
      systemctl start mariadb.service

      Reply
    8. Oack on October 5, 2019 7:56 am

      permission denied:
      setsebool -P httpd_can_network_connect_db=1

      Reply
    9. Yan on August 26, 2019 4:49 pm

      Can’t load when call from http://laravel.example.com/

      Reply
    10. Sean S on May 31, 2017 8:43 am

      Easy CentOS 6 install of PHP 7:

      yum-config-manager –enable remi-php71
      yum update

      Reply
    11. ladi on April 8, 2016 1:25 pm

      wget git clone https://github.com/laravel/laravel.git worked for me.

      Reply
    12. ladi on April 8, 2016 1:16 pm

      git clone https://github.com/laravel/laravel.git command is not going . it shows git is command cant be find

      Reply
      • Alvaro on February 18, 2019 2:34 pm

        yum install -y git

        Reply
    13. Gilang on March 3, 2016 9:27 am

      Remi repo doesn’t have php 5.5> . in laravel versin 5, this guide will fail.
      please update to used webtatic repo also

      ## Remi Dependency on CentOS 6 and Red Hat (RHEL) 6 ##
      rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

      ## CentOS 6 and Red Hat (RHEL) 6 ##
      rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

      Reply
    14. deco on March 1, 2016 12:38 am

      Here is how I have installed php for laravel

      yum install php php-cli php-common php-gd php-imap php-mbstring php-mysqlnd php-pdo php-pecl-jsonc php-pecl-zip php-xml php-pgsql –enablerepo=epel,remi-php56

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.