Labels

Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

Tuesday, May 20, 2014

org.apache.jk.common.MsgAjp cpBytes SEVERE: Overflow

May 16, 2014 6:54:01 AM org.apache.jk.common.MsgAjp cpBytes
SEVERE: Buffer overflow: buffer.len=8192 pos=8188 data=9
May 16, 2014 6:54:01 AM org.apache.jk.common.MsgAjp cpBytes
SEVERE: Overflow
java.lang.Throwable
        at org.apache.jk.common.MsgAjp.cpBytes(MsgAjp.java:196)
        at org.apache.jk.common.MsgAjp.appendByteChunk(MsgAjp.java:170)
        at org.apache.jk.common.MsgAjp.appendBytes(MsgAjp.java:155)
        at org.apache.jk.common.JkInputStream.appendHead(JkInputStream.java:311)
        at org.apache.jk.core.MsgContext.action(MsgContext.java:266)
        at org.apache.jk.core.MsgContext.action(MsgContext.java:302)
        at org.apache.coyote.Response.action(Response.java:183)
        at org.apache.coyote.Response.finish(Response.java:305)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:195)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)

        at java.lang.Thread.run(Thread.java:662)

Solution:- While running perl scripts thourgh web application we got above error .we did below change to work.
we need to default packetSize like this in mod_jk file:

<Connector ... packetSize="16384" />

Make sure you set the max_packet_size in mod_jk TO BE THE SAME VALUE,
otherwise everything will go to problem. You can go up to 65536 bytes for
the packet size if you really need to. Note that larger packet sizes may
have a performance impact.

Friday, March 21, 2014

Questions and Answers on Apache Server

Apache Server on linux
Questions and Answers: Apache Server

1. Is Apache installed?
     rpm-qa | grep httpd

2. Is Apache running?
     Ps -ef | grep httpd

3. How to start and stop Apache?

     /etc/init.d/httpd stop
     /etc/init.d/httpd start
    or go to /etc/rc3.d
     ./S85httpd stop
     ./S85httpd start
  This is a soft link. You can create if not there:
         ln -s /etc/init.d/httpd  /etc/rc3.d/S85httpd

4.Where are web files uploaded for your web site?

          /var/www/html
5.What is default home page and how do you set on LAN for local viewing of web pages?
        /var/www/html/index.html
        http://192.168.0.XX   (index.html is default home page)
6.How do you check if Apache is working on your linux computer (that has the web site):
       http://localhost/
 7. How do you setup a local domain for the web site to be seen by other computers on the LAN?

First of all, check and see if you have a file called /etc/init.d/httpd
If you do, type the following command to create a link in /etc/rc3.d
   ln -s /etc/init.d/httpd  /etc/rc3.d/S85httpd
 In order to create a local domain called testmind.com, you have to do the following steps:-
 1. Run the command:  netstat -an |grep LISTEN
 You will see what IP address port 80 is bound to. It's most likely bound to 127.0.0.1
 2. After backing up the file, edit  httpd.conf.  Look for the line where you see 127.0.01, replace it with the IP of your machine. Stop/start the web server
 3. Make sure you have an entry in your /etc/hosts, binding the machine IP to testmind.com
 4. Also make sure that this entry exists in ALL your other machines in the house. (In Windows machines, it should be in 'host' and also 'lmhosts'
 Additional Information:
 Apache files (Red Hat Linux 8):
/etc/init.d/httpd/conf/httpd.conf -configuration file
/var/www/html   - index.html, web pages
/etc/rc3.d/S85httpd  -to start Apache at boot time
/var/log/httpd  -error logs

Sunday, March 2, 2014

Step by step Apache Installation & Configuaration

Apache Installation & Configuaration

Installation made simple Steps which you can follow them

Step1: Download the any stable version of httpd for your operating environemnt (Now I am intersted in Solaris) suitable binaries given as tar/zip file (Ex: httpd-2.2.11.tar) and Extract it

tar -xvf httpd-2.2.11.tar

Step2: Go to httpd-2.2.11 directory and execute the confiure command to configure the apache in one folder (Ex: apache2)

cd httpd-2.2.11
./configure --prefix=$Home/apache2

Step3: We need to execute the below commands to build I mean compile the binaries

make
make install

Step4: take the backup of httpd.conf file

cd apache2/conf
cp httpd.conf httpd.conf_original

Step5: Edit the httpd.conf configuration file

vi httpd.conf
ServerRoot "$Home/apache2"
(ServerRoot is the path to the server's configuration, error and log files.It is possible to change this path, provided all the necessary files are copiedto the new location accordingly)
Listen IPAddress:Port (Ex: Listen 4.192.50.25:9999)
LoadModule weblogic_module modules/mod_wl_22.so
User wlusername
#main content of wl application details to update in httpd.conf file
Open tag of IfModule
#keep the info in open tag of IfModule ---mod_weblogic.c
WebLogicCluster hostname:9902,hostnamevir1:9902
MatchExpression *.jsp
close tag of IfModule
Open tag of Location
#keep /application root folder name in Lacation
SetHandler weblogic-handler
DynamicServerList ON
HungServerRecoverSecs 600
ConnectTimeoutSecs 40
WLCookieName JSESSIONID
DebugConfigInfo OFF
Debug ON
WLLogFile /$Home/apache2/logs/web1.log
ConnectRetrySecs 2
Idempotent ON
FileCaching ON
WLProxySSL OFF
SecureProxy OFF
Debug OFF
Close tag of Location

ServerAdmin sarangapani.matoori@gmail.com
ServerName 4.192.50.25 (we can use dns name , if we don't have it then we can use the ip)

Step6:copy the mod_wl_22.so module file from $Home/wl923/bea/weblogic92/server/plugin/solaris/sparc to $Home/apache2/modules
cp $Home/wl923/bea/weblogic92/server/plugin/solaris/sparc/mod_wl_22.so $Home/apache2/modules/

Step7:check the status of apche configuaration is ok
cd $Home/apache2/bin
apachectl -t
Step8: Now the starting your newly installed Apache webserver
apchectl -k start or httpd -k start

Step9: Access the application with the apache port
http://hostip:port(which%20is%20kept%20in%20httpd.conf/ file)/ProjectName/jsp/Logon.jsp
Step10: Stop the Apache
apchectl -k stop or httpd -k stop

Tuesday, August 21, 2012

What are the default port numbers for servers?

Step by step Tomcat with Apache Integration on Linux server ?

# Installing and configuring mod_jk

To make connection between Tomcat and Apache, you will need to download and install mod_jk connector.

I chose to download the current source from the Apache archives:- http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.15/

[root@map007 /]# cd /usr/local

[root@map007 local]# wget http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.15/jakarta-tomcat-connectors-1.2.15-src.tar.gz

[root@map007 local]# tar -zxvf jakarta-tomcat-connectors-1.2.15-src.tar.gz

Change to the /usr/local/jakarta-tomcat-connectors-1.2.15-src/jk/native directory.

[root@map007 local]# cd jakarta-tomcat-connectors-1.2.15-src/jk/native

Now you are ready to create the custom configure file for your system. Execute the following:

[root@map007 local]# ./buildconf.sh

[root@map007 local]# ./configure –with-apxs=/usr/bin/apxs2

Now build the mod_jk with the following:

[root@map007 local]# make

Finally, if you were successful with the previous commands, copy the newly created mod_jk.soto your Apache2 modules directory. My modules were located at /usr/lib/apache2/modules.

[root@map007 /]# cp /usr/src/jakarta-tomcat-connectors-1.2.15-src/jk/native/apache-2.0/mod_jk.so /usr/lib/apache2/modules
 # Configuring Tomcat and Apache

[root@map007 /]# vi /etc/apache2/workers.properties

workers.tomcat_home=/usr/lib/apache-tomcat

workers.java_home=/usr/lib/jdk

ps=/

worker.list=worker1

worker.default.port=8009

worker.default.host=localhost

worker.default.type=ajp13

worker.default.lbfactor=1

  # Save and close the file.

# Now you have to configure httpd.conf file and following lines.

[root@map007 /]# vi /etc/apache2/httpd.conf

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

# Where to find workers.properties

JkWorkersFile /etc/apache2/workers.properties

# Where to put jk logs

JkLogFile /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]

JkLogLevel info

# Select the log format

JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “

Save and close the file.

Now a final security point.

[root@map007 /]# chown -R tomcat:tomcat /usr/lib/apache-tomcat-5.5.16

# Now restart the Tomcat.

[root@map007 /]# cd /usr/local/tomcat/bin

[root@map007 bin]# ./shutdown.sh

[root@map007 bin]# ./startup.sh

And restart Apache:

[root@map007 /]# /etc/init.d/apache2 restart

You have Done all the Configurations.

Note :- Start Tomcat first: Always start Tomcat first and then start Apache.
References and paths:

Tomcat conf:

/usr/lib/apache-tomcat/conf/server.xml

Apache modules:

/usr/lib/apache2/modules

Apache conf:

/etc/apache2/workers.properties

/etc/apache2/httpd.conf

Tomcat stop and start:

cd /usr/local/apache-tomcat/bin

./shutdown.sh

./startup.sh

Apache2:

/etc/init.d/apache2 restart

/etc/init.d/apache2 stop

/etc/init.d/apache2 start

Step by step Installation Tomcat on Linux ?

Download and Install JAVA

Download j2sdk-<version> from Sun Download center http://developers.sun.com/downloads/


# chmod +x j2sdk-1_4_2_09-linux-i586.bin

# ./j2sdk-1_4_2_09-linux-i586.bin

Now set java home path

# vi .bash_profile

JAVA_HOME=/usr/local/j2sdk

Now Check if Java is installed on the server using command java -version

[root@map ~]# java -version

java version “1.6.0_07?

Java(TM) SE Runtime Environment (build 1.6.0_07-b06)

Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

# Download Tomcat

Now Download Tomcat from Apache Website and extract it

http://tomcat.apache.org/download-55.cgi

# cd /usr/local/

#wget http://www.poolsaboveground.com/apache/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz

# tar -zxvf apache-tomcat-6.0.18.tar.gz

Create Symlink for the Tomcat Folder

# ln -s /usr/local/apache-tomcat-6.0.18 /usr/local/apache/tomcat

# Install Tomcat

# cd apache-tomcat-6.0.18

# cd bin

# tar xvfz jsvc.tar.gz

# cd jsvc-src

# chmod +x configure

# ./configure

# make

# cp jsvc ..

# cd ..

Now set Cataline home path


# vi .bash_profile

CATALINA_HOME=/usr/loca/tomcat

JAVA=/usr/loca/j2sdk/bin

Save and exit

# Type following commands

# export JAVA_HOME=/usr/local/j2sdk

# export JAVA=/usr/local/j2sdk/bin

# export CATALINA=/usr/local/tomcat

# Start Tomcat

Use Following script to start Tomcat Service on the Server

# /usr/local/apache/tomcat/bin/startup.sh

# Running Tomcat as non root user

Due to security reasons always run tomcat as non-root user i.e. tomcat. To run it as tomcat first you will have to change the ownership of the tomcat folder

# chown -R tomcat.tomcat /usr/local/apache-tomcat-6.0.18

Now Tomcat can be stopped and started under user tomcat using following commands:

# su -l tomcat -c /usr/local/apache/tomcat/bin/startup.sh

# su -l tomcat -c /usr/local/apache/tomcat/bin/shutdown.sh

# Test Tomcat installation

open a browser and browse website http://xx.xx.xx.xx:8080 where xx.xx.xx.xx will be your Server IP and If you get Tomcat page than Tomcat has been installed properly on the Server.

# Creating Script to start, stop and restart Tomcat

The above installation step will not create tomcat service so that user can restart tomcat using command service tomcat restart. Create a new file in /etc/init.d as tomcat and copy following contenents into it.

# vi /etc/init.d/tomcat

#!/bin/bash

#

# Startup script for Tomcat

#

# chkconfig: 345 84 16

# description: Tomcat jakarta JSP server

# Necessary environment variables

export CATALINA_HOME=”/usr/local/tomcat”

if [ ! -f $CATALINA_HOME/bin/catalina.sh ]

then

echo “Tomcat not available…”

exit

fi

start() {

echo -n -e ‘\E[0;0m'"\033[1;32mStarting Tomcat: \033[0m \n"

su -l tomcat -c $CATALINA_HOME/bin/startup.sh

echo

touch /var/lock/subsys/tomcatd

sleep 3

}

stop() {

echo -n -e '\E[0;0m'"\033[1;31mShutting down Tomcat: \033[m \n"

su -l tomcat -c $CATALINA_HOME/bin/shutdown.sh

rm -f /var/lock/subsys/tomcatd

echo

}

status() {

ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start” | awk ‘{printf $1 ” “}’ | wc | awk ‘{print $2}’ > /tmp/tomcat_process_count.txt

read line < /tmp/tomcat_process_count.txt

if [ $line -gt 0 ]; then

echo -n “tomcatd ( pid ”

ps ax –width=1000 | grep “[o]rg.apache.catalina.startup.Bootstrap start” | awk ‘{printf $1 ” “}’

echo -n “) is running…”

echo

else

echo “Tomcat is stopped”

fi

}

case “$1? in

start)

start

;;

stop)

stop

;;

restart)

