Posts

Showing posts from 2015

Add Swap Memory

You can add Swap memory in the server through creating a swap file. Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks (here adding 2 GB to Swap): When you add a swap file, you leave existing alone, just swapon a new one. # dd if=/dev/zero of=/swapfile1 bs=1024 count=2097152   [bs=block size, count= 1024*2048(2gb)=2097152] # mkswap /swapfile1 # chown root:root /swapfile1 # chmod 0600 /swapfile1 # swapon /swapfile1 Now verify the added Swap memory : # free -m  # cat /proc/swaps  Notes:  1. No need of swapoff, if you swapoff the existing swap you can crash the host, because may be the system have not enough memory to take over the current swap in use. (always make sure RAM is free before going to do swapoff -a). 2. Making swap space changes persistent As with filesystems, changes made by swapon are not persistent; to have swap added at boot time, create a line in /etc/fstab like this: /dev/sdb2 /swapfil

High Load on *nix servers

To check and reduce the load, I am pasting the commands which will provide you the outputs concerned with high load. Accordingly, you can troubleshoot the issue to reduce the load. 1.Get server uptime with uptime command: $ uptime 2. Gather information like tasks, memory, cpu and swap through Top command: $ top -cd3 Use "Shift +m" to order the memory usage from maximum to minimum. You can use "Shift +o" to choose different options also. 3. See the Load average, memory usage and CPU usage with Sar command: $ sar $ sar -q $ sar -r 4. Check top 10 memory hungry processes using following command: $ ps auxxx --sort=-rss | head -11 5. Check top 10 cpu hungry processes using following command: $ ps auxxx --sort=-%cpu | head -11 6. Check mpstat result with following: $ /usr/bin/mpstat -P ALL 7. Check iostat with iostat command. $ iostat 8. Check free RAM on the server: $ free -m 9. Use pstree to look for any suspicious processes or u

It's about Bangalore !!!

Hi Folks, This Blog is not technical, but about my new destination, Bangalore. Earlier I have worked in three different cities Jabalpur, Kochi and Mangalore but Bangalore seem different. The first thing you will notice about this city is It's awesome weather. If you have been in Bangalore, no need to explain it to you. When I reached Bangalore in the morning and put my first step on the Road, a cold breeze of Air has welcomed me with all its warm affection towards the newcomer. I must say, It was a pleasant morning, even after a tiresome journey from Mangalore to Bangalore. I found this city as Blend of different cultures and everything is going in Harmony. There are people from every corner of India. They celebrate every festival with the same Joy and Happiness what you find in your place. Currently, the Ganesha Chaturthi festival is in celebration here and its surprise to see the same ebullience and exhilaration as in Maharastra towards Bappa(Lord Ganesha). Further, I wa

PHP functions checker code

<?php if (function_exists('imap_open')) {     echo "IMAP functions are available.<br />\n"; } else {     echo "IMAP functions are not available.<br />\n"; } if (function_exists('dir')){     echo "dir functions are available.<br />\n"; } else {     echo "dir functions are not available.<br />\n"; } if (function_exists('readdir')) {         echo "readdir functions are available.<br />\n"; } else {     echo "readdr functions are not available.<br />\n"; } if (function_exists('opendir')) {         echo "opendir functions are available.<br />\n"; } else {     echo "opendir functions are not available.<br />\n"; } if (function_exists('eval')) {         echo "eval functions are available.<br />\n"; } else {     echo "eval functions are not available.<br />\n"; } if

Steps to install Perl module in cPanel

Step 1. First export the following (replace username with the actual user): export PERL_MB_OPT='--install_base /home/username/perl5' export PERL_MM_OPT='INSTALL_BASE=/home/username/perl5' export PERL5LIB='/home/username/perl5/lib/perl5/i386-linux:/home/username/perl5/lib/perl5' export PATH="/home/username/perl5/bin:$PATH" Step 2. Then add those to the /home/username/.bashrc Step 3. Download the Module's file from the cpan website. Step 4. Untar it Step 5. Run: perl Makefile.pl && make && make install Step 6. chown installed files as necessary.

Speedup your website with Gzip on cPanel

Verify whether mod_deflate in installed or not on the server. It should be installed. $ httpd -l | grep mod_deflate If not, install it through easyapache. $ /scripts/easyapache Then add the following codes in .htaccess:  <IfModule mod_deflate.c>      <IfModule mod_setenvif.c>         BrowserMatch ^Mozilla/4 gzip-only-text/html         BrowserMatch ^Mozilla/4\.0[678] no-gzip         BrowserMatch \bMSIE !no-gzip !gzip-only-text/html        BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html     </IfModule>    <IfModule mod_headers.c>        Header append Vary User-Agent env=!dont-vary    </IfModule>   <IfModule mod_filter.c>      AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon   </IfModule> </IfModule> Then test it: $ curl -A 'Mozilla/5.0 (X11; Linux i686; rv:6.0.2) Gecko/20100101 Firefox

