Apache + Tomcat static and dynamic separation

Preparing the environment:

The need software

  • jdk-8u45-linux-x64.tar.gz
  • apache-tomcat-8.5.40.tar.gz
  • apr-1.6.5.tar.gz
  • apr-util-1.6.1.tar.gz
  • pcre-8.40.tar.gz
  • httpd-2.4.39.tar.gz
  • tomcat-connectors-1.2.46-src.tar.gz

Jdk installation environment

(All the software are placed in the / usr / local / src / below)

(1) extracting jdk and placed under / usr / local / directory
CD / usr / local / the src /
the tar the xzf jdk-8u45-Linux-x64.tar.gz
Music Videos jdk1.8.0_45 /usr/local/jdk1.8
( 2) adding a system environment variable
vim / etc / profile

Tomcat installation

tar xfz apache-tomcat-8.5.40.tar.gz
mv apache-tomcat-8.5.40 /usr/local/tomcat

Installation apr

cd /usr/local/src/
tar xfz apr-1.6.5.tar.gz
yum -y install gcc-c++
cd /usr/local/src/apr-1.6.5
./configure --prefix=/usr/local/apr
make
make install

Apr installation error:
RM: CAN not the Remove 'libtoolT': No SUCH File or Directory
Solution:
modify executable files configure line 30392

Installation apr-util

cd /usr/local/src/
tar xfz apr-util-1.6.1.tar.gz
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install

Apr-util installation error:
xml / apr_xml.c: 35: 19: fatal error: expat.h: No SUCH File or Directory
Solution:
install yum -y install expat-devel

Install pcre

cd /usr/local/src/
tar xfz pcre-8.40.tar.gz
./configure --prefix=/usr/local/pcre && make && make install

Compile and install httpd

cd /usr/local/src/
tar xfz httpd-2.4.39.tar.gz
cd httpd-2.4.39
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
make
make install

Given compiler installation:
the make [2]: *** [the htpasswd] Error. 1
the make [2]: Leaving Directory /usr/local/httpd-2.4.33/support ` '
the make [. 1]: *** [All-recursive This ] Error. 1
the make [. 1]: Leaving Directory /usr/local/httpd-2.4.33/support ` '
the make: *** [All-recursive This] Error. 1
solution:
solution:
Extract the good apr and apr-util (here are just extract from the source folder) copied to /httpd-2.4.33/srclib/ go
cp -r apr-1.6.1 /usr/local/src/httpd-2.4.33/srclib/apr
cp - r apr-util-1.6.2 /usr/local/src/httpd-2.4.33/srclib/apr-util
recompile:
./configure --prefix = / usr / local / --sysconfdir = Apache / etc / the httpd --enable-so --enable-rewrite --with- apr = / usr / local / apr --with-apr-util = / usr / local / apr-util --with-pcre = / usr / local / pcre --with-included-apr && make && make install

Install the compiler module

yum -y install wget
cd /usr/local/src/
tar xfz tomcat-connectors-1.2.46-src.tar.gz
cd tomcat-connectors-1.2.46-src/native
./configure --with-apxs=/usr/local/apache/bin/apxs
make

If you make successful in the current directory apache-2 should generate a mod_jk.so, copy it to your under the apache modules.

cp mod_jk.so /usr/local/apache/modules/

Edit apache configuration file

/etc/httpd/httpd.conf vi
# adding the following
Include /etc/httpd/conf/mod_jk.conf

New mod_jk.conf and workers.properties file

mkdir / etc / httpd / the conf
# mod_jk.conf new files and workers.properties etc / httpd under / / conf directory
contents are jk # mod_jk.conf profile, comprising a loading module and log information, and the specified work is parsed and directories. 

Jk_module /usr/local/apache/modules/mod_jk.so the LoadModule
JkWorkersFile /etc/httpd/conf/workers.properties
#JkLogFile /var/log/httpd/mod_jk.log
JkLogLevel info
#JkshmFile / var / log / the httpd / the mod_jk. SHM
JkLogStampFormat "[% a% B% D% H:% M:% S% the Y]"
JkRequestLogFormat "% V% W% T"
JkMount / the servlet / * # ajp13 here ajp13 file worker is workers.properties value .list configuration must write, like, otherwise it will error
JkMount /*.jsp ajp13
JkMount /*.do ajp13
JkAutoAlias / usr / local / the Apache / htdocs

# workers.properties is Tomcat wokers profile. As follows:
worker.ajp13.port = 8009
worker.ajp13.host = 127.0.0.1
worker.ajp13.type = ajp13
worker.ajp13.lbfactor. 1 =

Start tomcat and apache service, check whether the normal start

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

/usr/local/apache/bin/apachectl start #启动apache

Creating test file

# Create html file in the server apche
 
 vi /usr/local/apache2/htdocs/test/test.html
# enter the following
 
This IS apache's html Page
 
 # created under the apache server jsp file
 
 vi / usr / local / apache2 / htdocs / Test / showtime.jsp
# enter the following
<% @ Page Language = "Java" Import = "Classes in java.util *."%>
:: IS Apache apos the this JSP Page
Now, The Time & DATE IS: <% Out.println (new new a Date ());%>

In the IE browser testing

# In the IE browser address bar, enter
HTTP: //localhost/test/showtime.jsp
# output as follows, using the jsp file under tomcat, jsp files without the use of Apahce
:: the this IS jsp Tomcat's Page Now, at The DATE iS & Time: Wed Mar 22 05:50:22 CST 2017
# input in the IE browser address bar
HTTP: //localhost/test/test.html
# output follows, apahce under html file to use, without the use of the Tomcat
This is apache's test html page

Guess you like

Origin www.linuxidc.com/Linux/2019-07/159547.htm