The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Httpd Clean Up 1.0

Discussion in 'General Discussion' started by beehave, Sep 28, 2006.

  1. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    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!
     
    #1 beehave, Sep 28, 2006
    Last edited: Apr 19, 2007
  2. jefferyw18

    jefferyw18 Well-Known Member

    Joined:
    Apr 10, 2004
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    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
     
  3. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    This may help: http://www.wallpaperama.com/disp-post90.html
     
  4. bigger_travis

    bigger_travis Registered

    Joined:
    Mar 10, 2005
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
  5. jugo

    jugo Active Member

    Joined:
    Nov 23, 2005
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    Have it clean up all the comments...
     
  6. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    That is a good idea...
     
  7. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    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:
     
    #7 beehave, Sep 29, 2006
    Last edited: Sep 29, 2006
  8. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    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!
     
  9. jefferyw18

    jefferyw18 Well-Known Member

    Joined:
    Apr 10, 2004
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    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: bonzini@gnu.org .
    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: bonzini@gnu.org .
    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
    
     
  10. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    3.1 also tells you how many lines were removed.
     
  11. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    jefferyw18, I have ran it on four servers now and do not get the sed error. What os is the server?

    You also need to restore the file and restart apache.
     
  12. jefferyw18

    jefferyw18 Well-Known Member

    Joined:
    Apr 10, 2004
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Vancouver BC Canada
    cPanel Access Level:
    DataCenter Provider
    Redhat Linux 9
     
  13. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    What does the following command give you:

    sed -V
     
  14. jefferyw18

    jefferyw18 Well-Known Member

    Joined:
    Apr 10, 2004
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Vancouver BC Canada
    cPanel Access Level:
    DataCenter Provider
    Code:
    login as: root
    root@192.168.2.101's password:
    Last login: Fri Sep 29 18:59:18 2006 from 192.168.2.102
    -bash: /bin/hostname: Permission denied
    root@(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.
    root@(none) [~]#
    
     
  15. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    Okay 3.2 should fix that for you. Could you please upgrade and try again?

    Thanks!
     
  16. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    I ran this script on a CentOS release 3.8 sed version 4.0.7 and got:

    Code:
    root@moonlight [~]# ./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` )'
    root@moonlight [~]#
     
    #16 kernow, Sep 30, 2006
    Last edited: Sep 30, 2006
  17. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    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".
     
  18. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    Or try...

    which tcsh
    which csh
     
  19. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    865
    Likes Received:
    9
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Hi,
    Removing the "t" didn't work and "which" shows:
    Code:
    root@moonlight [~]# which tcsh
    /bin/tcsh
    root@moonlight [~]# which csh
    /bin/csh
    root@moonlight [~]# 
    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` )'
    root@moonlight [~]
     
    #19 kernow, Sep 30, 2006
    Last edited: Sep 30, 2006
  20. beehave

    beehave Well-Known Member

    Joined:
    Jun 26, 2005
    Messages:
    104
    Likes Received:
    0
    Trophy Points:
    16
    Did you change permissions to 755?
     
Loading...

Share This Page