Learn how to install Laravel Framework on Rocky Linux 8 with this comprehensive guide. Follow our step-by-step instructions to set up Laravel, configure your environment, and get your development project started seamlessly. #centlinux #linux #laravel
Laravel is a popular open-source PHP framework designed for web application development. It follows the Model-View-Controller (MVC) architectural pattern, providing developers with a structured and efficient way to build robust web applications. Here are some key features and benefits of Laravel:
Overall, Laravel is a powerful and versatile framework that simplifies the process of developing modern web applications, making it a preferred choice for many developers.
There are several alternatives to the PHP Laravel framework, each with its own strengths and features. Here are some popular ones:
Each of these frameworks offers unique advantages, making them suitable for different types of projects and developer preferences.
Recommended Online Training: Laravel Database Queries – From Beginner to Highly Advanced
We are using a minimal Rocky Linux 8 virtual machine with following specifications.
By using a SSH client, connect with laravel-01.centlinux.com machine as root user.
Rebuild yum cache of enabled repositories.
# dnf makecache
Execute following command to update already installed software packages on your Rocky Linux Operating System.
# dnf update -y
If the above command updates your Linux Kernel, then you should reboot your Linux Operating System before moving forward.
# reboot
After reboot, check Linux Operating System and Linux Kernel versions as follows.
# cat /etc/rocky-release && uname -r Rocky Linux release 8.5 (Green Obsidian) 4.18.0-348.20.1.el8_5.x86_64
PHP 8.1 is the latest release of the most popular server-side programming language at the time of this writing.
PHP 8.1 is currently not available in standard yum repositories.
Therefore, you have to install Remi yum repository to grab the latest version of PHP.
Execute following command to install Remi yum repository on Rocky Linux 8.
# dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Rebuild yum cache of newly installed repositories.
# dnf makecache
Get list of available PHP modules in installed yum repositories.
# dnf module list php Last metadata expiration check: 0:00:31 ago on Sat 02 Apr 2022 10:01:23 PM PKT. Rocky Linux 8 - AppStream Name Stream Profiles Summary php 7.2 [d] common [d], devel, minimal PHP scripting language php 7.3 common [d], devel, minimal PHP scripting language php 7.4 common [d], devel, minimal PHP scripting language Remi's Modular repository for Enterprise Linux 8 - x86_64 Name Stream Profiles Summary php remi-7.2 common [d], devel, minimal PHP scripting language php remi-7.3 common [d], devel, minimal PHP scripting language php remi-7.4 common [d], devel, minimal PHP scripting language php remi-8.0 common [d], devel, minimal PHP scripting language php remi-8.1 common [d], devel, minimal PHP scripting language Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
You can now easily install PHP 8.1 by executing following command on Linux bash prompt.
# dnf module install -y php:remi-8.1
PHP composer is needed to install and configure the Laravel framework.
But before installing PHP Composer, you must also install git and unzip packages. These packages are required during PHP Composer installation.
# dnf install -y git unzip
Download and install PHP Composer by executing following command at Linux bash prompt.
# cd /tmp # curl -sS https://getcomposer.org/installer | php All settings correct for using Composer Downloading... Composer (version 2.3.3) successfully installed to: /tmp/composer.phar Use it: php composer.phar
Rename and move the composer.phar file to location that is included in your PATH variable. So you can execute composer command from anywhere. Also set execution permissions of composer file.
# mv composer.phar /usr/local/bin/composer # chmod +x /usr/local/bin/composer
Now. execute following command to check the PHP Composer version.
# composer -V Composer version 2.3.3 2022-04-01 22:15:35
Download and install Laravel Framework and dependent libraries by using composer command.
# composer global require "laravel/installer" Changed current directory to /root/.config/composer Using version ^4.2 for laravel/installer ./composer.json has been updated Running composer update laravel/installer Loading composer repositories with package information Updating dependencies Nothing to modify in lock file Installing dependencies from lock file (including require-dev) Package operations: 10 installs, 0 updates, 0 removals - Downloading symfony/process (v6.0.7) - Downloading symfony/polyfill-mbstring (v1.25.0) - Downloading symfony/polyfill-intl-normalizer (v1.25.0) - Downloading symfony/polyfill-intl-grapheme (v1.25.0) - Downloading symfony/polyfill-ctype (v1.25.0) - Downloading symfony/string (v6.0.3) - Downloading psr/container (2.0.2) - Downloading symfony/service-contracts (v3.0.0) - Downloading symfony/console (v6.0.7) - Downloading laravel/installer (v4.2.10) - Installing symfony/process (v6.0.7): Extracting archive - Installing symfony/polyfill-mbstring (v1.25.0): Extracting archive - Installing symfony/polyfill-intl-normalizer (v1.25.0): Extracting archive - Installing symfony/polyfill-intl-grapheme (v1.25.0): Extracting archive - Installing symfony/polyfill-ctype (v1.25.0): Extracting archive - Installing symfony/string (v6.0.3): Extracting archive - Installing psr/container (2.0.2): Extracting archive - Installing symfony/service-contracts (v3.0.0): Extracting archive - Installing symfony/console (v6.0.7): Extracting archive - Installing laravel/installer (v4.2.10): Extracting archive Generating autoload files 8 packages you are using are looking for funding. Use the `composer fund` command to find out more!
Composer downloads the Laravel and other libraries in ~/.config/composer/vendor/bin directory.
Therefore, to make laravel command executable from anywhere, you need to include this location in PATH variable.
# echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bash_profile
Execute .bash_profile once to load these changes.
# source .bash_profile
Now, execute following command to get Laravel version.
# laravel -V Laravel Installer 4.2.10
You have successfully install Laravel on Rocky Linux 8.
Go to your home directory and create a new Laravel project as follows.
# cd
# laravel new helloworld
_ _
| | | |
| | __ _ _ __ __ ___ _____| |
| | / _` | '__/ _` / / _ |
| |___| (_| | | | (_| | V / __/ |
|________,_|_| __,_| _/ ___|_|
Creating a "laravel/laravel" project at "./helloworld"
Installing laravel/laravel (v9.1.3)
- Downloading laravel/laravel (v9.1.3)
- Installing laravel/laravel (v9.1.3): Extracting archive
Created project in /root/helloworld
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
...
...
...
Package manifest generated successfully.
78 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
> @php artisan key:generate --ansi
Application key set successfully.
Application ready! Build something amazing.
You have successfully create a new Laravel project.
Typically, you may use a web server such as Apache or Nginx to serve your Laravel applications. If you are on PHP 5.4+ and would like to use PHP’s built-in development server, you may use the serve Artisan command.
Artisan is the command line interface included with Laravel. Artisan exists at the root of your application as the artisan script and provides a number of helpful commands that can assist you while you build your application.
Execute the following command to start Laravel development server.
# php artisan serve --host=laravel-01.centlinux.com & [1] 5727 Starting Laravel development server: http://laravel-01.centlinux.com:8000 [Sat Apr 2 22:20:46 2022] PHP 8.1.4 Development Server (http://laravel-01.centlinux.com:8000) started
Artisan default service port is 8000/tcp. Therefore, you need to allow it in Linux Firewall.
# firewall-cmd --permanent --add-port=8000/tcp success # firewall-cmd --reload success
Open URL: http://laravel-01.centlinux.com:8000/ in a web browser.
Your Laravel application server has been started successfully.
To start building some amazing application, you may read Laravel: Up & Running: A Framework for Building Modern PHP Apps 2nd Edition (PAID LINK) by Matt Stauffer.
Read Also: How to install Laravel on Rocky Linux 9
Installing the Laravel Framework on Rocky Linux 8 can seem daunting, but with the right guidance, it becomes a straightforward process. By following this guide, you should now have a fully functional Laravel environment ready for your development projects. If you encounter any issues or need further assistance, I offer professional services to help you set up and customize your Laravel projects.
Feel free to visit my Fiverr profile to check out my services and get expert help with your Laravel installation and development needs. Let’s get your project up and running smoothly!
Learn how to change Apache document root in Linux by following this step-by-step guide. Adjust…
Discover how to change Apache port in Linux easily. Follow our simple guide to modify…
Learn how to create a virtual host in Apache Server with this comprehensive guide. Set…
Discover 10 practical tasks for the RHCSA exam with step-by-step solutions. Boost your Linux skills…
Discover the ultimate Fail2ban configuration guide. Learn how to set up, customize, and optimize Fail2ban…
Explore the ultimate guide to VPS servers and learn everything about Virtual Private Servers, including…
This website uses cookies.