stop

sleep 3

start

;;

status)

status

;;

*)

echo “Usage: tomcatd {start|stop|restart|status}”

exit 1

esac

Now save and exit from the file. Now assign executable permission to this file

# chown 755 /etc/init.d/tomcat

Enable it for all the Run-levels

# chkconfig –add tomcat

# chkconfig tomcat on

Now you can restart tomcat service using following commands.

# service tomcat restart <<< To restart tomcat

# service tomcat stop <<< To stop Tomcat

# service tomcat start <<< To start Tomcat

# service tomcat Status <<< to check the status of Tomcat

Now you have successfully installed Tomcat.

Steps to check Apache connection and error log ?

Below is the details.

date;netstat -ant | grep 80 | grep TIME_WAIT | wc -l

cat /etc/httpd/conf/httpd.conf | grep MaxClients

head /var/log/httpd/error_log

Apache Server Interview Questions and Answers for Linux adminisration?


Q: - What is location of log files for Apache server ?
/var/log/httpd
Q: - What are the types of virtual hosts ?

name-based and IP-based.
Name-based virtual host means that multiple names are running on each IP address.
IP-based virtual host means that a different IP address exists for each website served. Most configurations are named-based because it only requires one IP address.
Q: - How to restart Apache web server ?

service httpd restart
Q: - How to check the version of Apache server ?

