A Development Environment Integrating JSP, PHP, and JAVA

Source: Internet
Author: User
Tags zts
A Development Environment Integrating JSP, PHP, and JAVA-general Linux technology-Linux programming and kernel information. For details, see the following. Preface

This article introduces the establishment of a Development Environment Integrating JSP, PHP, and JAVA. To meet the needs of most beginners, many steps are easy to use and strive to be simple and clear. Generally, I use RPM to install software without special requirements. If you have special requirements such as optimized configuration and security considerations, please refer to relevant articles for configuration.

In this article, Apache is installed in DSO mode, and PHP supports JAVA components, so that PHP can be used as the Front-End scripting language during large-scale project development, call JAVA components to implement underlying and enterprise-level applications.


1. System Environment

1. Initial installation

Open firewall interfaces:, eth0

Redhat in Linux 9.0

Development Tools

Network Servers

VSFtp

CVS-1.11.2-10

MySQL 3.23.54


2. Package Installation

JDK 1.4.2 _ 04

: Http://www.netshine.com.cn/linux/j2sdk-1_4_2_04-linux-i586.rpm

Tomcat 5.0.19

: Http://www.netshine.com.cn/linux/jakarta-tomcat-5.0.19.tar.gz


3. Script Installation

Webmin 1.110

: Http://www.netshine.com.cn/linux/webmin-1.110.tar.gz

ZendOptimizer 2.5.1

: Http://www.netshine.com.cn/linux... glibc21-i386.tar.gz


4. manual compilation

Apache 2.0.49

: Http://www.netshine.com.cn/linux/httpd-2.0.49.tar.gz

PHP 4.3.5

: Http://www.netshine.com.cn/linux/php-4.3.5.tar.gz

JK 2-2.0.4

: Http://www.netshine.com.cn/linux... -src-current.tar.gz


5. Client Environment

Windows XP Professional

Absolute Telnet 3.0

Zend Encoder

Macromedia Dreamweaver MX 2004

Borland JBuilder 9 Enterprise

Win CVS 1.3

: Http://www.netshine.com.cn/linux/WinCvs13b17.zip


Ii. System Installation

Start the Linux installation CD and install the basic system FTP, development tools, and MySQL3.23.54. If you compile and install MySQL manually, remember to specify the specific MySQL path when compiling PHP or other programs. Otherwise, compilation errors may occur because the path cannot be found.


3. Install webmin1.110

Webmin can be used to configure the system, which is foolish and can save a lot of effort. Therefore, I usually install it first. The installation process is very simple. Execute the setup. sh script and follow the prompts to start step by step.

--------------------------------------------------------------------

# Cd webmin *

#./Setup. sh

----------------------------------------------------------------------


4. Install JDK1.4.2

1. Edit the following three files without specifying the full path in your home directory.

/Etc/profile

JAVA_HOME =/usr/java/j2sdk1.4.2 _ 04

CLASSPATH =.: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib

CVSROOT =/usr/local/cvsroot

PATH =.: $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin: $ PATH

Export JAVA_HOME CLASSPATH CVSROOT PATH


/Etc/ld. so. conf

/Usr/java/j2sdk1.4.2 _ 04/jre/lib/i386

/Usr/java/j2sdk1.4.2 _ 04/jre/lib/i386/server


HelloWorld. java

Class HelloWorld

{

Public static void main (String [] args)

{

// Test whether the Java environment is successfully installed.

System. out. println ("Hello World! ");

}

}


2. Run the following command:

-------------------------------------------------------------------

# Rpm-ivh j2sdk *. rpm // install the JDK package.

# Source/etc/profile // reload the profile environment.

# Ldconfig // create a dynamic link library cache file.

# Javac-d. HelloWorld. java // compile the test file.

# Java HelloWorld // run the program to test whether the installation is successful.

------------------------------------------------------------------


5. install Apache

------------------------------------------------------------------

# Tar xvzf httpd * // extract the source code package.

# Cd httpd * // enter the installation directory.

#./Configure -- prefix =/usr/local/apache -- enable-so -- enable-mod-shared = most -- enable-rewrite

# Make; make install // compile and install.

----------------------------------------------------------------

Note:

-- Enable-so option: enables Apache to support the DSO mode. Note that the Apache2.0 syntax is used here. If your Apache version is 1.3, change it to -- enable-module = so.

-- Enable-mod-shared = most option: tells the compiler to compile all standard modules into DSO modules. If you use Apache1.3, change it to -- enable-shared = max.

-- Enable-rewrite option: supports address rewriting. If you are using version 1.3, change it to -- enable-module = rewrite.


6. Compile and install PHP

1. Execute the command

-------------------------------------------------------------------

# Tar xvzf php * // decompress the source code package

# Cd php * // enter the PHP installation command

#. /Configure -- prefix =/usr/local/php -- with-mysql -- with-apxs2 =/usr/local/apache/bin/apxs -- with-java =/usr/java/j2sdk1.4.2 _ 04

