PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, September 20, 2022

[FIXED] How to disable all apache virtual hosts?

 September 20, 2022     apache, virtualhost     No comments   

Issue

I'm writing a shell script to do some web server configuration. I need to disable all currently active virtual hosts. a2dissite doesn't accept multiple arguments, so I can't do

a2dissite `ls /etc/apache2/sites-enabled`

Should I use find? Is it safe to manually delete the symlinks in /etc/apache2/sites-enabled?


Solution

Is your script Debian only? If so, you can safely delete all the symlinks in sites-enabled, that will work as long as all sites have been written correctly, in the sites-available directory.

For example:

 find /etc/apache2/sites-enabled/ -type l -exec rm -i "{}" \;

will protect you against someone who has actually written a file instead of a symlink in that directory.

(remove the -i from rm for an automatic script, of course)



Answered By - Vinko Vrsalovic
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing