Admins eHow SysAdmin Tips & Tricks

May 12, 2009

Secure Your WebServer by Disabling Dangerous PHP Functions

Filed under: CentOS,cPanel,Debian,General,Security — Tags: , , , — admin @ 8:02 pm

In order to secure your web server you need to disable some php functions which may be used to hack your server.
open your php.ini file and search for “disable_functions” then replace it with following directive :

disable_functions = "apache_child_terminate, apache_setenv, define_syslog_variables, eval, exec, fp, fput, ftp_connect, ftp_exec, ftp_get, ftp_login, ftp_nb_fput, ftp_put, ftp_raw, ftp_rawlist, highlight_file, ini_alter, ini_get_all, ini_restore, inject_code, openlog, passthru, php_uname, phpAds_remoteInfo, phpAds_XmlRpc, phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, posix_setuid, posix_uname, proc_close, proc_get_status, proc_nice, proc_open, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode"

after this step you need to restart apache server.
if you have cPanel installed on your server , you need to run the following command from SSH for cPanel work properly :

/scripts/makecpphp

it will make another instance of PHP for internal cPanel/WHM use.

Check Memory Usage in Linux

Filed under: CentOS,Debian,General — Tags: , — admin @ 5:39 pm

In order to check memory usage in Linux , there are several commands , but the most useful commands I have found are the following :

Check total memory usage :

# free -m
total       used       free     shared    buffers     cached
Mem:           512        490         21          0         16        160
-/+ buffers/cache:        314        197
Swap:         1023         76        947

what you are looking for is in front of “-/+ buffers/cache:” , in above example Total memory is 512MB , Used memory is 314MB and Free memory is 197MB.
it also shows the usage of Swap which is 76MB from 1023MB Total.

Check detailed processes memory usage :

# ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' | sort -nr
10.0 1 (squid)
2.7 1 python
1.5 1 /usr/sbin/pdns_recursor
1.3 1 sshd:
1.3 1 /usr/sbin/apache2
.........

This command is a little complex , we dont want to go into the details of command. we are only interested in the output.
The First column shows the percent of memory which this process is using , second column shows the number of instances of the process and the third column is the name of process. in the above example , process “squid” is using 10% of my server memory and python is using 2.7% of memory.

How to install a caching only dns server using powerdns on debian lenny

Filed under: Debian,General — Tags: , , , — admin @ 3:50 pm

I just noted my caching bind9 dns server is using 306MB of my precious memory ! what the hell is it doing !? go to hell bind !

/etc/init.d/bind9 stop
apt-get remove bind9

so I decided to install another caching dns server , after some research I found PowerDNS. it uses MySQL for storing its zones , but hopefully its caching component doesnt need mysql , so great , lets go and install it.
My favourite OS is debian lenny , so I ran the following command :

apt-get install pdns-recursor

WOW , it was very simple ! it is already working on localhost , but I needed it to listen on all IPs on my box and accept queries from everyone 😀 I wanted to serve public :p so I went to /etc/powerdns and opened “recursor.conf” file and made the following changes :

allow-from=
local-address=0.0.0.0

and restarted the service by :

/etc/init.d/pdns-recursor restart

it’s done 😀 now it is working as a public caching name server.

May 9, 2009

How to autostart a service on Debian, CentOs and RedHat

Filed under: CentOS,Debian,General — Tags: , , , — admin @ 3:31 pm

For Debian based distros run the following command as root :

update-rc.d servicename defaults

For CentOS and RedHat run the following command as root :

chkconfig servicename on
« Newer Posts

Powered by WordPress