# Make; make install // compile and install

# Cp php. ini-dist/usr/local/php/lib/php. ini // copy the php configuration file

# Cd/usr/local/php/lib/php/extensions/no-debug-non-zts-20020429 // extensions directory

# Ln-s java. so libphp_java.so // establish a connection. If you forget it, an error will occur.

# Cd Zend * // enter the ZendOptimizer directory

#./Install // install the PHP accelerator

---------------------------------------------------------------------

Note:

-- With-apxs2 =/usr/local/apache/bin/apxs is the syntax of Apache2. For versions 1.3, use -- with-apxs =/usr/local/apache/bin/apxs.


2. Edit the following three files

/Usr/local/apache/conf/httpd. conf

LoadModule php4_module modules/libphp4.so


AddType application/x-httpd-php. php

AddType application/x-httpd-php-source. phps


Adddefacharcharset gb2312


/Usr/local/apache/htdocs/test. php

// This program tests whether the JAVA environment of PHP is available. The code is extracted from http://www.php.net/manual/en/ref.java.php.


// Get instance of Java class java. lang. System in PHP

$ System = new Java ('java. lang. system ');


// Demonstrate property access

Echo 'java version = '. $ system-> getProperty ('java. version ').'
';

Echo 'java vendor = '. $ system-> getProperty ('java. upload ').'
';

Echo 'OS ='. $ system-> getProperty ('OS. name ').''.

$ System-> getProperty ('OS. version'). 'On '.

$ System-> getProperty ('OS. arch ').'
';


// Java. util. Date example

$ Formatter = new Java ('java. text. simpledateformat ',

"EEEE, MMMM dd, yyyy 'at' h: mm: ss a zzzz ");


Echo $ formatter-> format (new Java ('java. util. date '));

?>


/Usr/local/php/lib/php. ini

Register_globals = On

[Java]

Java. class. path =/usr/local/php/lib/php/php_java.jar:/home/jim/myclass

Java. home =/usr/java/j2sdk1.4.2 _ 04

Java. library =/usr/java/j2sdk1.4.2 _ 04/jre/lib/i386/libjava. so

Java. library. path =/usr/local/php/lib/php/extensions/no-debug-non-zts-20020429

Extension_dir =/usr/local/php/lib/php/extensions/no-debug-non-zts-20020429

Extension = libphp_java.so


Note:

(1). If you have just switched from the old version of PHP to the new version, you may find that many of your PHP programs are useless. Don't be nervous! It's okay to open register_globals! This is because the register_globals of the old version of PHP is open by default, but the new version is disabled.

(2)./home/jim/myclass is the path for storing JAVA components. You can modify the path according to the actual situation, but do not place it in the web directory for security reasons.


7. install Tomcat

1. Execute the following command

------------------------------------------------------------------------

# Cd * jk2 */jk/native2 // enter the connector compilation directory

#./Buildconf. sh // run the configuration script

#./Configure -- with-apxs2 =/usr/local/apache/bin/apxs -- enable-jni -- enable-EAPI

# Make // compilation Module

# Cd ~ Jim/src/* jk2 */jk/build/jk2/apache2 // enter the directory of the compiled Module

# Cp *. so/usr/local/apache/modules // copy the module to the Apache directory

# Cp-R jakarta-tomcat-5.0.19/usr/local/tomcat // install Tomcat

# Touch/usr/local/apache/logs/shm. file // create a shared memory file

------------------------------------------------------------------------

When I first started to install Tomcat, I always failed. Then I ran to the Apache website and read a two-page English description. I soon configured it. I found that Chinese authors always like to learn more about it. They make complicated things and make them easy to understand.


2. Edit the following files

/Usr/local/apache/conf/httpd. conf

LoadModule jk2_module modules/mod_jk2.so

JkSet config. file/usr/local/apache/conf/workers2.properties

DocumentRoot "/usr/local/tomcat/webapps"



/Usr/local/tomcat/webapps/jsp-examples/for. jsp



/Usr/local/tomcat/conf/jk2.propertie

Handler. list = request, container, channelSocket

ChannelSocket. port = 8009

ChannelSocket. address = 127.0.0.1

ChannelSocket. maxPort = port + 10


/Usr/local/apache/conf/workers2.properties

[Shm]

File =/usr/local/apache/logs/shm. file

Size = 1048576

[WorkerEnv:]

Info = Global server options

Timing = 1

Debug = 0

[Channel. socket: localhost: 8009]

Port = 8009

Host = 127.0.0.1

[Ajp13: localhost: 8009]

Channel = channel. socket: localhost: 8009

