Resin Solution for Linux + Apache + PHP + JSP

Source: Internet
Author: User
Tags perl script
Article Title: Linux + Apache + PHP + JSP Resin solution. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

JSP may run faster than PHP, consume less system resources, and have more powerful functions, such as distributed processing and component support. JSP technology has been widely used in foreign countries, but in China, it is just getting hot ...... Although ASP + brings severe challenges to JSP in terms of performance, as a choice other than Microsoft, it also supports multiple platforms, so it is the first choice for many websites. In this section, we will explain three different JSP integration solutions, representing three typical application scopes.

 Resin Solution for Linux + Apache + PHP + JSP

First, we recommend Resin. Resin is a simple JSP/Servlet engine and Web server that is fast, easy to configure and implement. This is completely flawless, either on windows or UNIX/Linux platforms. However, the current Resin 1.3 is not an application server. However, the Resin 2.0 version is expected to make great breakthroughs. It includes some of the latest J2EE features. Resin has invested relatively early in JSP tags and XML parsing, and is now in a leading position. The tomcat of apache.org is more like a product for development and research. If I want to build a website, RESIN is definitely my first choice-I believe that pan Zhou thinks so too.

We will add JSP support to the WEB service solution of Linux + Apache + PHP, which may be required for your website upgrade. Even if you don't need PHP, it doesn't matter. I will explain how to do this.

1. Obtain the Software Package

JDK is all necessary to support the JSP environment, you can get it from the http://java.sun.com for linux the latest version, now seems to be JSDK v1.3.

Resin can get its latest version from its home http://www.caucho.com. In early May, its latest stable version was 1.2.5.

For more information about apache, see the previous section.

2. Install JDK

Install JDK before installing Resin. If you want to download the rpm package, you can use

Rpm-Uvh java_version.rpm

If you download the GNU compressed package, you can decompress it directly.

Do not forget to confirm some basic settings required for running java, including PATH, JAVA_HOME, and CLASSPATH. For example, you can add these rows to the/etc/profile file:

PATH=/usr/local/bin:/usr/bin:/bin:/usr/java/binexport PATHJAVA_HOME=/usr/javaexport JAVA_HOMECLASSPATH=/usr/java/lib/tools.jarexport CLASSPATH



For more information, see java.sun.com.

3. apache requirements for Resin

Resin can provide apache with a fast servlet runtime environment, allowing apache to process servlets and JSP files. However, it requires the support of Apache versions 1.3.x and DSO (Dynamic Shared Object, Dynamic Shared Object. Therefore, in the apache compilation option in the previous section, we need to add a -- enable-module = so. If you do not need PHP support, you can directly compile apache using a method similar to the following:

linux> ./configure --prefix=/usr/local/apache --enable-module=solinux> makelinux> make install



4. Compile mod_caucho.so

To compile mod_caucho.so, you need to run configure before using make. In this step, mod_caucho.so is generated and stored in the module Directory of Apache. According to our settings in section 2, mod_caucho.so will be in the/server/apache/libexec directory, otherwise it will be compiled into/usr/local/apache/libexec/mod_caucho.so.

Linux>./configure -- with-apache =/server/apache
Set the apache installation directory
/Usr/local/apache. Modify the apache directory here.
Linux> make
Linux> make install

Then you can. But if you know the location of apxs, you can use the following method to compile it:

Linux>./configure -- with-apxs =/usr/local/apache/bin/apxs
Linux> make

Apxs is a small perl script generated when apache is installed and configured. It allows modules such as resin to obtain all the configuration paths of apache. You can use whereis apxs to obtain its location.

If you need more comprehensive and detailed customization of configuration options, you can also use. the following parameters of/configure, such as apache-include, apache-libexec, and apache-conf, are described as follows:

-- With-apache = dir // The root path of Apache, that is, the installation directory specified by prefix
-- With-apxs = apxs // extension script pointing to Apache
-- With-apache-include = dir // directory where Apache contains files
-- With-apache-libexec = dir // directory of the Apache module
-- With-apache-conf = httpd. conf // Apache configuration file

5. Set Environment Variables

We have completed JDK installation and environment settings, but we also need to set the environment for resin. The following is a typical configuration. You need to manually add it ~ /. Profile or/etc/profile file.

# Resin installation path. Normally, Resin is in this directory:
RESIN_HOME = // resin1.2
Export RESIN_HOME
# If you use an extension class library, you need to add it to classpath,
# The most typical driver is the JDBC driver.
CLASSPATH = $ CLASSPATH:

6. Configure resin. conf

By default, Resin will look for JSP files in the resin1.2/doc directory, and find servlets and beans in resin1.2/doc/WEB-INF/classes. To enable Resin to use the Apache publishing document directory (that is, the root of the WWW Service we published here is/var/www/), we need to configure app-dir. Change app-dir from "doc" to/var/www or the root of the WWW publishing document you specified. The following is a typical resin. conf file.

     app-dir='/var/www/'>  servlet-name='invoker'/>servlet-name='com.caucho.jsp.XtpServlet'/>servlet-name='com.caucho.jsp.JspServlet'/>  



7. Start the Servlet Engine

Now you need to start the servlet engine. In combination with apache, resin runs independently, and the resin startup method is the same. Of course, for the script file resin1.2/bin/httpd. sh, you can also use the start and stop parameters.

linux> resin1.2/bin/httpd.shResin 1.2.s010113 -- Sat Jan 13 11:17:18 PST 2001http listening to *:8080srun listening to localhost:6802



Resin displays every port it listens. In the preceding example, the http service of Resin uses port 8080 and the servlet support protocol uses port 6802. That is to say, mod_caucho can only communicate with Resin on the local port 6802, but you can browse the contents of the Resin server on any host through port 8080.

The following section shows the configurations of http and srun in the preceding example.

 

 


...

 

Now you can use some simple scripts to test your jsp environment.

Note: wrapper. pl

Resin uses a perl script, resin1.2/bin/wrapper. pl, to control Java processes. (Bin/httpd. sh is just a micro script that calls wrapper. pl ). You can modify bin/httpd. sh or bin/wrapper. pl to set your configuration.

Wrapper. pl automatically restarts when Resin ends. If you need to use the kill command to stop Resin, you need to use the kill command to kill the wrapper. pl process ("httpd. sh stop" is implemented by kill the wrapper. pl process.

[1] [2] Next page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.