Showing posts with label Red hat linux. Show all posts
Showing posts with label Red hat linux. Show all posts

Wednesday, April 08, 2015

Add the server/service automatic startup scripts to run level during unix/linux OS reboot

This blog will guide you to add a server or service start-up script to run at start up and shutdown of Linux OS.(Same can be used for Solaris/Unix)

Step 1: Note down the command that you use to start the service.

Step 2: Prepare a script in the following format.

#/bin/bash
# chkconfig: 345 80 01  -- will explain y to use this in step 4 --
# description: App Server Startup/Shutdown script

case $1 in
start)

Script_path="/app/home/bin/path"

 if [ -f $Script_path/service_start.sh ]; then              //checks if the file exists in the directory        
  echo $"Starting Services"
  su - serviceid "-c nohup $Script_path/service_start.sh &"     //if file is present will run the command
 fi
 ;;
stop)
 if [ -f $Script_path/service_stop.sh ]; then
   echo $"Stopping Services"
   su - serviceid "-c nohup $Script_path/service_stop.sh &"
 fi
 ;;
*)
echo $"Usage: $0 {start|stop}"
//if start and stop is not passed a argument, Error will be displayed and script will exit.
exit 1
;;

Step 3: Save the script as Zscript (Z alphabet is added to ensure that the script runs at the end, You can choose any alphabet based on your priority). Give the execute permissions to the script. Place the script in /etc/init.d.

Step 4: Remember the "chkconfig: 345 80 01" added in the commented initial lines of the script? 

--> The "345" numbers indicate the run levels. 
--> "80" indicates the start priority with which the script has to run, for example a script with 79 priority will run before the script with 80 priority. 99 will be the highest priority that can be assigned to any script to run at the end.
--> "01"indicates the stop priority. It will stop first when compared to the other scripts with 02 as priority.

Step 5: Now to add this script in the desired run levels, Run the following command.

chkconfig --add Zscript

This will add the script, ie, create a softlinks for the choosen run levels. Ex : 345, were choosen in the scripts. So the script will be added as a soft link with Zscript name(80 is the priority) to /etc/init.d in /etc/rc3.d, /etc/rc4.d, /etc/rc5.d.

/etc/rc0.d -> K01Zscript
/etc/rc3.d -> S99Zscript
/etc/rc4.d -> S99Zscript
/etc/rc5.d -> S99Zscript

Once you add the Zscript to run levels, You can recheck the output using the following command.

chkconfig --list Zscript // it will give a o/p similar to following screenshot.


Step 6: To test the script now. you can be in anypath and run.

service Zscript start         //To check if the script runs at the startup of the server
service Zscript stop         // To check if the script runs at the shutdown of the server

Incase of any issues, You can comment in the comments section.

Thursday, December 11, 2014

SSL0227E: SSL Handshake Failed, Specified label could not be found in the key file

The following error is seen in the IHS logs due to the missing label from the key.kdb file.

SSL0227E: SSL Handshake Failed, Specified label could not be found in the key file.
SSL0227E: SSL Handshake Failed
 This error is seen due the SSLServerCert variable defined in httpd.conf file of IHS defined under the SSL Virtual host.

Check the hostname or the common name that is mentioned next to SSLServerCert variable.

Solution: Install the self signed or signed certificate with the common name and import it to the key.kdb.

SSL0166E: Failure attempting to load GSK library (libgsk7ssl.so) Configuration Failed

The following error will be displayed in the error_log while starting the Apache webserver after enabling the SSL module.

Error: [Tue Dec 09 00:00:18 2014] [notice] (2019)DSO load failed: SSL0166E: Failure attempting to load GSK library (libgsk7ssl.so) Configuration Failed

OS - Linux

SSL0166E: Failure attempting to load GSK library (libgsk7ssl.so) Configuration Failed
SSL0166E: Failure attempting to load GSK library (libgsk7ssl.so) Configuration Failed

 To check if the GSK library or the Key kdb file is corrupted, Use the following commands.

/opt/HTTPServer/bin/gsk7capicmd -cert -list -db key.kdb

If the following error is seen, Then it is due to the bit conflict issue between the server and the OS.

error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory

ie, If you have a 32-bit IHS installed and you don't have the supportive libraries installed in the os 32 bit libraries, (/usr/lib). The above error is seen.

To check the bit of IHS, Use the following command:

/opt/HTTPServer/bin/httpd -V

Solution: To resolve this issue, You have to find out the missing library using the following command.

yum whatprovides libstdc++.so.5

Command's output:

Loaded plugins: product-id, refresh-packagekit, rhnplugin, security, subscription-manager
This system is receiving updates from RHN Classic or RHN Satellite.
compat-libstdc++-33-3.2.3-69.el6.i686 : Compatibility standard C++ libraries

Now install the library that is required for libstdc++.so.5.

yum install compat-libstdc++-33-3.2.3-69.el6.i686

check the /usr/lib folder, The libstdc++.so.5 is listed.

Restart the IHS server, The ssl issue will be resolved.

Friday, March 28, 2014

Configuration of ssl with apache (Red hat linux) using openssl


Steps to install and configure the self signed SSL certificate with Apache on Red Hat Linux

Installation of Openssl:  

 

Step 1: Download the openssl software from (http://www.openssl.org/)
Step 2:tar -xzf openssl-1.0.1f.tar.gz
Step 3: cd openssl-1.0.1f
Step 4: ./config --prefix=/usr/openssl -fPIC no-gost no-shared no-zlib
Step 5: make
Step 6: make install

The above steps will install the openssl software in /usr/openssl. You can define the openssl path in the PATH variable.

Apache installation:

 

  ./configure --prefix=/usr/local/apache2/ --enable-mods-shared=all --enable-ssl=shared --enable-proxy=shared --enable-proxy-connect=shared --enable-proxy-ajp=shared --enable-proxy-balancer=shared --enable-proxy-ftp=shared --enable-proxy-http=shared --enable-so --with-ssl=/usr/openssl/ 

Steps to generate key,csr and crt:


/usr/openssl/bin/openssl genrsa -out commonname.key 2048 -- Generate a 2048 bit key
/usr/openssl/bin/openssl req -new -key commonname.key -out commonname.csr -- To generate a CSR
/usr/openssl/bin/openssl x509 -req -days 365 -in commonname.csr -signkey commonname.key -out commonname.crt  - To generate the selfsigned certificate

Add the ssl configuration in apache httpd.conf file:

LoadModule ssl_module modules/mod_ssl.so

<VirtualHost servername:443>
    ServerName hostname
    SSLEngine On
    SSLCertificateFile /usr/commonname.crt
    SSLCertificateKeyFile /usr/commonname.key
    SSLProxyEngine On
</VirtualHost>

Start and stop the server using -DSSL option:

apache/bin/httpd -k start -DSSL
apache/bin/httpd -k stop -DSSL

                                           

                                                          (: Happy learning :)