Wednesday, 18 December 2013

Linux commands

1) to list open ports and services >> service --status-all
2) 

Wordpress with cPanel server

A) Steps to rename wordpress wp-login.php file

1) Find and replace the text “wp-login.php” on /wp-login.php file with “hidden-login.php”
2) Find and replace the text “wp-login.php” on /wp-includes/general-template.php file with “hidden-login.php” except this line on wp_login_url function, like :
$login_url = site_url('wp-login.php', 'login'); for new version, or
return site_url("wp-login.php$redirect",'login'); for old version
just let it be the way it is, otherwise when you go to wp-admin, it will redirect to “hidden-login.php”
3) Rename /wp-login.php file into hidden-login.php

http://crazydavinci.net/2010/11/secure-wordpress-login/

-------------------------------------------------------------------------------------

B) wordpress installation fantastico steps

1. Log into your website’s cPanel account, then click on the Fantastico icon.

2. From the Fantastico interface, scroll down until you see the Blogs section and just below it, you should see WordPress in the list. Click on the WordPress link.

3. To the right, you will be provided with some information about the version of WordPress you will be able to install. Take a moment to ensure that it’s up to date. If all is well, click on New Installation.

4. You should arrive at the first of three steps in the one-click installation process. Here, you’ll be able to determine which folder you’d like to have WordPress installed to, as well as some other blog information

  4.1 Installation Location. If you want your blog to be your website’s homepage, ensure that you leave the space blank, otherwise type in the name of the folder you want WordPress installed to (make sure it doesn’t already exist).

  4.2 Admin access data. Choose the username and password you’d like to use in order to access the WordPress admin panel after installation is completed.

  4.3 Base configuration. Type a nickname you’d like to use throughout the blog. By default, the nickname is used whenever you leave comments or write an entry on the blog, so choose something you don’t mind the world seeing. The admin e-mail address is where notices, passwords, and other information about the administration of the blog is sent. Your blog’s name and description should be self-explanatory.

  4.4 E-mail account configuration. You only need to worry about this if you plan to blog via e-mail. If you’ve set up a special e-mail account that you’ll use for blogging via e-mail, then enter the settings where applicable. (Bear in mind, you will need to enter an e-mail account password in order to proceed with the installation, simply use a false one if you don’t plan to blog via e-mail.)

  4.5 When your blog information is complete, click on the Install WordPress button at the bottom.

5. Verify that the information you provided is correct and click on Finish installation. Fantastico will create a brand new database for you and create the necessary WordPress files.

6. When the process is complete, you will receive a confirmation notice with the details of the installation. If you’d like a copy of the report for your records, you’ll have the option to send an e-mail to an account of your choosing.

-------------------------------------------------------------------------------------

Enable innodb in the mysql +cPanel

fix:: http://forums.cpanel.net/f354/how-install-innodb-step-step-155297.html Once you are logged in, check if Innodb is already there. Execute the command: mysqladmin variables | grep have_innodb this will tell you if Innodb is present on the server and whether it is ON or OFF. root@server1 [~]# mysqladmin variables | grep have_innodb | have_innodb | DISABLED | If you see have_innodb is set to OFF. It indicate thet innodb is disabled on your server. To enable it, ssh to your server as root and open file /etc/my.cnf with your favorite editor. Search for line skip-innodb and comment the line by placing # in the starting of the line. Save and quit the file and restart mysql service for changes to take effect. /etc/init.d/mysql restart Now check status of InnoDb engine mysqladmin variables | grep have_innodb Above command should show output as YES now. root@server1 [~]# vi /etc/my.cnf root@server1 [~]# /etc/init.d/mysql restart Shutting down MySQL... SUCCESS! Starting MySQL... SUCCESS! root@server1 [~]# mysqladmin variables | grep have_innodb | have_innodb | YES |

Webmail - squirrel, horde and roundcube doesn't work ask for double login

Cause:: this happened due to hostname change Fix:: http://forums.cpanel.net/f43/webmail-squirrel-horde-roundcube-doesnt-work-206321.html Please run the following command in root SSH: Code: /scripts/whoowns domain.com Where domain.com is the domain name in question. If it doesn't show any ownership, then move the following files: Code: cd /etc mv userdomains userdomains.bak mv domainusers domainusers.bak mv trueuserdomains trueuserdomains.bak At that point, run the following script and recheck ownership for the domain: Code: /scripts/updateuserdomains /scripts/whoowns domain.com

How to prevent mail delivered to spam folder

How to prevent mail delivered to spam folder when using contact forms etc:

Create custom php.ini file inside that ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path = "/usr/sbin/sendmail -t -i -f mail_account_id" // write from address earlier the value is sendmail_path = "/usr/sbin/sendmail -t -i"

Access domain via IP in cPanel servers

In order to access domain via xxx.xxx.xxx.xxx/~user Please make sure that you have not disabled the mod_userdir from WHM for the domain. You can check it from WHM --> Security Center --> Apache mod_userdir Protection. 
Also try Home » Security Center » PHP open_basedir Tweak

How to migrate a cPanel account to a webmin server?

1. Generate the full backup of the cPanel account. 2. SCP the generated backup file to the destination server 3. Login to webmin as root 4. Go to Add Servers>> Migrate Virtual Server 5. Fill up the form in the page Note: Enter Domain name to migrate, Username for domain and Password for administrator manually in the form =============================== Error 1 : validation failed : A password must be supplied for cPanel migrations Fix: Enter Domain name to migrate, Username for domain and Password for administrator manually in the form and try again Error2: Failed to migrate virtual server : SQL flush privileges failed : Table 'mysql.servers' doesn't exist Fix: Run the following command mysql_fix_privilege_tables --user=root --password=XXXXX --verbose where XXXXX is the root password. ================================= Reference: http://www.virtualmin.com/documentation/system/cpanel#migrating_existing_cpanel_domains_to_virtualmin

Bandwidth limit exceeded for an account in cPanel

Check in the awstats of the cPanel, for having the list of http request. Also check the apache logs for the IPs, block the IPs in the firewall that makes large number of requests. For temporarily activating the account, we can increase the bandwidth limit or change the bandwidth limit usage value(not recommended) For changing bandwidth usage value. 1) edit the value (reduce) in file /var/cpanel/bandwidth.cache for example before changing: root@server [/var/cpanel/bandwidth.cache]# cat user_name 7571093900 root@server [/var/cpanel/bandwidth.cache]# cat domain_name 7569243093 after changing: root@server [/var/cpanel/bandwidth.cache]# cat user_name 5571093900 root@server [/var/cpanel/bandwidth.cache]# cat domain_name 5569243093 2) click on change in bandwidth limit usage via whm.

Tomcat in cPanel

1) Loading dynamic pages


Write the following steps in the file cp_jkmount.conf, this file can be located based on the configuration. root@server [/home/user/public_html]# cat /usr/local/apache/conf/userdata/std/2/user/domain/cp_jkmount.conf <IfModule mod_jk.c> JkMount / ajp13 // for loading files with any extension JkMount /*.action ajp13 //for lading files with extension '.action' JkMount /*.jsp ajp13 //for lading files with extension '.jsp' JkMount /*.do ajp13 //for lading files with extension '.do' JkMount /servlet/* ajp13 JkMount /servlets/* ajp13 </IfModule> After editing the file, do tomcat restart

remote backup script

Write script in the server from which the backup has to be taken:

vi /root/bkp.sh

#!/bin/bash
###########################################################################################################################
####### PURPOSE : SELECTIVE BACKUP TO A REMOTE SERVER ; USAGE : PUT DOMAIN NAME AND USERNAME IN THE FILE "cred"############
###########################################################################################################################
DATE=`date +Date%d-%H%M%S`
TOIP=`tail -1 cred | awk '{ print $4 }'`
PORT=`tail -1 cred | awk '{ print $3 }'`

for i in `sed -n '/---START---/,/---ENDOF---/p' cred | grep -v ^-- | awk '{ print $2 }'`
do
        DOMAIN=$i
        /scripts/pkgacct "$DOMAIN"
        scp -P $PORT /home/cpmove-"$DOMAIN".tar.gz root@"$TOIP":/backup2/folder_name/"$DATE"_cpmove-"$DOMAIN".tar.gz      
        rm -rf /home/cpmove-"$DOMAIN".tar.gz
done



vi /root/cred


---START---
domain_name:user_name
---ENDOF---
Remote_server_name Remote_server_ip  Remote_server_port  Remote_server_ip

Thursday, 12 December 2013

Eximstats Desc

eximstats - generates statistics from Exim mainlog files.

Reason for large eximststat DB
=======================

If the server has heavy email activity or if there is an abuse activity on server or if the server eximstat log rotation interval is too high then the DB can grow large in size. Which is the main cause behind eximstats db crashing

-- > You can run command cat /var/log/exim_mainlog | eximstats . This will  Generate and display Exim stats from a logfile

Firstly check for any abuse attempts happening on server
Only if the DB is very large that is in GB size, attempt below or else the normal repair should work

Fix
===
1 ) Updating log rotation value in whm
WHM> tweak setting >  “The interval, in days, to retain Exim stats in the database” , suggested log rotation is 30days

2) Remove eximstats:
If you would like to remove and recreate eximstats database,
==============
# mysql

> DROP DATABASE eximstats;
> CREATE DATABASE eximstats;
> quit
mysql eximstats < /var/cpanel/sql/eximstats.sql
==============

3) Truncsating/deleting the DB values
=========
disable eximstats from whm >> service manager
Login to mysql
#mysql

mysql> use eximstats
mysql> delete from sends;
mysql> delete from smtp;
mysql> delete from failures;
mysql> delete from defers;

or if it is to Truncate
run truncate

>>truncate table smtp;
>>truncate table send; etc

root@server [~]# mysqlcheck -c eximstats
eximstats.defers OK
eximstats.failures OK
eximstats.sends OK
eximstats.smtp OK
root@jupiter [~]#

restart mysql and exim

=========

Command to check joomla and wordpress version in server backend

Check Joomla version.

root@mickgenie.com [~]# grep version language/en-GB/en-GB.xml
<?xml version=”1.0″ encoding=”utf-8″?>
<metafile version=”1.5″  client=”site” >
<version>1.5.15</version>
-------------------------------------------------
 Check wordpress version.

[root@server public_html]# grep wp_version wp-includes/version.php
* @global string $wp_version
$wp_version = '3.5';

Direct admin reset password not working

http://forum.directadmin.com/showthread.php?t=23664

cd /usr/local/directadmin

./directadmin i

The above will create the admin account with admin name and password as entered into the
 /usr/local/directadmin/scripts/setup.txt file.

You may want to edit and change the adminname= and adminpass= entries in the setup.txt before executing "./directadmin i".

Create custom php.ini file cPanel

1) Copy /usr/local/lib/php.ini to the site's Web root folder (public_html). Via SSH:
 php -i | grep php.ini

 cp /usr/local/lib/php.ini /home/USERNAME/public_html  

2) Make sure the file is owned by their cPanel user via SSH:  
 chown USERNAME:USERNAME php.ini

3) Edit .htaccess file and put there the path to your php.ini file. 
  suPHP_ConfigPath /home/username/public_html

--------------------------------------------------------------

 
Custom php.ini in server using php handler fcgi
http://blog.arvixe.com/how-to-add-custom-php-ini-for-servers-running-fastcgi/


Below are the steps to enable custom php.ini for FastCGI PHP handler:
Open .htaccess of the user and add the below codes:

AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php5.fcgi


Move to the cgi-bin folder of the account

cp /usr/local/lib/php.ini /home/user/public_html/cgi-bin/ 
 
chmod 755 /home/user/public_html/cgi-bin/php.ini

cd /home/user/public_html/cgi-bin/

vi php5.fcgi  (insert the below codes and save)

#!/bin/sh
export PHP_FCGI_CHILDREN=1
export PHP_FCGI_MAX_REQUESTS=10
exec /usr/local/cpanel/cgi-sys/php5


Save and quit the file

chmod 755 /home/user/public_html/cgi-bin/php5.fcgi

Modsecurity

ModSecurity is a web application firewall for the Apache web server. In addition to providing logging capabilities, ModSecurity can monitor the HTTP traffic in real time in order to detect attacks. ModSecurity also operates as a web intrusion detection tool, allowing you to react to suspicious events that take place at your web systems.
The rules are in the file "/usr/local/apache/conf/modsec2.user.conf" depending on apache version.

The error related with mod security is specified in the apache error log

The rule must be removed for this site, by creating custom conf in the apache conf for this domain and remove the id. Create below file using username, domain name, file name-mod_sec2.conf. Location match and Id obtained from the apache error_log. 

=================
root@server [/usr/local/apache/conf/userdata/std/2/username/domain_name]# cat mod_sec2.conf <IfModule mod_security2.c>
<LocationMatch "URL">
SecRuleRemoveById id
</LocationMatch>
</IfModule>
=================


Disable mod sec for a domain completely.

Just create a directory:

 mkdir -p /usr/local/apache/conf/userdata/std/2/username/domain.com

Then create a file:   /usr/local/apache/conf/userdata/std/2/username/domain.com/mod_security.conf

In that file add:

 <IfModule mod_security.c>
SecRuleEngine Off
</IfModule>

Save it.

 Then run:   /scripts/ensure_vhost_includes --user=username


Permission fix

Script for viewing files whose permission is not 644 and change it to 644

find . -type f ! -perm 644
       type: specifies whether the type of file, f for file d for directory
       ! perm: permission not equal to

find . -type f ! -perm 644 -exec chmod 644 {} \;
       exec: execute change

How to disable redirection to SSL while accessing WHM,cPanel,Webmail

If you want to disable redirection to SSL connection while accessing WHM, cPanel, Webmail, please follows these steps.

Login to WHM >> Tweak Setting >> Uncheck the following options under Redirection.


Always redirect to SSL: Off

Also you have to uncheck the following option under Security in Tweak Settings.


Require SSL: Off
------------------------------------------
Also you can disable those options from the shell.
SSH to the server as root.

You can do this by editing /var/cpanel/cpanel.config with your favorite shell text editor and changing the following entry: 
requiressl=1 
Change the "1" to a "0", and save the changes. 

You may also need to edit the following entry: 
alwaysredirecttossl=1 
If the value is a "1", change to a "0". 

Next, make sure to run the following command: 
# /usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings 
This command will put any changes made to the /var/cpanel/cpanel.config file into effect.

How to Install ClamAV and Configure Daily Scanning on CentOS

A. Install ClamAV

1. Install EPEL repo
Before we can do proceed, you must ensure that you have the EPEL yum repository enabled.
2. Install required packages
yum install clamav clamd
3. Start the clamd service and set it to auto-start
/etc/init.d/clamd on
chkconfig clamd on
/etc/init.d/clamd start
4. Update ClamAV’s signatures
/usr/bin/freshclam
Note: ClamAV will update automatically, as part of /etc/cron.daily/freshclam.

B. Configure Daily Scan

In this example, we will configure a cronjob to scan the /home/ directory every day:
1. Create cron file:
vim /etc/cron.daily/manual_clamscan
Add the following to the file above. Be sure to change SCAN_DIR to the directory that you want to scan:
#!/bin/bash
SCAN_DIR="/home"
LOG_FILE="/var/log/clamav/manual_clamscan.log"

/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE
Give our cron script executable permissions:
chmod +x /etc/cron.daily/manual_clamscan
You can even run the above script to ensure that it works correctly.

Update or reset root login details of mysql server

service mysqld stop
mysqld_safe --skip-grant-tables &



use mysql
UPDATE mysql.user SET password=PASSWORD('newpass') WHERE user='root';
FLUSH PRIVILEGES;
quit


/sbin/service mysqld start
mysql -uroot -p

VPS Shows the Wrong Time [Xen]

The VPS system clock is synced with the dom0 (host) clock unless an independent “wall” clock is specified. This is done by performing the following:

echo 1 > /proc/sys/xen/independent_wallclock
 
To make this change persist on boot, edit /etc/sysctl.conf and add the following on a new blank line:

xen.independent_wallclock = 1
 
Then you may set the time as you desire, or sync it with an NTP server, e.g.:

ntpdate ntp1.ndchost.com
 
Syncing your time via NTP is considered good practice to ensure proper server functionality. By default the ntpdate command is not installed, so you will need to add it. The process dependson your distro. For CentOS/RedHat/Fedora Core:

yum -y install ntp
For Ubuntu/Debian:

apt-get install ntp
For cPanel servers:
Log into the WHM and go to Main » Server Configuration » Server Time and select Sync with Time Server.

===========================================================

 

Procedure: Setup NTPD on CentOS Linux

Open the terminal or login over the ssh session. You must login as as the root user. Type the following yum command to install ntp
# yum install ntp ntpdate ntp-doc

Turn on service, enter:
# chkconfig ntpd on

Synchronize the system clock with 0.pool.ntp.org server (use this command only once or as required):
# ntpdate pool.ntp.org

Start the NTP server. The following will continuously adjusts system time from upstream NTP server. No need to run ntpdate:
# /etc/init.d/ntpd start

Configure ntpd (optional)

Edit /etc/ntp.conf, enter:
# vi /etc/ntp.conf

Set public servers from the pool.ntp.org project:
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org

How to Setup Reverse DNS in WHM

Create a reverse DNS zone file
  1. Login to WHM and navigate to DNS Functions -> Add a DNS Zone
  2. Type in your IP address (example – 192.168.254.254)
  3. Enter the reverse DNS name (example -254.128.192.in-addr.arpa).
Edit the reverse DNS zone file
Now, you will need to create each PTR record.
  1. From the main WHM page, go to DNS Functions-> Edit DNS Zone
  2. Under where it says “Add New Entries Below This Line”, enter the corresponding octet or nibble (the final number in the IP address). Example: 254. In the drop down menu, select “PTR”.
  3. Enter the associated domain name for that IP address
  4. Repeat for each IP address
To check that your reverse DNS is working, you can type this from the command line:
host 192.168.254.254
and the output should look like this:
254.254.168.192.in-addr.arpa domain name pointer www.yourdomain.com