How To Install Laravel on Linux Mint 21
In this tutorial, we will show you how to install Laravel on Linux Mint 21. Laravel, a robust MVC (Model-View-Controller) PHP framework, is designed for developers who need a simple and elegant toolkit to create full-featured web applications. Laravel simplifies tasks such as routing, authentication, sessions, and caching, making it highly popular among developers.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Laravel PHP web application framework on a Linux Mint 21.
Prerequisites
- A server running one of the following operating systems: Linux Mint 21.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- While we’ll guide you through the process, a basic understanding of the command line will be beneficial. If you’re new to the CLI, you might want to acquaint yourself with some fundamental commands.
- An active internet connection.
- Administrative privileges are essential for installing and configuring software on your system. Ensure that you have superuser or sudo access.
Install Laravel on Linux Mint 21
Step 1. Before installing Laravel, ensure your Linux Mint 21 system is up-to-date and has the necessary software installed.
sudo apt update sudo apt upgrade
Step 2. Installing LAMP Stack.
Laravel requires a web server, database server, and PHP to run properly. The quickest way to get these set up on Linux Mint is by installing the LAMP (Linux, Apache, MySQL, PHP) stack. Run the following commands to install LAMP:
sudo apt update sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql
Step 3. Installing Composer.
Composer is essential for managing Laravel‘s dependencies. Install Composer globally using the following commands:
curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer chmod +x /usr/local/bin/composer
Verify the installation by checking Composer‘s version:
composer --version
Step 4. Installing Laravel on Linux Mint 21.
With Composer installed, you can now install Laravel globally. This allows you to create new Laravel projects from anywhere in your system:
composer global require laravel/installer
Ensure the ~/.composer/vendor/bin
directory is in your system’s PATH so that the laravel
executable can be located by your system. Add the following line to your ~/.bashrc
or ~/.zshrc
file:
export PATH="$HOME/.composer/vendor/bin:$PATH"
Source your profile to apply the changes:
source ~/.bashrc # Or source ~/.zshrc if you are using zsh
Step 5. Create a New Laravel Project.
Now that Laravel is installed, you can create a new project using the following command:
laravel new my_laravel_project
Replace my_laravel_project
with your desired project name.
Navigate to your project directory and start the Laravel development server:
cd my_laravel_project php artisan serve
Finally, you can now access your Laravel application by visiting http://localhost:8000
in your web browser.
Congratulations! You have successfully installed Laravel. Thanks for using this tutorial to install the latest version of the Laravel PHP web application framework on the Linux Mint system. For additional help or useful information, we recommend you check the official Laravel website.