Back to lessons

Hosting Operations

Show Enabled Apache Sites

You need to see which Apache virtual host files are enabled.

Command

find fixtures/apache/sites-enabled -maxdepth 1 -type l -printf '%f -> %l\n' | sort

What changed

Nothing changes. The command lists enabled Apache site symlinks.

Danger

safe

When to use it

Use when Apache ignores a virtual host file you edited.

When not to use it

Do not remove or create symlinks from this output unless you intend to enable or disable a site.

Undo or recovery

No undo needed because this command is read-only.

Expected output

Enabled Apache site filenames and their symlink targets.

demo script

Disposable terminal steps

  1. find fixtures/apache/sites-enabled -maxdepth 1 -type l -printf '%f -> %l\n' | sort
  2. find fixtures/apache/sites-available -maxdepth 1 -type f | sort
  3. grep -RInE '

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ find fixtures/apache/sites-enabled -maxdepth 1 -type l -printf '%f -> %l\n' | sort
app.conf -> ../sites-available/app.conf
example.conf -> ../sites-available/example.conf
::exit-code::0
$ find fixtures/apache/sites-available -maxdepth 1 -type f | sort
fixtures/apache/sites-available/app.conf
fixtures/apache/sites-available/example.conf
::exit-code::0
$ grep -RInE '
fixtures/apache/sites-enabled/app.conf:2:    ServerName app.example.com
fixtures/apache/sites-enabled/example.conf:1:
fixtures/apache/sites-enabled/example.conf:2:    ServerName legacy.example.com
::exit-code::0

YouTube Short

Is the Apache site enabled?

Apache can have a perfect virtual host file that is not enabled. List the symlinks before editing more.

LinkedIn hook

The Apache config existed. The enabled symlink did not.

Question: Have you ever edited an Apache site that was not enabled?

experiments

A/B tests to run

Metric: save_rate

A: Config existed.

B: Symlink was missing.