bash script to remove modules from httpd.conf that are not actually installed

confmodules=`cat /etc/httpd/conf/httpd.conf |grep -v ^#|grep  "modules/"|awk '{print $3}'|cut -d "/" -f 2`

for module in $confmodules; do
  echo "module=$module"
  if [ ! -f /etc/httpd/modules/$module ]; then
    linenum=`awk /"$module/{ print NR; exit}" /etc/httpd/conf/httpd.conf`
    sed -i "$linenum"s/.*// /etc/httpd/conf/httpd.conf
    echo "hey we don't have this $module in /etc/httpd/modules"

Basically the script checks all of the modules your httpd.conf tries to load.  Then it checks if the file actually exists in /etc/httpd/modules/ and if it doesn't it edits httpd.conf by removing the relevant line for the module that doesn't exist.


bash, modules, httpd, conf, installedconfmodules, etc, grep, quot, awk, module, confmodules, echo, linenum, nr, sed, fi, doesn, edits, removing, relevant,

Latest Articles

  • Linux Mint 18.2 Create Config File To Start Application Upon Login
  • Dell Wyse Thin Client BIOS Access Key
  • sudoers fle in /etc warning about comments/includes!
  • Centos 7 Reallocate logical volume space to another
  • lvm how to reduce volume size
  • letsencrypt certbot error "Unable to find a virtual host listening on port 80 which is currently needed for Certbot to prove to the CA that you control your domain. Please add a virtual host for port 80."
  • SSH error cannot Forward or Listen "bind: Cannot assign requested address"
  • X11 SSH Linux Forwarding Error
  • Using Microsoft's Group Policy Management Editor (GPME) To Change Default Permissions and Internet Explorer Security Settings
  • Thunderbird How To Disable An Email Account
  • iptables linux firewall recommended rules for public computing
  • LVM How To Create Pool (dynamically allocated and not fully allocated)
  • VMWare Pro Workstation Nic Disconnected and No IP Using NAT
  • Linux How To Create A RamDisk
  • mdadm force resync when resync=PENDING solution
  • Proxmox Breaks Storage/LVM Backing If Killing QEMU-IMG
  • Proxmox trying to acquire lock... TASK ERROR: can't lock file '/var/lock/qemu-server/lock-102.conf' - got timeout
  • Debian 9 SSH root password authentication failure password not working problem / solution
  • QEMU / KVM How To Manually Create Basic Virtual Machine VM
  • Linux wlan0 check all wireless clients