Install Laravel Valet Linux+ development environment on Ubuntu System

Harish Kumar · · 24932 Views

The official Laravel Valet development environment is great if you are an Apple user. But there is no official Valet for Linux or Window system.

But we have two different versions of the Valet for Linux system created by the community. These are:

  1. cpriego/valet-linux (Valet Linux)

  2. genesisweb/valet-linux-plus (Valet Linux+)

If we compare both, Valet Linux+ has more features. For example, it provides MySQL database handling from command-line, MailHog, Redis, Sharing Sites on LAN, Securing Sites With TLS (HTTPS), etc.

So, In this article, I will show you how to install valet-linux-plus in your Ubuntu system. 

Requirements

  1. Ubuntu 14.04+

  2. PHP 7.1+

  3. PHP extensions: php-cli php-curl php-mbstring php-mcrypt php-xml php-zip

If you are on Ubuntu 14.04, then you need to add the Nginx PPA because the version in the Trusty repos does not support http2. And http2 is required if you want to use the valet secure command.

Run this command to add the Nginx PPA, if you are on Ubuntu 14.04 or below:

sudo add-apt-repository -y ppa:nginx/stable
sudo apt-get update

Install dependencies packages

sudo apt-get install network-manager libnss3-tools jq xsel

Install PHP & it's extensions

Currently, the latest version of PHP is v8.0. So, I will install PHP 8. For that first, we need to add PPA for PHP 8. 

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

Install PHP8

sudo apt install php8.0-fpm

Install PHP Extensions:

sudo apt install php8.0-cli php8.0-common php8.0-curl php8.0-mbstring php8.0-opcache php8.0-readline php8.0-xml php8.0-zip php8.0-mysql php8.0-gd

Install MySql Server

Valet Linux+ automatically installs the MySql server. But sometimes, it gives an error on MySQL installation via valet install command. So, I recommend installing the MySql server first before starting the installation of the valet.

So, to install the MySql server run the following command:

sudo apt-get -y install mysql-server

Once it is installed, run the following command and follow the instructions:

sudo mysql_secure_installation

By default, we need sudo privileges to gain access to the root MySQL user.

That, we need to change. We will use the mysql_native_password plugin to authenticate the root MySQL user. For that run the following commands on the terminal:  

# login MySQL
sudo mysql

In the MySQL shell, update root password with mysql_native_password plugin:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

mysql> FLUSH PRIVILEGES;
mysql> exit;

From now, we can log in to MySQL using the following command:

mysql -u root -p

The -p flag will prompt you for your MySQL user’s password to authenticate.

Install Composer 

To install Composer, we will use curl. So, make sure in your system curl is installed, and you can install curl using the following command:

sudo apt install curl

Now, run the following command to install Composer:

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Now composer is installed, verify it by checking its version:

composer --version

Install Valet Linux+

Finally, require the package to install Valet Linux Plus:

composer global require genesisweb/valet-linux-plus

Now add the export PATH="$PATH:$HOME/.composer/vendor/bin" or export PATH="$PATH:$HOME/.config/composer/vendor/bin" to ~/.bash_profile or ~/.bashrc or ~/.zshrs.

Restart your terminal and run the valet install command.  

valet install

This will configure and install Valet Linux+, Nginx, MySql, Redis, Mailhog, and DnsMasq. It also registers Valet's daemon to launch when your system starts.

Once Valet Linux+ is installed, try pinging any *.test domain on your terminal.

ping -c1 foobar.test

If Valet Linux+ is installed correctly you should see this domain responding on 127.0.0.1. If not you might have to restart your system.

After completion of Valet Linux+, you’ll get all the Valet features including parklink, and status, etc.

For more information check out the Valet Linux+ documentation.

1

Please login or create new account to add your comment.

1 comment
SilasWorx
SilasWorx ·

Bro... thanks for this. Works perfect.

You may also like:

Building a Real-Time Chat App with Laravel Reverb and Nuxt 3

Building a real-time chat application is a great way to understand the power of WebSockets and real-time communication. In this tutorial, we will walk through creating a Real-Time (...)
Harish Kumar

How to Set Up Nuxt 3 Authentication with Laravel Sanctum (Step-by-Step Guide)

In modern web development, securing your application’s authentication process is a top priority. For developers building Single Page Applications (SPA) or Server-Side Rendered (...)
Harish Kumar

Essential Linux Command Line Cheatsheets for Beginners and Advanced Users

The Linux command line is a powerful tool for managing your system efficiently. Whether you're a beginner exploring the terminal or an advanced user handling complex tasks, cheatsheets (...)
Harish Kumar

Laracon US 2024: Laravel 11 Minor Features That Enhance Performance

At Laracon US 2024, Taylor Otwell and the Laravel team introduced a series of "minor" features for Laravel 11 that are anything but minor. These enhancements, while not headline-grabbing (...)
Harish Kumar

PHP OPCache: The Secret Weapon for Laravel Performance Boost

OPCache, a built-in PHP opcode cache, is a powerful tool for significantly improving Laravel application speed. This guide will demonstrate how to effectively utilize OPCache to (...)
Harish Kumar

How to Use DTOs for Cleaner Code in Laravel, Best Practices and Implementation Guide

When developing APIs in Laravel, ensuring your responses are clear, concise, and consistent is crucial for creating a maintainable and scalable application. One effective way to (...)
Harish Kumar