ManXP

Well-Known Member
Feb 3, 2005
62
0
156
Ah, sorry, it was my mistake. I left default value of "/myscripts" on config file, I had to change it to "/root/myscripts" :)

Worked just fine, removed about 10.000 lines from httpd.conf

Thanks for such a great script!
 

ManXP

Well-Known Member
Feb 3, 2005
62
0
156
Well, it was about 13.000 lines actually ;)

Server load was reduced really well. I'm running 2xDual Opteron with 2 Gb RAM, but server was slow. Now it's running fast :)
 

AdamDresch

Well-Known Member
Jun 22, 2006
80
0
156
Seemed to work AOK

I got this message afterwards

./clean

HttpdCleanUp 5.0


Backing up httpd.conf.....

Processing httpd.conf.....

File is now 55 bytes smaller in size

There were 796 lines removed

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

Warning: DocumentRoot [/home/dreschc/public_html/peter] does not exist
[Sun Apr 29 14:28:40 2007] [warn] The ScriptAlias directive in /usr/local/apache/conf/httpd.conf at line 638 will probably never match because it overlaps an earlier ScriptAliasMatch.
[Sun Apr 29 14:28:40 2007] [warn] The ScriptAlias directive in /usr/local/apache/conf/httpd.conf at line 641 will probably never match because it overlaps an earlier ScriptAliasMatch.
[Sun Apr 29 14:28:40 2007] [warn] NameVirtualHost 207.xxx.xx.xx:80 has no VirtualHosts
/etc/rc.d/init.d/httpd start: httpd started

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

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

beehave

Well-Known Member
Jun 26, 2005
104
0
166
Seemed to work AOK

I got this message afterwards
To see if the script caused the error, run the following commands:

mv /usr/local/apache/conf/httpd.conf.Apr29 /usr/local/apache/conf/httpd.conf

/scripts/restartsrv_httpd


If you still get the error, you should fix the issue before running the script again.
 

OpperGoeroe

Active Member
Apr 26, 2005
30
0
166
Before httpd.conf:
40.000 lines (yes, 40.000!) - almost 1 MB

After:
34.000 lines

So it did make sense, thanks ;)
 

junglecat

Well-Known Member
Jul 6, 2004
168
0
166
Can someone give me idiot instructions please? I need to know step by step how to use this script, including making the backup etc.

I *think* I know what to do, but I want to be sure I don't break anything.
 

beehave

Well-Known Member
Jun 26, 2005
104
0
166
Can someone give me idiot instructions please? I need to know step by step how to use this script, including making the backup etc.

I *think* I know what to do, but I want to be sure I don't break anything.
Just run the following commands: (First cd into where you want to keep script. I keep my scripts in /stuff)

wget http://www.systemabuse.com/scripts/httpdcleanup.txt
mv -f httpdcleanup.txt httpdcleanup
chmod 755 httpdcleanup

Edit variables at top and then run script:

./httpdcleanup

It will make a backup before starting...
 

astridas

Member
Jun 20, 2004
13
0
151
For this script to work on FreeBSD:
Code:
# cd /usr/ports/textproc/gsed
# make install clean
# replace 'sed' 'gsed' -- /root/myscripts/httpdcleanup.sh
or change the file to where you put your cleanup script.

Script worked like it was supposed to. Excellent job and Thanks Beehave.
 

chae

Well-Known Member
Apr 19, 2003
145
0
166
Auckland, New Zealand
# ./httpdcleanup
TERM environment variable not set.

HttpdCleanUp 5.0

Backing up httpd.conf.....
Processing httpd.conf.....
File is now 995 bytes smaller in size
There were 1777 lines removed
Done... Restarting Apache.......

Thank you for the script, for the short time apache has been running with the cleanup load has dropped about 0.5
 

junglecat

Well-Known Member
Jul 6, 2004
168
0
166
# ./httpdcleanup
TERM environment variable not set.

HttpdCleanUp 5.0