rpm -qa |grep httpd
Q: - What is meaning of "Listen" in httpd.conf file ?

Port number on which to listen for nonsecure (http) transfers.
Q: - What is DocumentRoot ?

it is a location of files which are accessible by clients. By default, the Apache HTTP server in RedHat Enterprise Linux is configured to serve files from the /var/www/html/ directory.
Q: - On which port Apache server works ?

http - port 80
https - port 443
Q: - Tell me name of main configuration file of Apache server ?

httpd.conf
Q: - On which version of apache you have worked ?

httpd-2.2.3
Q: - What do you mean by a valid ServerName directive?

The DNS system is used to associate IP addresses with domain names. The value of ServerName is returned when the server generates a URL. If you are using a certain domain name, you must make sure that it is included in your DNS system and will be available to clients visiting your site.
Q: - What is the main difference between <Location> and <Directory> sections?

Directory sections refer to file system objects; Location sections refer to elements in the address bar of the Web page
What is the difference between a restart and a graceful restart of a web server?

During a normal restart, the server is stopped and then started, causing some requests to be lost. A graceful restart allows Apache children to continue to serve their current requests until they can be replaced with children running the new configuration.
Q: - What is the use of mod_perl module?

mod_perl scripting module to allow better Perl script performance and easy integration with the Web server.
Q: - If you have added “loglevel Debug” in httpd.conf file, than what will happen?

 It will give you more information in the error log in order to debug a problem.
