Install Laravel Valet Linux+ development environment on Ubuntu System

Harish Kumar · · 22197 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:

Laravel Facades: Simplifying Code and Improve Readability

As an integral part of Laravel, a renowned PHP framework, Facades provide a static interface to classes stored in the application's service container. They serve as static proxies (...)
Harish Kumar

What is Laravel’s Service Container and How to Use Dependency Injection in Laravel App

Dependency injection and inversion of control are vital in clean web development. They make writing maintainable, testable code possible. Laravel is a famous PHP framework that (...)
Harish Kumar

Secure Your SPA with Laravel Sanctum: A Step-by-Step Guide

In today's web development landscape, Single Page Applications (SPAs) are increasingly popular. But securing their interaction with backend APIs is crucial. Laravel Sanctum provides (...)
Harish Kumar

Multi-Authentication with Guards in Laravel

Laravel's robust authentication system provides a powerful mechanism for securing your application. To cater to scenarios where you need different user roles with distinct login (...)
Harish Kumar

Laravel Pint & VS Code: Automate Your Code Formatting

Laravel Pint is an opinionated PHP code style fixer built on top of PHP-CS-Fixer, designed to simplify the process of ensuring clean and consistent code style in Laravel projects. (...)
Harish Kumar

Laravel Clockwork: A Deep Dive into Debugging, Profiling Skills and Best Practices

In the world of web development, building complex applications often comes with the challenge of identifying and resolving performance bottlenecks. This is where a reliable debugging (...)
Harish Kumar