Install Laravel On Manjaro/Arch Linux

Laravel, written in PHP, is a popular MVC framework for developing web applications. The PHP framework makes it easy to develop dynamic web apps with powerful built-in tools such as database systems, routes, controllers, authentication systems, and a lot more.

Laravel is an open-source PHP web framework. It was first released in June 2011. With each new release, Laravel makes it easier to implement complicated features without wasting too much time. From scaffolding to providing helper methods to build advanced features such as authentication, Models for making database queries, controllers to write request logic, and Views to render blade templates or even supports Inertia for building frontend with React or Vue.

Currently, Laravel 8.x is the latest release. For a quick start, Laravel provides Laravel Breeze (optional) to scaffold the entire authentication system that includes login, register, and a password reset system.

If you are a PHP developer, Laravel is a genie for you. The huge community and well-explained documentation are always there if one needs any help. To further save time in coding popular features, search for packages already coded by somebody in the community. Use Packalyst, a huge directory to find Laravel packages built by the community. From interacting with a third-party API to implementing different authentication systems, multiple packages are available for all kinds of needs.

Install Laravel on Manjaro/Arch Linux

If you are using Manjaro to develop Laravel applications, here is how you can install Laravel on Manjaro, Arch Linux, or any other Arch-based system.

If you’re using an Ubuntu-based system, please follow this guide.

Prerequisites

  • Apache or Nginx
  • PHP >= 5.3
  • Database (mysql, MariaDB, etc.)
  • Install Composer (PHP package manager)

For this article, I am going to use Apache, PHP 8, and Mysql for Laravel.

Install PHP and Apache web server

Let’s first install and set up Apache and PHP.

sudo pacman -S php php-apache

Enable PHP Extensions

For Laravel to function properly, enable the following extensions from the php.ini file.

sudo nano /etc/php/php.ini

To enable an extension, first find the line in php.ini where the extension is mentioned. Press ‘CTRL+W‘ and type the extension name.

First, find and enable bcmath. To enable it, remove; from the line.

Similarly, enable zip extension. Search zip and remove; from the line.

Install MySQL

sudo pacman -S mariadb

Once the installation is successful, run the following command –

sudo systemctl start mysqld

If you get the following starting MySQL daemon –

Job for mariadb.service failed because the control process exited with error code.
See “systemctl status mariadb.service” and “journalctl -xe” for details.

Then initialize your MySQL directory using the following command –

$ sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Now start MySQL and run mysql_secure_installation to secure the installation of MySQL.

sudo systemctl start mysqld
sudo mysql_secure_installation

Install Composer

Composer is a PHP package manager. We’ll use composer to install Laravel and the required packages.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php --install-dir=/bin --filename=composer

Install Laravel

Finally, install Laravel. The following command will install the latest version of Laravel.

composer global require laravel/installer

Export path variables.

echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc
source ~/.bashrc

Next, run the Laravel command in the terminal, and Voila!

Create new Laravel application

laravel new application_name

If you want to configure authentication scaffolding, install Larave UI. For more in-depth tutorials on setting up Laravel to build the frontend with react or any other frontend framework, head over to this documentation.

If you run into issues, let me know in the comment section below this article. Or, join our Discord server for more help or join our Telegram channel for notifications of the latest articles.