Skip to content

Service

Description

With the service command you are able to define the state (enabled/disabled) of an installed service and set the default version for services that support multiple parallel versions (e.g. PHP, Elasticsearch, MySQL).

The command only operates on services that are currently installed - use install/uninstall to add or remove a service before managing its state here.

Information

All changes are "install" stable. This means "valet.sh install" will not override your state or default settings.

To reduce the load on your system, its makes sense to stop all services you don't need!

Overview

list

This command lists all currently installed services (essential and optional) in a table with the columns Type, Name, Default and Autostart, so you can see at a glance which services are installed, which one is the default per family (e.g. which PHP or MySQL version), and whether autostart is enabled.

valet.sh service list

To identify which services are currently started or stopped, you can query the underlying runtime directly. The data services run as containers, everything else runs natively:

Services macOS Ubuntu
MySQL, MariaDB, Elasticsearch, OpenSearch, Redis, Valkey, RabbitMQ, Mailpit container list --all podman ps or systemctl --user list-units 'vsh-*'
PHP-FPM brew services list systemctl status php8.3-fpm
Nginx, dnsmasq sudo brew services list systemctl status nginx

Note

On Ubuntu the containers are started by systemd user units and are removed again when they stop, so podman ps only ever shows the services that are currently running

enable

start the service and put in autostart

valet.sh service enable mysql80

disable

stops the service and remove from autostart

valet.sh service disable mysql80

start

start the service, but it will not change the behavior for autostart

valet.sh service start mysql80

stop

stop the service, but it will not change the behavior for autostart

valet.sh service stop mysql80

restart

restart the service, but it will not change the behavior for autostart

valet.sh service restart mysql80

Note

Since 2.6.3 `valet.sh service restart all restarts all enabled services!

default

set a default version for a service. Any service that supports multiple parallel versions is "defaultable" - that's every service configured with a versions array in valet.sh's bundle definitions (currently PHP, MySQL, MariaDB, Elasticsearch, OpenSearch, Redis, Valkey and RabbitMQ).

valet.sh service default mysql80

  • PHP: setting a default php only changes the default php on cli. You can still use any other installed PHP versions by appending the version number, e.g. "php7.0"
  • Elasticsearch: the default elasticsearch is listening on port 9200. You can still use any other installed Elasticsearch version by accessing the version specific port (see Elasticsearch service documentation)
  • MySQL: changes the default mysql command on cli and the version listening on port 3306. You can still access any other installed MySQL versions by appending the version number, e.g "mysql5.7", or using the version specific port (see MySQL service documentation)
  • Redis/Valkey: changes which version the plain redis-cli/valkey-cli commands connect to. You can still access any other installed version via its version specific cli command, e.g "valkey8-cli", or its version specific port (see Redis service documentation)

Warning

Setting the default version to a disabled service will not change the state of it! You have to enable the service if you want to use it