Monday, April 7, 2014

Type of Issues which we get under Apache Tomcat

Type of Issues which we get under Apache/Tomcat:-
=====================================================================
A. Reducing the file size by compressing the existing files to reduce the used space on server.
  1. First we need to check the size of file system. File size of the different file systems can be known by command df -k 
  2. 1.       We can always check for file of bigger size and compress them if they are not compressed.
    sudo find . –size +5000000 |more
  3.  Suppose you have got the output of last command as :- “/export/apps/apache/app_instance/logs/access_log” , then go to the path where this file exists... path should be something like "/export/apps/apache/app_instance/logs"
  4. Then you need to go to the bin folder of this particular application, example for this file: - /export/apps/apache/app_instance/bin and then you have to stop the apache services with command - “sudo ./apachectl stop” 
  5. And to check if the instances are stopped or not then we need to run a command that will be: - “ps -ef|grep -i”.
  6. Once you are confirmed that all the instances are stopped then go and rename the file i.e. :- “sudo mv access_log access_log_current_date”.Once, name of file is change you can zip the log with command “sudo gzip access_log_current date”.
  7.  Now you can again check the file system with command df -k. It will be surely reduced file system then before. Side wise we should also restart the apache service that stopped, for this we will again have to go to “bin” directory (/export/apps/apache/app_instance/bin) and command  “sudo ./apachectl start” can be used to start the apache service.
  8. So once the services are started you need to do check the log directory if the new log file has been created or not and you need to do the same steps for all the files which you find under large files.
Note :- At times when we get other files as large files we need to check the time stamp of the files so that we can zip the files.

===================================================================


B. To redirect a particular website or a particular address to a different address.


Single address redirect can be done by adding a line to the conf file where the site is hosted.



Two types of redirection can be done.

1.)     Domain  redirection
2.)     Web page redirection.


1.)     Domain Redirection
Domain redirection is to redirect whole domain to of site to another site.
Above domain needs redirects to another site http://xxx5.lvs.domain1.com/dir4/dir5/     
NoteHost name –“dir4” must be mentioned in documented root as virtually
Document Root: /dir1/dir2/dir3/ (check on the path)

Open “httpd.conf” of apache in which you want to make the redirection.Use vi editor (make sure take the backup of configuration file before any changes in it)

  Run command - vi “httpd.conf” and then add
    Document Root /dir1/dir2/dir3/dir4/dir5/ 
    Server Name        www.a1.domain1.com 
    Server Alias         a1.domain1.com 
    Redirect permanent  /   http://xxx5.lvs.domain1.com/dir4/dir5/ 

There after recycle same Apache to affect the changes.

2.)     Web page redirection.
Web page redirection is permanent redirection of link to another link; it redirects always link to domain or link to domain+directoty/link – (whole web page).

Link - /dir1/dir2/

It will redirect the link “/dir1/dir2/” to desired web page, it does not take prefixed domain name
Whatever the domain name is prefixed to link it will redirect to desired web page.
User wants to redirect the link - /dir1/dir2/  which is mentioned in documented root of  application, to http://qwerty.domain.com/display/ddmx/Home.
Whatever domain prefixed   to link it ignores the domain and redirects the link to desired site.
Example:
xxx1.lvs.domain.com/dir1/dir2/ 
or xxx2.lvs.domain.com/dir1/dir2/  
or xxx5.lvs.domain.com/dir1/dir2/  
after changes in configuration for redirection to desired site, it will concentrate to link only and open the other site.
                                     http://qwerty.es.domain.com/a/b/Home.

Path - :/export/apps/apache/Apache2.0.54/conf
File - httpd.conf
Vi httpd.conf and add the below line in redirection parameter of file.

Redirect permanent   /dir1/dir2/index.html  “http://qwerty.es.dupont.com/a/b/Home

Recycle Apache after addition in file to affect the changes.

Note;- Before redirecting, first we need to check if single address needs to be redirected to a different address or a new website is hosted on our server



=====================================================================


C. To change the look of the URL

Re-write Engine modifies a web URL's appearance. This modification is called URL rewriting. Rewritten URLs are used to provide shorter and more relevant-looking links to web pages.
Re-write redirects the URL to the directory of webapps in which war file is deployed. It redirects the URL of application to folder where war file of application is deployed.
Let’s take an example
There is a URL - http://app-dev.lvs.domain1.com , if we click on URL then the actual web page does not come up, it opens “tomcat successfully installation page”. The actual web page is http://app-dev.lvs.domain1.com/app-war-d . I had to write complete URL along with /app-war-d.  to  get the actual web page.

Re-write rule comes in picture now; Re-write engine redirect the JK_Mount in httpd.conf file in instance directory on server.
Login to the server on which the application is hosted .Go to the directory of apache of instance and make changes in httpd.conf file of application.
Export/apps/apache//conf

