Skip to main content

Posts

Showing posts from August, 2014

Remove old backups from a cPanel server

Disk space usage is always a problem for the server admins and this script can be used for removing the old account backups from the server. The first script will make a list for the accounts to be removed and the second one will clean it. for i in `ll /backup/cpbackup/weekly/ |awk {‘print $9′}|grep -v ^$|grep -Ev “cpbackupstatus|dirs|files”|cut -d’/’ -f1` ; do grep -w $i /etc/userdomains >/dev/null  ;  if [ $?  -ne 0 ] ; then echo $i ; fi ; done | grep -v “.tar.gz” >  /root/deletelistnw for i in `cat /root/deletelistnw`; do rm -rf /backup/cpbackup/weekly/$i; done

CPanel Proxy – WHM Proxy Domain

# CPANEL/WHM/WEBMAIL/WEBDISK PROXY SUBDOMAINS     ServerName $hostname     ServerAlias cpanel.* whm.* webmail.* webdisk.*     DocumentRoot /usr/local/apache/htdocs     ServerAdmin system@hostname            SecRuleEngine Off        UserDir disable     RewriteEngine On            SSLProxyEngine On        RewriteCond %{HTTP_HOST} ^cpanel\.     RewriteCond %{HTTPS} on     RewriteRule ^/(.*)  https://127.0.0.1:2083/$1  [P]     RewriteCond %{HTTP_HOST} ^webmail\.     RewriteCond %{HTTPS} on     RewriteRule ^/(.*)  https://127.0.0.1:2096/$1  [P]     RewriteCond %{HTTP_HOST} ^whm\.     RewriteCond %{HTTPS} on     RewriteRule ^/(.*)  https://127.0.0.1:2087/$1  [P]     RewriteCond %{HTTP_HOST} ^webdisk\.     RewriteCond %{HTTPS} on     RewriteRule ^/(.*)  https://127.0.0.1:2078/$1  [P]     RewriteCond %{HTTP_HOST} ^cpanel\.     RewriteRule ^/(.*)  http://127.0.0.1:2082/$1  [P]     RewriteCond %{HTTP_HOST} ^webmail\.     RewriteRule ^/(.*)  http://127.0.0.1:2095/$1  [P]     RewriteCond %{HTT

How to recover deleted Apache Log

Scenario: The server is running Apache and by mistake one of the log files gets deleted. How, we can recover it? Currently, Apache server is working perfectly: Login/Switch to as root user: Move to the httpd in log directory: cd /var/log/httpd Delete the log file: rm -f access_log So the log file has been deleted,now find the process number for main apache procees that owned by root: ps aux | grep httpd In this case, the pid for the main apache process is1784. Now lets list the file descriptors: ls -lsa /proc/1784/fd Stop the apache service: service httpd stop Now copy the access log file that is marked as deleted (In this case it is 7) into the log directory: cp /proc/1784/fd/7 /var/log/httpd/access_log Start the apache service again: service httpd start Access the webpage again from your server: Verify the log file: tail -f /var/log/httpd/access_log It’s working :-) Hope this will help you! Scenario: The server is running Apache and by

Error : 111 Can’t open SMTP stream – SquirrelMail

ERROR: Message not sent. Server replied: Connection refused 111 Can’t open SMTP stream.  Solutions: > Cpanel version of SquirrelMail does not work. 1) config for Squirrelmail: /usr/local/cpanel/base/3rdparty/squirrelmail/config/ config.php I just changed: $useSendmail = false; to: $useSendmail = true; 2)Enabling the SMTP tweak: It is likely related to an iptables rule used to deny connections from those other than exim, mailman and root. Turning the SMTP Tweak on and then off should recreate this rule correctly. Main >> Security Center >> SMTP Tweak 3) Editing the CSF conf: # Block outgoing SMTP except for root, exim and mailman (forces scripts/users # to use the exim/sendmail binary instead of sockets access). This replaces the # protection as WHM > Tweak Settings > SMTP Tweaks. This will block hosting # clients from using your server as an SMTP relay SMTP_BLOCK = 1 # If SMTP_BLOCK is enabled but you want to allow local connections to port 25 # o

Too many connections in TIME_WAIT state

Too many connections in TIME_WAIT state: If you seeing a lot of connections in  TIME_WAIT state then each socket in TIME_WAIT consumes some memory in the kernel, usually somewhat less than an ESTABLISHED socket. But it may increase the load in server. For solving this you need to do the following on the server, Login to the server via SSH Then enter the following command, it will append the values for timeout in the server, echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle Also you need to edit the file,  /etc/ sysctl.conf and add the timeout and recycle values in it. vi /etc/ sysctl.conf And add the following values to the file net.ipv4.tcp_fin_timeout=30 net.ipv4.tcp_tw_recycle  = 1