Q: - Can you record the MAC (hardware) address of clients that access your server.

No
Q: - Can you record all the cookies sent to your server by clients in Web Server logs?

Yes, add following lines in httpd.conf file.

CustomLog logs/cookies_in.log "%{UNIQUE_ID}e %{Cookie}i" CustomLog logs/cookies2_in.log "%{UNIQUE_ID}e %{Cookie2}i"
Q: - Can we do automatically roll over the Apache logs at specific times without having to shut down and restart the server?

Yes
Use CustomLog and the rotatelogs programs

Add following line in httpd.conf file. CustomLog "| /path/to/rotatelogs/path/to/logs/access_log.%Y-%m-%d 86400" combined
Q: - What we can do to find out how people are reaching your site?

Add the following effector to your activity log format. %{Referer}
Q: - If you have only one IP address, but you want to host two web sites on your server. What will you do?
In this case I will use Name Based Virtual hosting.
ServerName 10.111.203.25
NameVirtualHost *:80
<VirtualHost *:80>
ServerName web1.test.com
DocumentRoot /var/www/html/web1
</VirtualHost>

<VirtualHost *:80>
ServerName web2.test2.com
DocumentRoot /var/www/html/web2
</VirtualHost>
Q: - Can I serve content out of a directory other than the DocumentRootdirectory?


Yes, by using “Alias” we can do this.
Q: - If you have to more than one URL map to the same directory but you don't have multiple Alias directives. What you will do?

In this case I will use “AliasMatch” directives.

The AliasMatch directive allows you to use regular expressions to match arbitrary patterns in URLs and map anything matching the pattern to the desired URL.
Q: - How you will put a limit on uploads on your web server?

This can be achieved by LimitRequestBody directive.
<Directory "/var/www/html/data_uploads">
LimitRequestBody 100000
</Directory>
Here I have put limit of 100000 Bytes
Q: - I want to stop people using my site by Proxy server. Is it possible?


<Directory proxy:http://www.test.com/myfiles>
Order Allow,Deny
Deny from all
Satisfy All
</Directory>
Q: - What is mod_evasive module?

mod_evasive is a third-party module that performs one simple task, and performs it very well. It detects when your site is receiving a Denial of Service (DoS) attack, and it prevents that attack from doing as much damage. mod_evasive detects when a single client is making multiple requests in a short period of time, and denies further requests from that client. The period for which the ban is in place can be very short, because it just gets renewed the next time a request is detected from that same host.
Q: - How t to enable PHP scripts on your server?

If you have mod_php installed, use AddHandler to map .php and .phtml files to the PHP handler. AddHandler application/x-httpd-php .phtml .php
Q: - Which tool you have used for Apache benchmarking?

ab (Apache bench)
ab -n 1000 -c 10 http://www.test.com/test.html
Q: - Can we cache files which are viewed frequently?

Yes we can do it by using mod_file_cache module.
CacheFile /www/htdocs/index.html
Q: - Can we have two apache servers having diff versions?
Yes, you can have two different apache servers on one server, but they can't listen to the same port at the same time.Normally apache listens to port 80 which is the default HTTP port. The second apache version should listen to another port with the Listen option in httpd.conf, for example to port 81.

For testing a new apache version before moving your sites from one version to another, this might be a good option.You just type www.example.com:81 in the browser window and you will be connected to the second apache instance.

Steps to start and stop apache server in linux

you need to type the following command to start the apache server

$>service httpd start

or

$>/etc/init.d/httpd start

To stop the server

$>service httpd stop

or

$>/etc/init.d/httpd stop

Friday, July 6, 2012

