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:
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.
- Ubuntu 14.04+
- PHP 7.1+
- 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
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:
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.
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:
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.
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 park, link, and status, etc.
For more information check out the Valet Linux+ documentation.