Thursday, October 22, 2009

Running your script at system startup on linux

Hi,

If you want to run your script at system startup e.g if you want to start jboss on system startup and stop on system shut down then create script and put it in "/etc/init.d" directory.

If you are using Debian then use 'update-rc.d' utility to install and remove System-V style init script links. Other distributions (such as Red Hat) use 'chkconfig'. You can see these utilities the you can locate files and check them.

If name of the script is say jboss then use following command

update-rc.d jboss defaults

If defaults is used, update-rc.d will make links to start the service in runlevels 2345, and stop the service in runlevels 016.

To start the script jboss in runlevels 0123 and stop in 456, run (as root):

update-rc.d jboss start 0123 stop 456

Read more: http://wiki.linuxquestions.org/wiki/Update-rc.d#ixzz0UjiBfsGM


For other distribution like red hat you can use chkconfig

Following tag needs to be added to your script so that it can be added to chkconfig
#!/bin/sh
#
# chkconfig: 2345 90 60

then you can add script by using command

chkconfig --add jboss

you can see all scripts configured by command

chkconfig --list

Regards,
Anand

Wednesday, October 14, 2009

Opening ports to outside world on linux machine

Hi,

If you want to open ports of linux machine to outside world through command line (It can be done through UI too) then follow the below steps:

Goto /etc/init.d/iptables

Add entry like: (this is for port 6667)

iptables -I INPUT -p tcp -m tcp --dport 6667 -j ACCEPT

Then restart iptables so that changes made gets effective

/etc/init.d/iptables restart

Thanks,
Anand

Running multiple jboss 5.0 instance on same machine

Hi,

I wanted to setup production and dev environment on the same machine. As both are using different database instances and I was deploying EJB application, so I couldn't use the same server and deploy two applicatione with different context roots as EJB jndi names were conflicting.

I copied jboss server dir structure and given some other name. I changed properties as needed.

I run new instance of jboss using following command which will save you from port conflicts.

run -Djboss.service.binding.set=ports-01
The above command will use port 8180 (http) and 8543 (https).

There is another way which is bit difficult i.e. change ports in various xml files.


Thank,
Anand

Thursday, October 8, 2009

Installing Verisign SSL certificate to your site

Here is example to create Certificate signing request and install the SSL certificate received from Verisign using openssl tool. (Specific to jboss, may or may not work for other servers. Visit http://www.verisign.com for further information )

1. Generate RSA private key

openssl genrsa -des3 -out domainname.key 1024

You will be promted for passphrase.

2. Create CSR (Cerificate signing request)

openssl req -new -key domainname.key -out domainname.csr

When creating a CSR you must enter information to be displayed on the certificate. E.g. Common name, Organization, Organization Unit etc

3. Send this CSR to get SSL Certificate from Verisign.

4. When you receive SSL Certificate from Verisign, you need to install it.

- Save the certificate in file name it "YourVeriSignSSLCert.crt"

- Get the intermediate CA certificate from: http://www.verisign.com/support/verisign-intermediate-ca/secure-site-intermediate/index.html and save it in a file, name it "YourIntermediateCertificate.cer"

- Command to create PKCS12 keystore

openssl pkcs12 -export -in YourVeriSignSSLCert.crt -inkey domainname.key -out mycert.p12 -name tomcat -CAfile YourIntermediateCertificate.cer -caname root -chain

5. Configure the server conf file with keystoreFile="c:\PATH TO mycert.p12" keystorePass="PASSWORD HERE" keystoreType="PKCS12"

6. Restart the server. You can check your installation status at: https://knowledge.verisign.com/support/ssl-certificates-support/index?page=certchecker

7. Once certificate installed properly you need to add Verisign seal to you site. Refer to https://www.verisign.com/ssl/secured-seal/index.html


In case if you face any issues in the installion, you can call or chat with verisign support team.

For other server installation instruction please refer to https://www.verisign.com/support/ssl-certificates-support/install-ssl-certificate.html

Thanks,
Anand