Thursday, 31 July 2014

Install Virtualmin

Installing Virtualmin
===============================
chmod 700 install.sh
./install.sh

Install railo 4


1. wget http://www.getrailo.org/railo/remote/download/4.0.4.001/tomcat/linux/railo-4.0.4.001-pl1-linux-x64-installer.run
2. chmod +x railo-4.0.4.001-pl1-linux-x64-installer.run
3. ./railo-4.0.4.001-pl1-linux-x64-installer.run
also  do http://www.modcfml.org/index.cfm/install/web-server-components/apache-on-centos/
and
http://www.modcfml.org/index.cfm/install/tomcat-component/tomcat-valve-on-linux/

Plesk Email account password


If you want to find the password for email account’s in plesk then there are 3 ways to get the email account’s password
1) To find password for a single email account
/usr/local/psa/bin/mail --info example@domain.com
2) To find all email account passwords for a single domain
/usr/local/psa/admin/bin/mail_auth_view | grep user@domain.com
3) The below command will list passwords for all email accounts in plesk.
/usr/local/psa/admin/bin/mail_auth_view
OR
mysql -uadmin -p` cat /etc/psa/.psa.shadow` -Dpsa -e"select mail_name,name,password from mail left join domains on mail.dom_id = domains.id inner join accounts where mail.account_id = accounts.id;"

Check spamming in Exim mail server


1. To check the number of emails present in the queue:

# exim -bpc

2. To check the emails present in the queue with the mail id and sender ID:

# exim -bp
# exim -bp | less

3. To view the header of a particular email using mail ID:

# exim -MvH mail_id

4.  To view the body of a particular email using mail ID:

# exim -Mvb mail_id

5. To view a message's logs:

# exim -Mvl mail_id

6. To trace path:

# exim -d -bt user@domain.com

7. To get sorted list of email sender in exim queue:

# exim -bpr | grep "<" | awk {'print $4'} |cut -d "<" -f 2 | cut -d ">" -f 1 | sort -n | uniq -c| sort -n

8. To check the script that will originate spam mails:

# grep "cwd=" /var/log/exim_mainlog|awk '{for(i=1;i<=10;i++){print $i}}'|sort| uniq -c|grep cwd|sort -n

9. If we need to find out exact spamming script. To do this, run following command:

# ps auxwwwe | grep user | grep --color=always "/home/user/public_html/templates/" | head

# grep "cwd=/home" /var/log/exim_mainlog | awk '{for(i=1;i<=10;i++){print $i}}' | sort | uniq -c | grep cwd | sort -n

10.  To delete the emails of a specific user:

# grep -lr 'user@domain.com' /var/spool/exim/input/ | sed -e 's/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g' | xargs exim -Mrm

# exim -bp | grep "user_email-account" | awk '{print $3}' | xargs exim -Mrm

11. Removing null mails

exim -bp | grep "<>" | awk '{print $3}' | xargs exim -Mrm

12. To delete Frozen emails from the email queue:

# grep -R -l '*** Frozen' /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm
# exim -bp| grep frozen | awk '{print $3}'| xargs exim -Mrm
# exiqgrep -z -i | xargs exim -Mrm

12.  To delete Spam emails from the email queue:

#  grep -R -l [SPAM] /var/spool/exim/msglog/*|cut -b26-|xargs exim -Mrm

14. To check the no. of frozen mails:

# exiqgrep -z -c

15. To check exim logs:

# tail -f /var/log/exim_mainlog

16. Force delivery of one message:

# exim -M mail_id

17. Force another queue run:

# exim -qf

18. Force another queue run and attempt to flush frozen messages:

# exim -qff

19. To check if there are frozen emails:

# exim -bp |awk '/fr[o]zen/ {print}'

20. To clear just one email:

# exim -Mrm mail_id

21. Check the subjects of the emails:

# exiqgrep -i |awk '{ print "exim -Mvh "$1 }' |sh |grep -i Subject

Set time on server


follow   http://www.cyberciti.biz/faq/set-date-time-network-time-protocol-ntp/
ntpdate -u pool.ntp.org
==================================
==================================
errro when set time using date command  as   “date: cannot set date: Operation not permitted”
solution:
http://www.linuxhelp.in/2011/09/date-cannot-set-date-operation-not.html
This post explains how to solve the following error while setting the time in a openvz container vps.
Error:
date: cannot set date: Operation not permitted
Reason:
Capability not set for the vps
Soultion:
On Openvz node:
Stop the vps
[root@test ~]# vzctl stop ID
set the parameter
[root@test ~]# vzctl set ID –save –capability sys_time:on
Saved parameters for CT ID
Start the vps
[root@test ~]# vzctl start ID
Enter into the vps
[root@test8 ~]# vzctl enter ID
entered into CT ID
[root@abc /]#
check date
[root@abc /]# date
Fri Sep 16 00:39:09 CST 2011
Change date
[root@abc /]# date -s “Tue Sep 27 00:39:09 CST 2011″
Tue Sep 27 00:39:09 CST 2011
check date again
[root@abc /]# date
Tue Sep 27 00:39:19 CST 2011
Thats it. Date has been changed.
================================
================================
CHANGE THE TIME ZONE IN THE SERVER
mv /etc/localtime  /etc/localtime-old
ln -sf /usr/share/zoneinfo/EST localtime

htaccess file for WordPress


Basic WP


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


Multisite
WordPress 3.5 and up
If you activated Multisite on WordPress 3.5 or later, use one of these.

Subfolder Example

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
SubDomain Example

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
WordPress 3.4 and below
If you originally installed WordPress with 3.4 or older and activated Multisite then, you need to use one of these:

SubFolder Example

WordPress 3.0 through 3.4.2

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress

SubDomain Example

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]
# END WordPress

WordPress MU
If you started using WordPress with WordPress MU (WPMU) and then migrated to a newer version of WordPress multisite, the .htaccess rules are more complex:

SubFolder Example

RewriteEngine On
RewriteBase /

# BEGIN WordPress
#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# END WordPress

Create custom php.ini




1. You can copy php.ini  from server’s default php.ini diretory or create a new one

#cp /usr/local/lib/php.ini ./

2. Create a .htaccess file in your public_html directory and add the following contents
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/<username>/public_html
<Files php.ini>
order allow,deny
deny from all
</Files>
</IfModule>

3. Create a php info page to verify

#vim info.php

<?php
phpinfo();
?>

#chown username.username info.php