Backing up httpd.conf.....
Processing httpd.conf.....
File is now 995 bytes smaller in size
There were 1777 lines removed
Done... Restarting Apache.......

Thank you for the script, for the short time apache has been running with the cleanup load has dropped about 0.5
Ok, I ran the script, the server is not broke, and it's MUCH faster. Thanks for that script!

File is now 545 bytes smaller in size

There were 1295 lines removed
 

jasbor

Active Member
Apr 21, 2004
25
0
151
getting error

Processing httpd.conf...
./httpd_cleanup: line 86: syntax error near unexpected token `newline'
./httpd_cleanup: line 86: ` grep -v "$cl" $mypath/data/httpd.a > '
 

jasbor

Active Member
Apr 21, 2004
25
0
151
Did you edit the script at all?
Yes, I edited the few lines in the script at the top.
I really only changed the path line to: /root/myscripts
It created the data folder, and I have the httpd.a,b,c,d files
 

bebop1065

Active Member
Apr 14, 2004
28
0
151
NJ
It looks like six lines of your script are missing because it shows that lines 86-92 are like this
done

replace -s ' ' 'XTX' -- $mypath/data/httpd.a

sed '/NameVirtualHost/ d' <$hpath/httpd.conf> $mypath/data/httpd.b

L1=`cat -n $mypath/data/httpd.b | grep "<VirtualHost $ip" | head -n1 | awk '{print $1}'`
 

beehave

Well-Known Member
Jun 26, 2005
104
0
166
Processing httpd.conf...
./httpd_cleanup: line 86: syntax error near unexpected token `newline'
./httpd_cleanup: line 86: ` grep -v "$cl" $mypath/data/httpd.a > '
Please try this for me:

At around line 86 find:
Code:
for cl in `cat $mypath/data/httpd.d`; do
        grep "$cl" $hpath/httpd.conf > $mypath/data/httpd.e
        ct=`awk 'END { print NR }' $mypath/data/httpd.e`
        if [ $ct = '1' ]; then
                grep -v "$cl" $mypath/data/httpd.a > $mypath/data/httpd.f
                cat < $mypath/data/httpd.f > $mypath/data/httpd.a
        fi
done
And change to:
Code:
for cl in `cat $mypath/data/httpd.d`; do
        grep "$cl" $hpath/httpd.conf > $mypath/data/httpd.e
        ct=`awk 'END { print NR }' $mypath/data/httpd.e`
        if [ $ct = '1' ]; then
                grep -v "$cl" $mypath/data/httpd.a >\
                $mypath/data/httpd.f
                cat < $mypath/data/httpd.f >\
                $mypath/data/httpd.a
        fi
done
Let me know...
 

jasbor

Active Member
Apr 21, 2004
25
0
151
Please try this for me:

At around line 86 find:
Code:
for cl in `cat $mypath/data/httpd.d`; do
        grep "$cl" $hpath/httpd.conf > $mypath/data/httpd.e
        ct=`awk 'END { print NR }' $mypath/data/httpd.e`
        if [ $ct = '1' ]; then
                grep -v "$cl" $mypath/data/httpd.a > $mypath/data/httpd.f
                cat < $mypath/data/httpd.f > $mypath/data/httpd.a
        fi
done
And change to:
Code:
for cl in `cat $mypath/data/httpd.d`; do
        grep "$cl" $hpath/httpd.conf > $mypath/data/httpd.e
        ct=`awk 'END { print NR }' $mypath/data/httpd.e`
        if [ $ct = '1' ]; then
                grep -v "$cl" $mypath/data/httpd.a >\
                $mypath/data/httpd.f
                cat < $mypath/data/httpd.f >\
                $mypath/data/httpd.a
        fi
done
Let me know...
that worked.... thanks
 

biggdogg285

Well-Known Member
May 14, 2004
73
0
156
cPanel Access Level
Root Administrator
Thanks behave for the script. I ran it on my servers, and it worked well.

httpd.conf went from 150KB's to 120KB's or 5,195 lines to 4,054.

Thanks again!