Thursday, June 18, 2015

How to run tomcat as service

Make sure there is a valid user "tomcat" and that this user has rw permissions in the $CATALINA_HOME/conf and $CATALINA_HOME/logs directories. Also make sure that $JAVA_HOME is set. You will start Tomcat as user "tomcat" to avoid running it as root.

Save the following scripts as /etc/init.d/tomcat.They will automatically be read and run at boot time. Check the log files if it does not start properly.


Do like below for rc3.d rc5.d rc4.d
Make a link to it from /etc/rc5.d such as:
cd /etc/rc5.d
sudo ln -s ../init.d/tomcat S71tomcat


Script for init.d

#!/bin/bash
#
# tomcat        where is tomcat mention is script that need to replace with user
#
# chkconfig: 345 20 80
# description:     Start up the Tomcat servlet engine.

# Source function library.
. /etc/init.d/functions


RETVAL=$?
CATALINA_HOME="/tomcat-apache path/apache-tomcat-7.0.62"

case "$1" in
 start)
        if [ -f $CATALINA_HOME/bin/startup.sh ];
          then
        echo $"Starting Tomcat"
            /bin/su tomcat $CATALINA_HOME/bin/startup.sh
        fi
    ;;
 stop)
        if [ -f $CATALINA_HOME/bin/shutdown.sh ];
          then
        echo $"Stopping Tomcat"
            /bin/su tomcat $CATALINA_HOME/bin/shutdown.sh
        fi
     ;;
 *)
     echo $"Usage: $0 {start|stop}"
    exit 1
    ;;
esac

exit $RETVAL

For boot time active : chkconfig --level 345 tomcat on

To Find from which user service running
ps aux | egrep 'process name' typically will show from which user is service running as.
Tuesday, June 16, 2015

How to check forgot password of plesk & login mysql too

For login plesk mysql without password : mysql -uadmin -p`cat /etc/psa/.psa.shadow`

For Check plesk admin panel password :  /usr/local/psa/bin/admin --show-password

OVF file not able to deploy

Failed to deploy OVF package: The task was canceled by a user

 

There will be three files you have to delete .mf file and edit .ova file and change contain like below
  • .ova – OVF descriptor, written in XML, which describes the hardware requirements
  • .mf – contains SHA1 checksums of the .OVA and .VMDK
  • .vmdk – the virtual hard disk for the virtual machine.
vmware.cdrom.iso
Changing the above line, to read…
vmware.cdrom.atapi
Then import it will work.
Before import right click on virtual system and edit setting and modify and choose Host CD ROME.
Then export vm and then deploy it will work.

Friday, May 29, 2015

How to excute mysql command from shell



execute mysql command remotely from shell

# mysql -h [ip] -u [user] -p[pass] -e "[mysql commands]"

# mysql -h hostip -u root -pmysqlpassword -e "show databases"

Mention database to use.

Use -D option to specify the name of MySQL database :
# mysql -D [db name] -u [user] -p[pass] -e "[mysql commands]"

# mysql -D DBName -u root -pmysqlpassword -e "show tables"


Use the following syntax in your Bash scripts for running MySQL commands :

mysql -u [user] -p[pass] << EOF

[mysql commands]

EOF

Example :
#!/bin/bash
mysql -u root -pmysqlpassword << EOF
use mysql;
show tables;
EOF
 

Wednesday, May 27, 2015

Use full command

Find particular word in files. directory & subdirectory

grep -r EAJggRQ * > asdf

Find particular files. directory & subdirectory

find . -print | grep -i 'index.php'


Mobile test

curl -s -D - -A 'Mozilla/5.0 (Linux; U; Android 2.1-update1; de-de; HTC Desire 1.19.161.5 Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17' http://dsroutage.com/ > asd

Find Out apache load per process

ps aux | grep 'httpd' | awk '{print $6/1024 " MB";}'
ps -aux | grep 'httpd' | awk '{print $6/1024 " MB";}'
ps aux | grep 'httpd' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB";}'
ps aux | grep 'mysql' | awk '{print $6/1024 " MB";}')
ps aux | grep 'mysql' | awk '{print $6/1024 " MB";}'

for check memory  : free -g

most cpu & ram using process :  top -c


High load cpu & Ram using   :  ps -eo pmem,pcpu,vsize,pid,cmd | sort -k 1 -nr | head -10
Plesk Mysql login without password

mysql -uadmin -p`cat /etc/psa/.psa.shadow`

Plesk Mysql login password
/usr/local/psa/bin/admin --show-password

apache overload stop contain
vi /etc/httpd/conf.d/fcgid.conf

##FcgidIOTimeout 45
  FcgidIOTimeout 300

GracefulShutDownTimeout 3
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
FcgidMaxRequestLen 533554432

/scripts/ensure_vhost_includes --all-users

http://www.zyxware.com/articles/2714/how-to-make-custom-changes-to-virtualhost-settings-in-httpd-conf-on-a-whmcpanel-vps-without-losing-the-changes

Friday, May 8, 2015

How to reset Jenkins admin password



For reset jenkin admin password if you forgot just login server via terminal & edit

/var/lib/jenkins/users/username/config.xml file  and update the contents of passwordHash:
Replace with current with below.

#jbcrypt:$2a$10$SmpPO.crN1akTcBmuiIPhOGqVL82RtBQlgaX9u3/4CKUtFNS9Iesy

Save file and restart Jenkins service  now able to login with password “ India@123”
Sunday, April 12, 2015

How to make WHM to non secure to secure redirect permant

Once you login visit this section:

WHM >> Server Configuration >> Tweak Settings >> Redirection section and tick the top box for "Always redirect users to the SSL/TLS....." Next tick the Hostname and SSL Certificate Name respectively and save.

Closer all browser windows, then open one and go back to https://domainname:2087/ login and accept the security Certificate into your browser and you're good to go.