Valet is an elegant way to create a local webserver for testing your Laravel applications on Mac.
Fortunately there is a fork allowing us to use Valet on a Linux based OS as well thanks to @cpriego.
Let's get started.
Helpful Links
Prerequisites
Laravel installation must be complete (see Setting Up A Laravel Local Dev Environment On Ubuntu
Ubuntu 18.04/19.04
Installing Dependencies
sudo apt-get install php7.3-curl
sudo apt-get install jq
sudo apt-get install xsel
sudo apt-get install libnss3-tools
Installing Valet
composer global require cpriego/valet-linux
test -d ~/.composer && bash ~/.composer/vendor/bin/valet install || bash ~/.config/composer/vendor/bin/valet install
Restart your terminal
Serving your project
cd
into project root and run the following command
valet park
The web URL generated will be {project_folder_name}.test
.
For example:
laravel new blog
cd blog
valet park
will provide a working URL of blog.test
Things to remember
If you have a local Apache serve running you need to disable it or your Valet URLs will lead to the Apache welcome page.
sudo systemctl stop apache2
sudo systemctl disable apache2
To un-park a project cd
into the root and run
valet forget
I'm Andrew, a full stack software developer from the deep south who makes internet things.
Hit me up on twitter @andrew_brooksie
Reach out if you have any questions or requests for future write-ups!
Top comments (3)
Also if you want to restart the apache2(I had difficulting while restarting apache)
or
Does it work on PHP8.1 on Ubuntu22.04 LTS till today, 17Feb2024. I have tried but no luck. Can anyone pls help me? TIA.
is valet php.ini different from the local system's ?