[Uri:/*. jsp]

Worker = ajp13: localhost: 8009


/Etc/rc. d/init. d/httpd

#! /Bin/sh


# Chkconfig: 2345 92 12

# Description: Starting Apache and Tomcat Server


LD_LIBRARY_PATH =/usr/java/j2sdk1.4.2 _ 04/jre/lib/i386:/usr/java/

J2sdk1.4.2 _ 04/jre/lib/i386/server

Export LD_LIBRARY_PATH


CATALINA_BASE =/usr/local/tomcat

Export CATALINA_BASE


CATALINA_HOME =/usr/local/tomcat

Export CATALINA_HOME


APACHE_HOME =/usr/local/apache

Export APACHE_HOME


JAVA_HOME =/usr/java/j2sdk1.4.2 _ 04

Export JAVA_HOME


PROFILEDIR =/var/run


Case "$1" in

Start)


If [-f $ PROFILEDIR/Tomcat5_Apache2]; then

Echo "Running Tomcat5_Apache2"

Else

If [-f $ CATALINA_HOME/bin/startup. sh]; then

If [-f $ APACHE_HOME/bin/apachectl]; then

"$ CATALINA_HOME/bin/startup. sh"

Echo "Startting Tomcat5"

Sleep 3

Echo "Startting Apache2"

$ APACHE_HOME/bin/apachectl start

Echo "."

Touch $ PROFILEDIR/Tomcat5_Apache2

Else

Echo "Apache File Not Founds"

Fi

Else

Echo "Tomcat File Not Founds"

Fi

Fi

;;


Stop)

If [-f $ PROFILEDIR/Tomcat5_Apache2]; then

If [-f $ CATALINA_HOME/bin/shutdown. sh]; then

If [-f $ APACHE_HOME/bin/apachectl]; then

"$ CATALINA_HOME/bin/shutdown. sh"

Echo "Stopping Tomcat5"

Sleep 3

Echo "Stopping Apache2"

$ APACHE_HOME/bin/apachectl stop

Rm $ PROFILEDIR/Tomcat5_Apache2

Else

Echo "Apache File Not Founds"

Fi

Else

Echo "Tomcat File Not Founds"

Fi

Else

Echo "Not Running Tomcat5_Apache2"

Fi

;;

*)

Echo "Usage; 'basename $ 0' {start | stop}" 1> & 2

Exit 1

;;

Esac


Exit 0


3. Set automatic start

----------------------------------------------------------------------

# Chmod u + x/etc/rc. d/init. d/httpd // modify the File Execution permission

#/Sbin/chkconfig -- add httpd // add httpd to the system startup list

------------------------------------------------------------------


8. Install CVS

1. Edit the following files

/Etc/xinetd. d/cvspserver

Service cvspserver

{

Socket_type = stream

Wait = no

User = root

Server =/usr/bin/cvs

Server_args =-f -- allow-root =/usr/local/cvsroot pserver

Log_on_failure + = USERID

}


2. Run the following command:

--------------------------------------------------------------------

#/Usr/sbin/useradd-d/usr/local/cvsroot cvs // create a CVS management user.

# Passwd cvs // create and manage user passwords.

# Chmod 771/usr/local/cvsroot // modify the CVS root directory permission.

# Su cvs // use the identity of the CVS user.

$ Cvs-d/usr/local/cvsroot init // initialize the CVS repository.

$ Exit // exit the CVS user identity.

# Chmod 644/etc/xinetd. d/cvspserver // modify the CVS Service Startup File Permission.

#/Etc/rc. d/init. d/xinetd restart // restart the xinetd super server.

# Netstat-lnp | grep 2401 // check whether the CVS service has been started.

#/Usr/sbin/useradd cvspub // create a CVS equivalent system user cvspub.

#/Usr/sbin/usermod-G cvs cvspub // Add cvspub users to the cvs group.

# Cd/home/tets1 // enter the project directory for testing.

# Cvs import-m' this is a test only 'test1 v_0_0_1 start // import the files of the current project to the CVS repository.

-------------------------------------------------------------------

Note:

The password of CVS is different in the past. Some of them are programmed to generate the password, and some are copied using the so-called soil method. In fact, I can tell beginners the simplest and most convenient way to add a CVS user using Webmin, And it will generate a password for you.


3. Edit the following files

/Usr/local/cvsroot/CVSROOT/passwd

Test1: NXWxabrVe7z/w: cvspub

Test2: FZTxeAWW. ySIA: cvspub

Note:

The User Name cvspub is added at the end to allow the System user cvspub to replace test1 and test2 to read and write the CVS repository.


/Usr/local/cvsroot/CVSROOT/readers

Test1


/Usr/local/cvsroot/CVSROOT/writers

Cvs

Test2


Conclusion

So far, the entire system configuration is complete. Many errors have occurred in the system configuration process. Unfortunately, the solution is found through the English site. I hope the technical level of our domestic site can be improved as soon as possible. Although this article strives to be concise and clear, it may not be satisfactory in many places due to time constraints. If you do not understand anything, please contact me and I will accept your comments, modify obscure places. Many excellent articles have been referenced in the configuration process. Thank you for choosing here! Finally, I would like to explain that this system was originally built on the FreeBSD platform, but the JAVA environment on the FreeBSD platform is not complete yet, finally, I had to give up the best operating system on the INTEL Platform and choose RedHat Linux with average performance and stability.
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.