Linux/Unix HOWTOs
From Zedomax Wiki
How to install Monit to automatically restart/monitor your web server
You need to install this flex for compiling Monit:
yum install flex
and this:
[YACC Compiler http://linux.softpedia.com/progDownload/Berkeley-Yacc-Download-1326.html]
Then install using the instructions at [Monit http://www.tildeslash.com/monit/doc/apache.php].
Setting programs to start at boot for Fedora
Edit this file:
vi /etc/inittab
Then enter your stuff like:
mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
How to find which files and directories are taking up most space in your Linux system
du -s * | sort -g
Restarting Plesk via Command Line
/etc/rc.d/init.d/psa stopall /etc/rc.d/init.d/psa start
What to do if you if you get Method Not Implemented message when browing
Notice something funky about your server? Not accepting POST?
This means there's some type of security rule on your server.
Add the following lines to your httpd.include file or httpd.conf file.
For Fedora with Plesk, they should be under /home/httpd/vhosts/example.com/conf directory.
It took me couple days to figure this one out so go figure. (I just upgraded to Fedora Core 7, it could happen on the new Fedoras I think...)
<directory "/home/httpd/vhosts/example.com/httpdocs">
SecRuleEngine Off
</directory>
HOWTO Limit number of connections to your server to fight Denial of Service attacks
add the following to your /etc/rc.local so it will use iptables to limit the number of connections 12 per second after 24 per second have been seen.
iptables -t nat -N syn-flood iptables -t nat -A syn-flood -m limit --limit 12/s --limit-burst 24 -j RETURN iptables -t nat -A syn-flood -j DROP iptables -t nat -A PREROUTING -i $EXT_IFACE -d $DEST_IP -p tcp --syn -j syn-flood
Or you can type the code if you are experiencing DoS attacks right now.
More on iptables
See list of current iptables:
iptables -L # list rules iptables -L -n # list in numeric format iptables -L --line-numbers # show also the rule number
Do this to see the table you just made
iptables -L -t nat
To delete the rules
Simply replace -A with -D like this:
iptables -t nat -D syn-flood -m limit --limit 12/s --limit-burst 24 -j RETURN iptables -t nat -D syn-flood -j DROP iptables -t nat -D PREROUTING -i $EXT_IFACE -d $DEST_IP -p tcp --syn -j syn-flood
Use
httpd -k stop
to stop the server and enter the code above then
httpd -k start
to start your web server again.
HOWTO search for a string in a selection of files
find . -exec grep "www.athabasca" '{}' \; -print
This command will search in the current directory and all sub directories. All files that contain the string will have their path printed to standard output.
If you want to just find each file then pass it on for processing use the -q grep option. This finds the first occurrance of the search string. It then signals success to find and find continues searching for more files.
find . -exec grep -q "www.athabasca" '{}' \; -print
This command is very important for process a series of files that contain a specific string. You can then process each file appropriately. An example is find all html files with the string "www.athabascau.ca". You can then process the files with a sed script to change those occurrances of "www.athabascau.ca" with "intra.athabascau.ca".}}
Installing SVN Subversion
Most likely, your web server does not come with SVN installed. Simply do "Yum install subversion*" and install all the packages listed there. Then you can use the "svn" command to download all those cool goodies.
Here's some of my notes while trying to install PHPMOTION for my dedicated server:
(I've found that PHPMOTION DOES NOT WORK with 64bit Fedora cores, so don't even try)
Here's a helpful site for installing all the stuff you will need for installing the video codecs and requirements.
FIXING ERRORS
For the following error:
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
Make sure to install gcc-c++ by doing the following in fedora 5:
yum install gcc-c++
I think you can also install using rpm.
For Phpize and other Php tools:
yum install php-devel
HOW TO INSTALL MOST SOFTWARE ON YOUR LINUX BOX
Most of the time,
the following will install any of your tarball (tgz files) that you get. (for linux dummies)
./configure make make install
Make sure you have the proper packages installed such as gcc and glibc and whatnot
HOW TO INSTALL MOST SOFTWARE ON YOUR LINUX BOX 2
Now, if you want to use the easy way out instead of all the above tarball crap, you can always see if you can install the software using yum or rpm.
Examples:
rpm -qa lame
where lame is the name of the software.
You can also do:
yum install lame
or if you can't find the package still:
yum install lame*
try the 3 ways and if you can't find it, you can always get the source tarball files and install it manually. :)