DEV Community

Andrew Brooks ๐Ÿ‘จโ€๐Ÿ’ป
Andrew Brooks ๐Ÿ‘จโ€๐Ÿ’ป

Posted on • Edited on

Using Laravel Valet On Linux/Ubuntu! ๐Ÿ˜ ๐Ÿ”‘

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

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)

Collapse
 
sahilkashyap64 profile image
Sahil kashyap • Edited

Also if you want to restart the apache2(I had difficulting while restarting apache)

  1. Turn off the nginx
sudo service nginx stop
  1. Then enable the apache
sudo systemctl enable apache2
  1. then
sudo systemctl start apache2  

or

sudo systemctl restart apache2  
Collapse
 
pranoysinha profile image
Pranoy Sinha

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.

Collapse
 
riliwanrabo profile image
Riliwan

is valet php.ini different from the local system's ?