Login failed error in Webmail when access from cPanel

Issue: When you access your Webmail account from cPanel, its showing Login failed error Whilst, Webmail is accessible directly through Webmail URL or with Webmail port number. Fix: The issue may occurs due to the missing directory where session files are saved. You need to create the directory "/var/cpanel/cpses/keys" on the server in order to fix the issue.

cPanel AutoFix Scripts

cPanel comes with a number of hidden autofix commands that allow for administrators to fix common problems simply by logging into WHM and going to a special URL. Two of the most useful ones I’ve seen are flushing iptables and restarting SSH in safe mode. You will not find the ‘scripts2’ directory in your server. To run your hidden cpanel commands you will have to login to the WHM. Then you may go to the URL http://serverIP:2086/scripts2/autofixer From there you can type the autofixer scripts name. You will get the autofix commands from the link: http://httpupdate.cpanel.net/autofixer/ Here are some examples: Reset the Firewall Settings   https://serverIP:2087/scripts2/doautofixer?autofix=iptablesflush Reset the SSH Settings        http://serverIP:2086/scripts2/doautofixer?autofix=safesshrestart bsdbindfix                    http://serverIP:2086/scripts2/doautofixer?autofix=bsdbindfix Autorepair                    http://serverIP:2086/scripts2/doautofixer?autofix=auto

Bug in Mailman

Error:  We're sorry, we hit a bug! Please inform the webmaster for this site of this problem. Printing of traceback and other system information has been explicitly inhibited, but the webmaster can find this information in the Mailman error logs. Reason:   One of the reason for the issue is that the folders in /usr/local/cpanel/3rdparty/mailman is not having sufficient permission. Fix: You can perform the following steps to fix the issue: Go to /usr/local/cpanel/3rdparty/mailman and check the permission of all the folders. $ ls -al /usr/local/cpanel/3rdparty/mailman Try $ chmod -R 2775 ./*  Now the permission of folders must have changed. Check if this has fixed the issue.  If not, you can try running the fixmailman script in the server at /scripts.

Incorrect disk quota on WHM/cPanel

Issue:   Disk usage zero for all the domains in 'list accounts'  Reason: Mismatch between the disk usage in backend and Cpanel Fix: Check whether /home partition has been mounted with 'usrquota' option (defaults,usrquota in /etc/fstab) # cat /etc/fstab| grep home LABEL=/home  /home    ext3    defaults,usrquota  1 2 # quotacheck -c /home # quotaon /home Also Check the option WHM >> Server Configuration >> Tweak Settings >> System --- Disable Disk Quota display caching

WordPress website slowness

Here are the following few things that you should do at your end: -->> Plugins: Before you install any plugin on your website, ask yourself “Is this plugin necessary?”. Plugins are one of the biggest causes of WordPress websites being slow. The more plugins you install without research, the more likely you will face performance issues; however the sheer number of plugins you have installed is not the reason a WordPress website can slow down. Certain plugins are known for causing websites to be slow. There are many reasons for this including bad coding, calls to external servers and persistent calls and updating of your WordPress database. Pay close attention to how much CPU plugins use too. Many plugins can bottleneck your CPU due to persistent processes. -->> Themes: A design that has been coded badly, or uses images throughout the design, will add unnecessary weight to your page. It is not uncommon for some WordPress themes to be a few megabytes in size. Such

Website slow reasons

Here are 7 possible causes for slow-loading pages. 1. Un-Optimized Images This is usually the most common reason for slow websites; there are lots of images, all of which are full-size and uncropped. 2. Use of Server-Intensive Dynamic Scripts Dynamic websites, such as those that generate their pages from data stored in databases, are slower than simple HTML websites. And while the slight delay is not often noticed on small, low-traffic websites, it is often noticeable as a website increases in size and popularity. To remedy this situation, we suggest caching. Caching enables you to store copies of frequently accessed dynamic documents and allows files to be accessed more quickly. 3. No Compression of Web Pages Another way to speed up your website is to compress your pages. 4. Too Much Flash Flash is a great tool for adding interactivity or animation to a website. However, flash is also very bulky and causes websites to load slowly. So when creating your flash

Enabling Extended Exim Logging in cPanel/WHM

