beehave

Well-Known Member
Jun 26, 2005
104
0
166
HttpdCleanUp 1.0

http://www.systemabuse.com/scripts/httpdcleanup.txt

Script removes excessive blank lines from the httpd.conf file.

UPDATE: Script now also removes all redundant NameVirtualHost. It then places the NameVirtualHosts to just before the first VirtualHost. This really cleans up the file and puts an end to the VirtualHost errors when restarting apache.

Script makes a copy of file before cleaning up.

Use at your own risk! You may want to make your own backup first. I have tested on several servers and it works great. Reduces file size and load seems lower.

Looking for ideas of what else it can clean up in the httpd.conf file.

Thanks!
 
Last edited:

jefferyw18

Well-Known Member
Apr 10, 2004
45
0
156
Vancouver BC Canada
cPanel Access Level
DataCenter Provider
Ran The Script And Got

HttpdCleanUp 1.0


Backing up httpd.conf.......

.....
Backup file is /usr/local/apache/conf/httpd.conf.Sep28


Processing httpd.conf.......

.....
Done... Restarting Apache.......

httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Thu Sep 28 22:06:35 2006] [warn] NameVirtualHost 70.79.7.183:80 has no VirtualHosts
/etc/rc.d/init.d/httpd start: httpd started
 

beehave

Well-Known Member
Jun 26, 2005
104
0
166
jefferyw18 said:
Ran The Script And Got

HttpdCleanUp 1.0


Backing up httpd.conf.......

.....
Backup file is /usr/local/apache/conf/httpd.conf.Sep28


Processing httpd.conf.......

.....
Done... Restarting Apache.......

httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Thu Sep 28 22:06:35 2006] [warn] NameVirtualHost 70.79.7.183:80 has no VirtualHosts
/etc/rc.d/init.d/httpd start: httpd started
This may help: http://www.wallpaperama.com/disp-post90.html
 

beehave

Well-Known Member
Jun 26, 2005
104
0
166
Okay HttpdCleanUp 2.0 now available

Script now also removes all redundant NameVirtualHost. It then places the NameVirtualHosts to just before the first VirtualHost. This really cleans up the file and puts an end to the VirtualHost errors when restarting apache. This was not an easy task. :confused:
 
Last edited:

beehave

Well-Known Member
Jun 26, 2005
104
0
166
Okay HttpdCleanUp 3.0 now available

Script now has option of removing all comment lines. This makes for a very clean file.


I ran this script on two dual xeons with over 300 sites. The servers are over two years old so httpd.conf was pretty fragmented. These servers have not ran this good in over a year. I was happy to see the load under 1%. Now they do not go over 1%. The average that is. iowait is also way down...

http://www.systemabuse.com/scripts/httpdcleanup.txt

Please do you own backup first!
 

jefferyw18

Well-Known Member
Apr 10, 2004
45
0
156
Vancouver BC Canada
cPanel Access Level
DataCenter Provider
Ran Version 3 Here Is What I Got

Code:
HttpdCleanUp 3.0


Backing up httpd.conf.......

.....
Processing httpd.conf.......

.....sed: invalid option -- 2
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
  -i[suffix], --in-place[=suffix]
                 edit files in place (makes backup if extension supplied)
  -l N, --line-length=N
                 specify the desired line-wrap length for the `l' command
  -r, --regexp-extended
                 use extended regular expressions in the script.
  -s, --separate
                 consider files as separate rather than as a single continuous
                 long stream.
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
      --help     display this help and exit
  -V, --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

E-mail bug reports to: [email protected] .
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
sed: invalid option -- 1
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
  -i[suffix], --in-place[=suffix]
                 edit files in place (makes backup if extension supplied)
  -l N, --line-length=N
                 specify the desired line-wrap length for the `l' command
  -r, --regexp-extended
                 use extended regular expressions in the script.
  -s, --separate
                 consider files as separate rather than as a single continuous
                 long stream.
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
      --help     display this help and exit
  -V, --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

E-mail bug reports to: [email protected] .
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.

No cleanup needed at this time...

Restarting Apache just because I touched it.......

httpd: Could not determine the server's fully qualified domain name, using 192.168.2.101 for ServerName
no listening sockets available, shutting down
Unable to open logs
/etc/rc.d/init.d/httpd start: httpd could not be started

All done... You should make sure all is well.......

Backup file is /usr/local/apache/conf/httpd.conf.Sep29
 

jefferyw18

Well-Known Member
Apr 10, 2004
45
0
156
Vancouver BC Canada
cPanel Access Level
DataCenter Provider
Code:
login as: root
[email protected]'s password:
Last login: Fri Sep 29 18:59:18 2006 from 192.168.2.102
-bash: /bin/hostname: Permission denied
[email protected](none) [~]# sed -V
GNU sed version 4.0.5
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
[email protected](none) [~]#
 

kernow

Well-Known Member
Jul 23, 2004
995
42
178
cPanel Access Level
Root Administrator
I ran this script on a CentOS release 3.8 sed version 4.0.7 and got:

Code:
[email protected] [~]# ./apache_cleanup
./apache_cleanup: line 11: onintr: command not found
HttpdCleanUp 3.2
Backing up httpd.conf.......
./apache_cleanup: line 22: sp1:: command not found
../apache_cleanup: line 25: @: command not found
./apache_cleanup: line 80: syntax error near unexpected token `('
./apache_cleanup: line 80: `foreach cl ( `cat httpd.d` )'
[email protected] [~]#
 
Last edited:

beehave

Well-Known Member
Jun 26, 2005
104
0
166
kernow said:
I ran this script on a CentOS release 3.8 sed version 4.0.7 and got:

Code:
[email protected] [~]# ./apache_cleanup
./appache_cleanup: line 11: onintr: command not found
HttpdCleanUp 3.2
Backing up httpd.conf.......
./appache_cleanup: line 22: sp1:: command not found
../appache_cleanup: line 25: @: command not found
./appache_cleanup: line 80: syntax error near unexpected token `('
./appache_cleanup: line 80: `foreach cl ( `cat httpd.d` )'
[email protected] [~]#
That looks like you don't have tcsh on your server. On the top line, try reemoving the "t' so it reads "#!/bin/csh -f".
 

kernow

Well-Known Member
Jul 23, 2004
995
42
178
cPanel Access Level
Root Administrator
Hi,
Removing the "t" didn't work and "which" shows:
Code:
[email protected] [~]# which tcsh
/bin/tcsh
[email protected] [~]# which csh
/bin/csh
[email protected] [~]#
Code:
./apache_cleanup
./apache_cleanup: line 11: onintr: command not found

HttpdCleanUp 3.2


Backing up httpd.conf.......

./apache_cleanup: line 22: sp1:: command not found
../apache_cleanup: line 25: @: command not found
./apache_cleanup: line 80: syntax error near unexpected token `('
./apache_cleanup: line 80: `foreach cl ( `cat httpd.d` )'
[email protected] [~]
 
Last edited: