Tuesday, December 6, 2016

Setting Profiles for AWS Credentials in PowerShell

Following procedure descibes setting up Profiles in PowerShell for AWS Credentials/Accounts:

 
A) Obtain the AWS keys (-AccessKey and -SecretKey) from AWS IAM User Accounts

B) Run the following commands to store these keys

:> Set-AWSCredentials –AccessKey <AccessKey> –SecretKey <SecretKey> -StoredCredentials <profileName>

Repeat the above command for multiple profiles

C) Discard the current powershell and start a new one. To load the credentials into the new shell, run the same cmdlet, but this time pass the profile name you specified as the -StoredCredentials parameter:

:> Set-AWSCredentials -StoredCredentials <profileName>

D) Make Profiles added to PS Session

Right-click Windows PowerShell, and then click Run as administrator.

  1. At the Windows PowerShell prompt, type the following command, and then press ENTER:
    :> Test-path $profile
    If the results of the this command are false, go to step 2.
    If the results are true, go to step 3.
  2. Type the following command, and then press ENTER.
    :> New-item –type file –force $profile
  3. Type the following command, and then press ENTER.
    :> Notepad $profile
  4. Add the following lines, save and exit:
    Set-AWSCredentials -StoredCredentials <Profile-1>
    Set-AWSCredentials -StoredCredentials <Profile-2>
    Set-DefaultAWSRegion <Region Name>
  5. Discard the current powershell and start a new one.
    :> Get-AWSCredentials -ListProfiles

E)  Local file of profiles are stored in - C:\Users\%username%\AppData\Local\AWSToolkit\RegisteredAccounts.json.
In case they get corrupted for some reason, rename the file and add the keys.

Tuesday, October 18, 2016

Powershell Script to retrieve process details from UNIX machines

<#  
.SYNOPSIS  
Script to retrieve process details from UNIX machines. Read the credentials file for the UNIX box which are separated by # symbol as root#password

.FILE NAME

getUNIXStatus.ps1
#>


# Import the SSH libraries which is one time task as below
#iex (New-Object Net.WebClient).DownloadString("https://gist.github.com/darkoperator/6152630/raw/c67de4f7cd780ba367cccbc2593f38d18ce6df89/instposhsshdev")

$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$CredPath = $scriptDir + "\securestring.txt"

$list = @()
$flag = ""

$Credential = Get-Content $CredPath
$User = $Credential.Split("#")[0]
$Password = $Credential.Split("#")[1] | ConvertTo-SecureString -AsPlainText -Force

$creds = New-Object System.Management.Automation.PSCredential -ArgumentList $User,$Password

New-SSHSession -ComputerName "machine1" -Credential $creds
$session = Invoke-SSHCommand -Index 0 -Command "/app/oracle/opmn/bin/opmnctl status | egrep 'process0|process1|process2|process3|process4|process5'"

#Since there are 24 values in the session object for loop has been iterated till 24

for($i=0; $i -lt 24)
{
    $Obj=New-Object -TypeName PSObject -Property @{
    Name = $session.Output.Split('|')[$i+1]
    Pid = $session.Output.Split('|')[$i+2]
    Status = $session.Output.Split('|')[$i+3]
    } | Select Name, Pid, Status

    $list += $Obj

    $i = $i+4
}

# Disconnect the UNIX session
Remove-SSHSession -Index 0 -Verbose

$Output = "<HTML><TITLE>UNIX Machine Details</TITLE><BODY><font color =""orange"" face=""Comic Sans MS""><H2 align=left>UNIX Machine Details</H2></font><Table border=1 cellpadding=0 cellspacing=0><TR bgcolor=black align=center><TD><font color=""white"" face=""Comic Sans MS"">Name</font></TD><TD><font color=""white"" face=""Comic Sans MS"">Process ID</font></TD><TD><font color=""white"" face=""Comic Sans MS"">Status</font></TD></TR>"
            foreach ($listobj in $list)
            {
                if($listobj.Status -eq "Down")
                {
                    $Output += "<TR bgcolor=red>"
                    $flag = "Red"
                }
               else
                { 
                    $Output += "<TR>" 
                } 
            
                $Output += "<TD>$($listobj.Name)</TD><TD>$($listobj.Pid)</TD><TD align=center>$($listobj.Status)</TD></TR>"
            }
$Output += "</Table></BODY></HTML>"

Powershell Script to retrieve URL response

<#  
.SYNOPSIS  
Script to retrieve URL response & relevant details and save it in HTML file. URLs are read from file

.FILE NAME

URL-Response.ps1
#>

clear
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$urlsPath = $scriptDir + "\" + "URLs.txt"

$FileName = (Get-Date).tostring("dd-MM-yyyy-HH-mm-ss")
$file = $scriptDir + "\Logs\" + "URLs-" + $FileName +".htm"

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    
    public class IgnorePolicy : ICertificatePolicy {
        public IgnorePolicy() {}
        public bool CheckValidationResult(
            ServicePoint sPoint, X509Certificate cert,
            WebRequest wRequest, int certProb) {
            return true;
        }
    }
"@

$urls = Get-Content $urlsPath
$list = @()
$count = 1

foreach($url in $urls) {
    
    try{
            [System.Net.ServicePointManager]::CertificatePolicy = new-object IgnorePolicy
            $request = Invoke-WebRequest -Uri $url
            $result = Measure-Command {$request}
            $timetaken = $result.TotalMilliseconds
            $status = $request.StatusCode
            #$reslen = $request.RawContentLength

            $cusObj=New-Object -TypeName PSObject -Property @{
                TT = $timetaken
                status = $status
                #reslen = $reslen
                url = $url
                Time = Get-Date
                count = $count++
                } | Select TT,status,url,Time, count
            
            $list += $cusObj
            
         }
    
    catch {
               $_.Exception
    }
}
            $Outputreport = "<HTML><TITLE>URL Response Report</TITLE><BODY><font color =""blue"" face=""Comic Sans MS""><H2 align=left> URL Response Report </H2></font><Table border=1 cellpadding=0 cellspacing=0><TR bgcolor=black align=center><TD><font color=""white"" face=""Comic Sans MS"">S.No</font></TD><TD><font color=""white"" face=""Comic Sans MS"">URL</font></TD><TD><font color=""white"" face=""Comic Sans MS"">StatusCode</font></TD><TD><font color=""white"" face=""Comic Sans MS"">Time Captured</font></TD><TD><font color=""white"" face=""Comic Sans MS"">TimeTaken(MS)</font></TD></TR>"
            foreach ($obj in $list)
            {
                if($obj.status -ne "200")
                {
                    $Outputreport += "<TR bgcolor=yellow>" 
                }
                else
                { 
                    $Outputreport += "<TR>" 
                } 
            
                $Outputreport += "<TD>$($obj.count)</TD><TD>$($obj.url)</TD><TD align=center>$($obj.status)</TD><TD align=center>$($obj.Time)</TD><TD align=center>$($obj.TT)</TD></TR>"
            }
            $Outputreport += "</Table></BODY></HTML>"
            
            $Outputreport | Out-File $file

Wednesday, October 12, 2016

Powershell Script to Amend ASG values - AWS Cloud

<#  
.SYNOPSIS  
Amend ASG for updating & reverting Values. ASGs will be read through file

.FILE NAME
SetASGtoZero.ps1
#>

clear

Set-ExecutionPolicy Unrestricted
Set-DefaultAWSRegion -Region {Specify the region}
Set-AWSCredentials –AccessKey {Specify the Access Key} –SecretKey {Specify the Secret Key}
Import-Module 'C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1'; Initialize-AWSDefaults

$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path

$Asg_LCGFilePath = $scriptDir + "\ASG.txt"
$logOrigPath = $scriptDir + "\" + "Log_Orig.txt"
$logFilePath = $scriptDir + "\" + "Log.txt"

try
{
    $AutoScalingGroups = Get-Content $Asg_LCGFilePath

    foreach($AutoScalingGroup in $AutoScalingGroups)
    {
        $AutoScalingGroupDetails = Get-ASAutoScalingGroup -AutoScalingGroupName $AutoScalingGroup 
        $AutoScalingGroup + "#" + $AutoScalingGroupDetails.MinSize + "#" + $AutoScalingGroupDetails.DesiredCapacity >> $logOrigPath
        Update-ASAutoScalingGroup -AutoScalingGroupName $AutoScalingGroup -MinSize 0 -DesiredCapacity 0
    }
}

catch 
{
$originalException = $_.Exception 
try
{
"Error: " + $originalException.Message >> $logFilePath
}
catch

"Original Error: " + $originalException.Message >> $logFilePath
"Logging Error:" + $_.Exception.Message >> $logFilePath
}

    Exit 1
}

<#  
.SYNOPSIS  
Amend ASG for updating & reverting Values. ASGs will be read through file

.FILE NAME
RevertASG.ps1
#>

clear

Set-ExecutionPolicy Unrestricted
Set-DefaultAWSRegion -Region {Specify the region}
Set-AWSCredentials –AccessKey {Specify the Access Key} –SecretKey {Specify the Secret Key}
Import-Module 'C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1'; Initialize-AWSDefaults

$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path

$logOrigPath = $scriptDir + "\" + "Log_Orig.txt"
$logZeroPath = $scriptDir + "\" + "Log_Zero.txt"
$logFilePath = $scriptDir + "\" + "Log.txt"

try
{
    $OriginalASGValues = Get-Content $logOrigPath

    foreach($OriginalASGVal in $OriginalASGValues)
    {
        $AutoScalingGroupName = $OriginalASGVal.Split("#")[0]
        $MinVal = $OriginalASGVal.Split("#")[1]
        $DesVal = $OriginalASGVal.Split("#")[2]
        "Values are:" + $AutoScalingGroupName + " " + $MinVal + " " + $DesVal >> $logZeroPath
        Update-ASAutoScalingGroup -AutoScalingGroupName $AutoScalingGroupName -MinSize $MinVal -DesiredCapacity $DesVal >> $logZeroPath
    }
}

catch 
{
$originalException = $_.Exception 
try
{
"Error: " + $originalException.Message >> $logFilePath
}
catch

"Original Error: " + $originalException.Message >> $logFilePath
"Logging Error:" + $_.Exception.Message >> $logFilePath
}

    Exit 1
}

Powershell Script to add Notification for all ASGs - AWS Cloud

<#  
.SYNOPSIS  
Script to add Notification for all ASGs

FILE NAME

AddNotifASG.ps1
#>

$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$CommonFilePath = $scriptDir + "\AWSCredentials.ps1"
. $CommonFilePath


$Environment = "PROD"

$AutoScalingGroupName=""

try
{
   $AutoScalingGroups = (Get-ASAutoScalingGroup | Where-Object -FilterScript {
                        $_.Tags | Where-Object {
                                ($_.Key -eq "Environment" -and $_.Value -eq $Environment)
                                }             
                            }) 

    foreach($AutoScalingGroup in $AutoScalingGroups)
    {
        $AutoScalingGroupName = $AutoScalingGroup.AutoScalingGroupName
        Write-ASNotificationConfiguration -AutoScalingGroupName $AutoScalingGroupName -NotificationType @("autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_TERMINATE") -TopicARN "{Specify the ARN Value here}"
    }

}

catch 
{
$originalException = $_.Exception 
try
{
"Error: " + $originalException.Message
}
catch

"Original Error: " + $originalException.Message
"Logging Error:" + $_.Exception.Message
}

    Exit 1
}

Powershell Script to Remove Tags for ASG and associated instances - AWS Cloud

<#  
.SYNOPSIS  
Script to Remove Tags for ASG and associated instances by reading the ASG's from file

.FILE NAME
RemoveTags.ps1
#>

clear

$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path

$Asg_FilePath = $scriptDir + "\ASG.txt"

$AutoScalingGroups = Get-Content $Asg_FilePath

foreach($AutoScalingGroup in $AutoScalingGroups)
{
    $Tag = New-Object Amazon.AutoScaling.Model.Tag
    $Tag.ResourceId = $AutoScalingGroup
    $Tag.ResourceType = "auto-scaling-group"
    $Tag.Key = "{Specify the Tag Key}"
    Remove-ASTag -Tag $Tag -Force
    "Removed Tag for ASG " + $AutoScalingGroup

    $Instances = (Get-ASAutoScalingGroup -AutoScalingGroupName $AutoScalingGroup).Instances
    foreach ($Instance in $Instances)
    {
        $tag = New-Object Amazon.EC2.Model.Tag
        $tag.Key = "{Specify the Tag Key}"
        Remove-EC2Tag -Resource $Instance.InstanceId -tag $tag -Force
        "Removed Tag for Instance " + $Instance.InstanceId
    }
}

Powershell Script to retrieve Instance Details under AWS Account - AWS Cloud

<#  
.SYNOPSIS  
Script to retrieve Instance Details under AWS Account

This script will also gather last 24hrs Average CPU Value using the function getStats


.FILE NAME

Instance.ps1
#>

clear

Set-ExecutionPolicy Unrestricted
Set-DefaultAWSRegion -Region {Specify the region}
Set-AWSCredentials –AccessKey {Specify the Access Key} –SecretKey {Specify the Secret Key}
Import-Module 'C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1'; Initialize-AWSDefaults

$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path

try
{
    $Environment = "PROD"
            
    $Insts = ((Get-EC2Instance -Region {Specify the region}).RunningInstance | Where-Object -FilterScript {
                                    $_.Tags | Where-Object {
                                        ($_.Key -eq "Environment" -and $_.Value -eq $Environment )
                                    }
                                })
           
    $Instances = $Insts | Where-Object {$_.State.Name.Value -eq "Running"}
    
    $Ins = @{Expression={$_.InstanceId};Label="Instance ID"}, `
    @{Expression={$_.Tags | ? { $_.key -eq "Name" } | select -expand Value};Label="Instance Name"},
    @{Expression={$_.PrivateIpAddress};Label="Private IP"},
    @{Expression={$_.Tags | ? { $_.key -eq "Environment" } | select -expand Value};Label="Environment"},
    @{Expression={$_.Architecture};Label="Architecture"},
    @{Expression={$_.Tags | ? { $_.key -eq "Component" } | select -expand Value};Label="Component"},
    @{Expression={$_.Platform};Label="Platform"},
    @{Expression={(Get-EC2InstanceStatus -InstanceId $_.InstanceId).AvailabilityZone};Label="AvailZone"},
    @{Expression={getStats($_.InstanceId)};Label="Avg Cpu (last 24hrs)"}
        
    $Instances | Format-Table -AutoSize $Ins
}

catch 
{
$originalException = $_.Exception 
try
{
"Error: " + $originalException.Message
}
catch

"Original Error: " + $originalException.Message 
"Logging Error:" + $_.Exception.Message
}

    Exit 1
}

Function getStats($InstID)
{

    $Stats = Get-CWMetricStatistics -MetricName CPUUtilization -Dimension @{Name = "InstanceId"; Value = $InstID} -StartTime (Get-Date).AddDays(-1) -EndTime (Get-Date) -Namespace "AWS/EC2" -Period 12000 -Statistic Average | Select-Object -ExpandProperty DataPoints
    $aveCpu = $Stats | sort TimeStamp | select -ExpandProperty Average | measure -Average | select -ExpandProperty Average
    
    return $aveCpu
}

Powershell Script to retrieve Instances Status under ELB associated with ASG - AWS Cloud

<#  
.SYNOPSIS  
Script to retrieve Instances and their status under ELB aligned to ASG. Import the credentials file in the same script

.FILE NAME

LBChecks.ps1
#>

clear

$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path

$CommonFilePath = $scriptDir + "\AWSCredentials.ps1"
. $CommonFilePath

$file = $scriptDir + "\" + "Details-" + (Get-Date).tostring("dd-MM-yyyy-HH-mm-ss") + ".txt"

try
{
    $Environment = "PROD"
    
    $AutoScalingGroups = (Get-ASAutoScalingGroup | Where-Object -FilterScript {
                        $_.Tags | Where-Object {
                                ($_.Key -eq "Environment" -and $_.Value -eq $Environment)
                                }
                            }) 

    foreach($AutoScalingGroup in $AutoScalingGroups)
    {

        $ELBs = $AutoScalingGroup.LoadBalancerNames

        foreach ($elb in $ELBs)
        {
            $LBDetails = Get-ELBLoadBalancer -LoadBalancerName $elb
            foreach($Instance in $LBDetails.Instances)
            {
                $InstanceHealth = Get-ELBInstanceHealth -LoadBalancerName $elb -Instance $Instance
                $InstAvailZ = (Get-EC2InstanceStatus -InstanceId $Instance.InstanceId).AvailabilityZone
                
                if($InstanceHealth.State -eq "OutOfService")
                    { 
                     $Message = $AutoScalingGroup.AutoScalingGroupName + " || " + $Instance.InstanceId + " || " + $elb + " || " + $InstAvailZ + " || state is " + $InstanceHealth.State
                     Write-Host $Message -ForegroundColor Red
                    }
                else 
                    {
                    $Message = $AutoScalingGroup.AutoScalingGroupName + " || " + $Instance.InstanceId + " || " + $elb + " || " + $InstAvailZ + " || state is " + $InstanceHealth.State
                    Write-Host $Message -ForegroundColor Green
                    $Message >> $file
                    }
            }
        }

    }
}

catch 
{
$originalException = $_.Exception 
try
{
"Error: " + $originalException.Message
}
catch

"Original Error: " + $originalException.Message 
"Logging Error:" + $_.Exception.Message
}

    Exit 1
}

Powershell Script to RDP

<#  
.SYNOPSIS  
Script to connect multiple RDP sessions with single username/password

.FILE NAME

Connect.ps1
#>

$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$CredPath = $scriptDir + "\securestring.txt"
$IPPath = $scriptDir + "\IP.txt"

$ComputerName = Get-Content $IPPath
#"IP's are" + $ComputerName

$Credential = Get-Content $CredPath
#"Credentials given are" + $Credential

try
{  

      $ComputerName | ForEach-Object {
      $User = $Credential.Split("#")[0]
      $Password = $Credential.Split("#")[1]
     
      cmdkey.exe /generic:TERMSRV/$_ /user:$User /pass:$Password
      mstsc.exe /v:$_
      #cmdkey.exe /delete:$_
    }

}

catch
{
$originalException = $_.Exception
    "Error: " + $originalException.Message
Exit 1
}

Monday, May 23, 2016

Stuck Thread Alert in UNIX - Weblogic

Following is the script which can be used to get email alerts in case of stuck threads in weblogic (installed on UNIX machines)

ScriptName: stuckCheckMS1.sh
#!/bin/ksh
 

Somefile=/export/home/oracle/stuckLogs/ms1_stuckCheck.log
 

count="$(/usr/ucb/ps auxwww | grep ms1 | grep Dweblogic | cut -c 10-15 | tr -d ' ' | xargs /opt/oracle/products/wls10.3.6/jdk1.6.0_45/bin/sparcv9/jstack -F | tee /export/home/oracle/stuckLogs/ms1_stuck.log_`/usr/bin/date +\%m-\%d-\%y-\%H-\%M` | grep STUCK | wc -l)"

if [ $count != 0 ]
then
                        echo "\n Server MS1 has stuck threads on" `/usr/bin/date +\%m-\%d-\%y-\%H-\%M` | mail -s 'STUCK thread on MS1' Some1@gmail.com
> $Sfile
else
                        echo "\n stuck threads status=okay" > $Somefile
fi
 

exit

Admin Password Change - Weblogic

1) Stop the weblogic Managed servers

2) Export the realm

  • Login to Admin Console --> Security Realms —> myrealm(Your realm Name)—> Migration(Tab)—> Export (Tab)

3) Stop the Admin Server

4) Rename the data folder   

  • mv {DOMAIN-HOME}/servers/AdminServer/data {DOMAIN-HOME}/servers/AdminServer/data-old

5) Take Back-up of DefaultAuthenticatorInit.ldift   

  • cd {DOMAIN-HOME}\security
  • mv DefaultAuthenticatorInit.ldift DefaultAuthenticatorInit_old.ldift

6)    Set the environment variables (don’t forget "." at the beginning)

  • cd {DOMAIN-HOME}/bin
  • . /setDomainEnv.sh

7) Reset the password (don’t forget "." at the end) to generate a new DefaultAuthenticatorInit.ldift   

  • cd {DOMAIN-HOME}/security
  • java weblogic.security.utils.AdminAccount .

8) Update the boot.properties file   

  • {DOMAIN-HOME}/servers/AdminServer/security/boot.properties
        username={new-username}
        password={new-password}

9) Start the Admin Server --> startWeblogic.sh

10)    Import realm   

  • Login to Admin Console
  • Security Realms —> myrealm(Your realm Name) —> Migration(Tab) —> Import (Tab)

11)    Restart Admin Again   

  • stopWeblogic.sh
  • startWeblogic.sh

12)    Start the Managed Servers    

  • Login to Admin console with new password and Start the managed servers

Password Complexity or Password Validation - Weblogic

Step-by-Step approach to implement password complexity/password validation method for weblogic domain:

1) Login to admin console
2) Stop all the managed servers
3) Click Lock & Edit
4) Go to Security Realms and select the name of the realm you are configuring
5) Select Providers > Password Validation
6) The Password Validation Providers table lists the Password Validation providers configured in this security realm
7) Click option “New"
8) Enter any desired name (which will be suitable for your domain/requirement)
9) From the Type drop-down list, select the type of the Password Validation provider and click OK
10) Now the next step is to configure the parameters. As an example, If I select below:
1 number
1 special Character
1 lowercase
1 uppercase
 And total of 8 character password

11) Save and activate changes, followed by admin server restart
12) Create a new user to see whether it meets the requirement or change password for existing user
13) Now Start managed Servers

Friday, January 22, 2016

Upgrade JDK for Weblogic Server

Following is the process to upgrade JDK for Weblogic Servers. I took the example of JDK 1.6 to 1.7:

1) Download and Install 1.7 on the desired machine(s) where your domain is running
2) Shutdown all Servers - Admin, Managed Servers in the domain
3) Shudown Nodemanagers running on the machine
4) Verify that none of the other process are running with exiting JDK 1.6

5) Search for the files in your MW Home directory which are pointing to JDK 1.6 as below:
    find . -type f -name "*.sh" -exec grep -il jdk1.6 {} \;
   
6) The result of search will show the files such as below:

/Middleware/wlserver_10.3/common/bin/commEnv.sh
/Middleware/utils/uninstall/uninstall.sh
/Middleware/utils/quickstart/quickstart.sh
/Middleware/utils/bsu/bsu.sh
/Middleware/domains/my_domain/bin/setDomainEnv.sh

7) Take a backup of all these files

8) Now we need to edit all these files by replacing the location of JDK 1.6 to 1.7

Open each file in vi and use the following to replace all instances at a time:
%s/jdk1.6/jdk1.7/

9) Now start Admin Server and check whether the process is pointing to the new JDK:
/usr/ucb/ps auxwww | grep AdminServer

10) Once Server started, you can verify it through Admin Console as well:
Admin console --> Servers --> Admin Server --> Monitoring --> General --> Java Version

Now start Nodemanager and Managed servers.

11) If there are multiple machines in your domain, make sure you complete the above steps on all the machines before starting servers.

Thursday, January 21, 2016

Upgrade Apache Webserver

Following is the process to upgrade Apache

1) Download and Extract the new Apache binaries into /tmp/apache-new folder

2) Stop the running Apache --> /etc/init.d/httpd stop

3) Take a backup of existing config files -->

mv /usr/local/apache/conf /usr/local/apache/conf.old
cp /usr/local/apache/conf/vhosts /tmp/vhosts.old

4) Take a backup of complete Apache folder -->
mv /usr/local/apache /usr/local/apache.old

5) Create a new folder of Apache directory
mkdir -p /usr/local/apache

6) Now move to /tmp/apache-new/httpd-2.xx/ and run the following

Make sure you have noted down the required modules. If not, check the existing config logs (config.log).

./configure --enable-mods-shared="all ssl cache proxy authn_alias mem_cache file_cache charset_lite dav_lock disk_cache" --prefix=/usr/local/apache
make
make install

7) Copy the config and vhost files: /usr/local/apache/conf.old, /tmp/vhosts.old

8) Check and if required modify the script /ect/init.d/httpd to point to new httpd file

9) Now start the httpd --> /etc/init.d/httpd start
10) Check the version --> httpd –v

Configure SSL for Apache Webserver

Following is the process to enable SSL on Apache webserver with Self Signed Certificates

1)    Add the below entry in HTTPD config file (/usr/local/apache2/conf/httpd.conf) on desired machine:

# BEGIN CUSTOMIZATIONS
NameVirtualHost *:80
NameVirtualHost *:443


Include conf/vhosts/*.conf

2) Generate key:
openssl genrsa -out ca.key 2048

3)    Generate CSR:
OpenSSL> req -new -key ca.key -out ca.csr

Country Name (2 letter code) [XX]:
State or Province Name (full name) []:
Locality Name (eg, city) [Default City]:
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:*****
An optional company name []:

4)     Generate Self Signed Key
openssl x509 -req -days 3650 -in ca.csr -signkey ca.key -out ca.crt

5)    Copy the files to the correct locations
cp ca.crt /etc/pki/tls/certs
cp ca.key /etc/pki/tls/private/ca.key
cp ca.csr /etc/pki/tls/private/ca.csr

6)    Create ssl.conf with the key entries:

/usr/local/apache2/conf/ssl.conf
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key


7)    Create a new virtual host file with SSL entries as below (/usr/local/apache2/conf/vhosts vhost_crk_ssl.conf)
 

< VirtualHost *:443 >
  ServerName crk.test.com

  SSLEngine on
  SSLCertificateFile /etc/pki/tls/certsca.crt
  SSLCertificateKeyFile /etc/pki/tls/private/ca.key

****************************
****************************

< VirtualHost >


8)    Restart Apache