In this tutorial, we will show you how to install Laravel on Manjaro. Laravel is known for its elegant syntax and developer-friendly features, making it an excellent choice for building web applications. Manjaro Linux, on the other hand, offers a user-friendly and powerful environment for 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 framework on a Manjaro Linux.
- A server or desktop running one of the following operating systems: Manjaro, and other Arch-based distributions.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Laravel.
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install Laravel on Manjaro
Step 1. Before running the tutorial below, make sure that our system is up to date:
sudo pacman -Syu sudo pacman -S base-devel
Step 2. Installing PHP.
Manjaro provides PHP packages in its official repositories. You can install PHP and some common extensions using the
pacman package manager. Install PHP and required extensions for Laravel:
sudo pacman -S php php-fpm php-gd php-intl php-mbstring php-zip php-pdo php-mysql
This command will install PHP and its extensions, making them available for your Laravel project.
Enabling and configuring PHP extensions is essential for Laravel to work correctly. Open your
php.ini file for editing:
sudo nano /etc/php/php.ini
Uncomment (remove the
; symbol) or add the following lines to enable extensions:
extension=gd extension=intl extension=mbstring extension=zip extension=pdo_mysql
Save and exit the text editor.
Verify that PHP is installed by running the following command:
Step 3. Installing Composer.
Composer is a crucial tool for Laravel development, allowing you to manage project dependencies efficiently. Install Composer globally with the following command:
curl -sS https://getcomposer.org/installer -o composer-setup.php
Install Composer by running the following command:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Verify that Composer is installed by running the following command:
Step 4. Setting up a Database.
Laravel supports multiple database systems, including MySQL, PostgreSQL, SQLite, and SQL Server. For this guide, we’ll focus on setting up MariaDB, a popular choice for Laravel projects due to its performance and compatibility with MySQL.
Use the following command to install MariaDB:
sudo pacman -S mariadb
Start the MariaDB service and enable it to start at boot:
sudo systemctl start mariadb sudo systemctl enable mariadb
Run the MySQL secure installation script to enhance security:
Follow the on-screen prompts to set the root password and secure your MariaDB installation.
To create a dedicated database and user for your Laravel project, follow these steps:
sudo mysql -u root -p
Creating a new database and user:
CREATE DATABASE yourdatabase; CREATE USER 'youruser'@'localhost' IDENTIFIED BY 'yourpassword'; Grant Privileges: Grant the user full privileges over the database: GRANT ALL PRIVILEGES ON yourdatabase.* TO 'youruser'@'localhost'; FLUSH PRIVILEGES; EXIT;
Step 5. Installing Laravel on Manjaro.
Navigate to the directory where you want to create your Laravel project and run the following command:
composer create-project --prefer-dist laravel/laravel your-project-name
your-project-name with your desired project name.
Laravel uses an environment file for configuration. Duplicate the
.env.example file and name it
cp .env.example .env
Generate a unique application key using the following command:
php artisan key:generate
Next, open the
.env file in your project directory and configure your database connection settings. You can use a text editor like Nano or Vim to edit the file:
Update the following variables with your database details:
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=yourdatabase DB_USERNAME=youruser DB_PASSWORD=yourpassword
yourpassword with the database information you previously set up.
Step 6. Configuring the Web Server for Laravel.
Laravel can run on various web servers, including Apache and Nginx. Choose the one that best suits your needs. Here, we’ll provide instructions for both.
If you haven’t already, install Apache on your Manjaro system:
sudo pacman -S apache
Enable the Apache service and start it:
sudo systemctl enable httpd sudo systemctl start httpd
Create an Apache virtual host configuration file for your Laravel project. Replace
your-domain with your project’s domain or IP address:
sudo nano /etc/httpd/conf/extra/your-domain.conf
Add the following content, adjusting the paths and domain as needed:
<VirtualHost *:80> ServerAdmin email@example.com DocumentRoot "/path/to/your-project-name/public" ServerName your-domain.com ServerAlias www.your-domain.com <Directory "/path/to/your-project-name/public"> AllowOverride All Require all granted </Directory> </VirtualHost>
Enable the virtual host configuration:
sudo a2ensite your-domain.conf
Reload Apache to apply the changes:
sudo systemctl restart httpd
Step 7. Running Your Laravel Application.
Once your Laravel project is set up, you can launch it by serving it through the built-in development server. Navigate to your project directory and run:
php artisan serve
This command will start a local development server, allowing you to access your Laravel application at
http://localhost:8000 in your web browser.
Step 8. Configuring File Permissions.
File permissions are crucial for your Laravel application to function correctly. Ensure that the web server user (usually
nginx) has the necessary permissions to read and write to specific directories.
Grant write permissions to the
sudo chmod -R 775 storage
Set permissions for the
sudo chmod -R 775 bootstrap/cache
Congratulations! You have successfully installed Laravel. Thanks for using this tutorial to install the latest version of the Laravel PHP framework on the Manjaro system. For additional help or useful information, we recommend you check the official Laravel website.