When troubleshooting mail or attempting to discover the source of spam originating from your server, it is often useful to enable extended Exim logging. To enable extended logging in Exim to trace nobody mails. Try the following trick . 1. Edit /etc/exim.conf 2. On the second line add : log_selector = +address_rewrite +all_parents +arguments +connection_reject +delay_delivery +delivery_size +dnslist_defer +incoming_interface +incoming_port +lost_incoming_connection +queue_run +received_sender +received_recipients +retry_defer +sender_on_delivery +size_reject +skip_delivery +smtp_confirmation +smtp_connection +smtp_protocol_error +smtp_syntax_error +subject +tls_cipher +tls_peerdn \ Make sure all that comes on a single line. 3. Save and exit. 4. Restart Exim.

Catch the Spammer using scripts

Use following two script to catch the spammer. 1. exim -bpr | grep "<*@*>" | awk '{print $4}'|grep -v "<>" | sort | uniq -c | sort -n That will show you the maximum number of emails currently in the mail queue have from or to the email address in the mail queue with exact figure. 2. exim -bpr | grep "<*@*>" | awk '{print $4}'|grep -v "<>" |awk -F "@" '{ print $2}' | sort | uniq -c | sort -n That will show you the maximum no of email currently in the mail queue have for the domain or from the domain with number. Also you can try following command that will show you the script which is using script to send the email. If it is from php then use /var/spool/exim/input egrep "X-PHP-Script" * -R Just cat the ID that you get and you will be able to check which script is here causing problem for you. That may help you a lot to catch the spammer.

Install MySQLNd on a cPanel based server

In order to enable PHP modules on a cPanel based server, you need to execute the script "EasyApache". For installing additional modules like MySQLNd. You can do this by following steps given below. 1) Create a file /var/cpanel/easy/apache/rawopts/all_php5 2) Add the following line to that file: --with-mysqli=mysqlnd 3) Compile PHP using EasyApache

/tmp: Read-only file system Error

If you are getting the error "Read-only file system" while editing some files on the server, you can fix the same by running File System Check.  Error example: $ crontab -e /tmp/crontab.XXXX1ibTLU: Read-only file system It shows that the /tmp partition is unwriteable. The read-only has been mounted as read-only because file-system facing some error. To fix this, we need to do file system check (fsck) for /tmp partition. Before we do fsck, we need to unmount the directory but following error occurred: $ umount /tmp /tmp: Device or resource busy It seems like /tmp directory is locked to be unmounted due to some files are already in process/being opened/being executed by some other processes. Using lsof, we can list out all the open files: $ lsof | grep /tmp mysqld 2599 mysql 5u REG 7,0 0 6098 /tmp/ibaqFhew (deleted) mysqld 2599 mysql 6u REG 7,0 0 6099 /tmp/ibC7Yfbn (deleted) mysqld 2599 mysql 7u REG 7,0 0 6100 /tmp/ibJ8AFbe (

How to change the SSH port on linux server

To change the SSH port on Linux server, you need to log into your server as the root user. You can find the SSH configuration file at /etc/ssh/sshd_config To change specific parameters within sshd_config, you need to uncomment the line by removing the number-sign (#) and changing the value for the line. For example, the default SSH port appears in a line like this: #Port 22 To change the SSH port to 759, you will need to make the line appear like this: Port 759 After you are finished configuring SSH, you will need to restart the SSH daemon. You can do so by issuing the following command: # /etc/init.d/sshd restart After you restart SSH, you will need to log out of your server and log in again using the proper user, IP address, and port number you specified in sshd_config.

How to Change Document Root of Primary Domain in cPanel server

You must have root shell access for changing the primary domain document root in cPanel server, Use following steps to  change  document root of your primary domain in cPanel account: Step 1:  Use SSH to get shell access for your server as root account.  Now edit following file. # vim /var/cpanel/userdata/ USERNAME / DOMAINNAME.COM *Change   USERNAME  with your cPanel account name. *Change   DOMAINNAME.COM  with your Primary domain name. Step 2:  After editing the mentioned file, search for text   documentroot   and   change   path as per your requirement. documentroot: /home/ USERNAME /public_html/ NEW_PATH Step 3:  After making the changes, you need to rebuild Apache configuration file and restart Apache service. Use following commands to do it: # /scripts/rebuildhttpdconf # service httpd restart Your changes will be permanently updated now. Check your website for reflecting changes.

Incorrect diskspace and information of the databases in cPanel

Issue: Sometimes, when you check the Disk space information of your databases on the cPanel, its showing incorrect. There could be many reasons for this like, quota file, not updated DB cache which can be resolved by moving the quota file out of the way and by running another update_db_cache script on the server. what if, after trying all these fixes, you are still getting incorrect Disk space information of your databases on cPanel ??? Fix: You need to disable to use INFORMATION_SCHEMA to acquire MySQL disk usage on cPanel. You can do the same through WHM panel by changing the option "Use INFORMATION_SCHEMA to acquire MySQL disk usage" to Off.