vi edit the httpd.con file. There is Re-write Engine Module in configuration file.

JK Mount mounting application to URL
Uncomment the RewriteRule by remove the “# key” and then replace the re-write folder name with the name of folder in which war file of application is deployed. Navigate the directory export/apps/tomcat///webapps , in webapps there could be folder(suppose 'app-air-d') in which war file must be deployed , so use the name of that folder in which war file deployed.

RewriteEngine On
RewriteRule  ^/$  /app-air-d/ [R]
#JkMount /* app-dev

Recycle the apache of instance to get the changes affected. Try to open the URL http://app-dev.lvs.domain1.com and it will redirect to substitute directory http://app-dev.lvs.domain.com/app-war-d.

@ Important


  1. Make sure Re-write Engine should be ON, in httpd.conf file of apache.
  2. An ISO file mod_rewrite.so file must be saved on module director of apache. I fit is not there then download it and copy into module directory. 
=====================================================================

D. MIME TYPE updation
The Multipurpose Internet Mail Extensions (MIME) types file contains mappings between file extensions and MIME types. This file is utilized during request processing to tell the server what type of resource is being requested. It bases this information on the extension of the resource (such as .txt, .html, or .cgi) and associates a type, language, or encoding method based on the extension.
Multipurpose Internet Mail Extensions (MIME) is an Internet standard that extends the format of email to support.
An Internet media type is a standard identifier used on the Internet to indicate the type of data that a file contains.
email clients use them to identify attachment files,
    web browsers use them to determine how to display or output files that are not in HTML format,
    search engines use them to classify data files on the web.
  
There are 3 things in MIMI TYPE updations
1.    File Type – Characteristics of the file , weather it is HTML , EXEL , WORD DOC., PPT like ...
2.    File Extension – The Extension of file after “.” .doc, .xls, .ppt,.html.
3.    MIMI TYPE - Type of Application format. Like template , micro

MIMI TYPE is arranged alphabetically, The MIMI TYPE is divided in 3 parts and all 3 parts are arranged alphabetically.
Example.
application/vnd.openxmlformats-officedocument.wordprocessingml.document  
application/vnd.ms-word.document.macroEnabled.12  
application/vnd.openxmlformats-officedocument.wordprocessingml.template  
application/vnd.ms-word.template.macroEnabled.12  
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet  
application/vnd.ms-excel.sheet.macroEnabled.12  
application/vnd.openxmlformats-officedocument.spreadsheetml.template  
application/vnd.ms-excel.template.macroEnabled.12  
application/vnd.ms-excel.sheet.binary.macroEnabled.12  
application/vnd.ms-excel.addin.macroEnabled.12  
application/vnd.openxmlformats-officedocument.presentationml.presentation  
application/vnd.ms-powerpoint.presentation.macroEnabled.12  
application/vnd.openxmlformats-officedocument.presentationml.slideshow  
application/vnd.ms-powerpoint.slideshow.macroEnabled.12  
application/vnd.openxmlformats-officedocument.presentationml.template  
application/vnd.ms-powerpoint.template.macroEnabled.12  
application/vnd.ms-powerpoint.addin.macroEnabled.12  
application/vnd.openxmlformats-officedocument.presentationml.slide  
application/vnd.ms-powerpoint.slide.macroEnabled.12  
application/onenote  
application/onenote  
application/onenote  
application/onenote  
application/vnd.ms-officetheme
Alphabetically arranged MIMI TYPE at below.
application/onenote  
application/onenote  
application/onenote  
application/onenote  
application/vnd.ms-excel.addin.macroEnabled.12  
application/vnd.ms-excel.sheet.binary.macroEnabled.12  
application/vnd.ms-excel.sheet.macroEnabled.12  
application/vnd.ms-excel.template.macroEnabled.12  
application/vnd.ms-officetheme
application/vnd.ms-powerpoint.addin.macroEnabled.12  
application/vnd.ms-powerpoint.presentation.macroEnabled.12  
application/vnd.ms-powerpoint.slideshow.macroEnabled.12  
application/vnd.ms-powerpoint.slide.macroEnabled.12  
application/vnd.ms-powerpoint.template.macroEnabled.12  
application/vnd.ms-word.document.macroEnabled.12  
application/vnd.ms-word.template.macroEnabled.12  
application/vnd.openxmlformats-officedocument.presentationml.presentation  
application/vnd.openxmlformats-officedocument.presentationml.slideshow  
application/vnd.openxmlformats-officedocument.presentationml.slide  
application/vnd.openxmlformats-officedocument.presentationml.template  
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet  
application/vnd.openxmlformats-officedocument.spreadsheetml.template  
application/vnd.openxmlformats-officedocument.wordprocessingml.document  
application/vnd.openxmlformats-officedocument.wordprocessingml.template  
Please go through the above example to arrange the MIMI TYPE.








No comments:

Post a Comment