brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: a2query -m rewrite tells you if an Apache module is switched on

Linux
~/tips/tip-a2query-module-status

a2query -m rewrite

Check whether an Apache module is enabled, and get a clean exit code for scripts.

A site that needs mod_rewrite fails in confusing ways when the module is off. I’d rather ask Apache than read config files.

On Debian and Ubuntu, a2query reports the state of modules. Give it a name:

a2query -m rewrite

When the module is enabled it prints something like rewrite (enabled by site administrator). When the name matches nothing, it prints No module matches and the exit code is 1, so you can use it in a script. Without a name, a2query -m lists all modules.

If the module is off, a2enmod rewrite enables it. That works by creating symlinks in /etc/apache2/mods-enabled, and the output tells you to restart Apache to activate it.

A caveat: the a2* helpers are a Debian family thing. On other distributions Apache keeps modules in different places and these commands don’t exist.

Further reading: a2enmod man page (Debian)

More Linux tips renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt flatpak uninstall --unused All Linux tips (261) All topics

Link