Apache Interview Questions & Answers

Q: - Can you record all the cookies sent to your server by clients in Web Server logs?

Yes, add following lines in httpd.conf file.
CustomLog logs/cookies_in.log "%{UNIQUE_ID}e %{Cookie}i" CustomLog logs/cookies2_in.log "%{UNIQUE_ID}e %{Cookie2}i"


Q: - Can we do automatically roll over the Apache logs at specific times without having to shut down and restart the server?
Yes
Use CustomLog and the rotatelogs programs
Add following line in httpd.conf file. CustomLog "| /path/to/rotatelogs /path/to/logs/access_log.%Y-%m-%d 86400" combined

Q: - What we can do to find out how people are reaching your site?

Add the following effector to your activity log format. %{Referer}

Q: - How you will put a limit on uploads on your web server?

This can be achieved by LimitRequestBody directive.

<Directory "/var/www/html/data_uploads">
LimitRequestBody 100000
</Directory>
Here I have put limit of 100000 Bytes


Q: - I want to stop people using my site by Proxy server. Is it possible?

<Directory proxy:http://www.test.com/myfiles>
Order Allow,Deny
Deny from all
Satisfy All
</Directory>


Q: - What is mod_evasive module?

mod_evasive is a third-party module that performs one simple task, and performs it very well. It detects when your site is receiving a Denial of Service (DoS) attack, and it prevents that attack from doing as much damage. mod_evasive detects when a single client is making multiple requests in a short period of time, and denies further requests from that client. The period for which the ban is in place can be very short, because it just gets renewed the next time a request is detected from that same host.





Q: - How t to enable PHP scripts on your server?
If you have mod_php installed, use AddHandler to map .php and .phtml files to the PHP handler. AddHandler application/x-httpd-php .phtml .php




Q: - Which tool you have used for Apache benchmarking?

ab (Apache bench)
ab -n 1000 -c 10 http://www.test.com/test.html




Q: - Can we cache files which are viewed frequently?

Yes we can do it by using mod_file_cache module.
CacheFile /www/htdocs/index.html




Q: - What is location of log files for Apache server ?

/var/log/httpd



Q: - What are the types of virtual hosts ? ?

name-based and IP-based.
Name-based virtual host means that multiple names are running on each IP address.
IP-based virtual host means that a different IP address exists for each website served. Most configurations are named-based because it only requires one IP address.



Q: - How to restart Apache web server ?
service httpd restart





Q: - How to check the version of Apache server ?

rpm -qa |grep httpd




Q: - What is meaning of "Listen" in httpd.conf file ?

Port number on which to listen for nonsecure (http) transfers.


Q: - What is DocumentRoot ?

it is a location of files which are accessible by clients. By default, the Apache HTTP server in RedHat Enterprise Linux is configured to serve files from the /var/www/html/ directory.





Q: - On which port Apache server works ?

http - port 80
https - port 443


Q: - Tell me name of main configuration file of Apache server ?

httpd.conf



Q: - On which version of apache you have worked ?

httpd-2.2.3



Q: - What do you mean by a valid ServerName directive?
The DNS system is used to associate IP addresses with domain names. The value of ServerName is returned when the server generates a URL. If you are using a certain domain name, you must make sure that it is included in your DNS system and will be available to clients visiting your site.




Q: - What is the main difference between <Location> and <Directory> sections?

Directory sections refer to file system objects; Location sections refer to elements in the address bar of the Web page



Q: - What is the difference between a restart and a graceful restart of a web server?

During a normal restart, the server is stopped and then started, causing some requests to be lost. A graceful restart allows Apache children to continue to serve their current requests until they can be replaced with children running the new configuration.


Q: - What is the use of mod_perl module?
mod_perl scripting module to allow better Perl script performance and easy integration with the Web server.


Q: - If you have added “loglevel Debug” in httpd.conf file, than what will happen?

It will give you more information in the error log in order to debug a problem.


Q: - Can you record the MAC (hardware) address of clients that access your server.

No