/ * ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------ Write in front: I see many netizens's questions are related to server configuration, build a reliable and safe application development The server is the foundation of web programming, especially for friends who have developed JSP on Linux.
This document is the crystallization of my multi-year server configuration. I haven't been modified by my N before publishing (the last big revision is just released in RH7.2, and then because I have not found a mistake because I didn't find any mistakes, I didn't have it. Upgrade), documentation
Be reprinted by Tianji.com by the end of 2001 (http://www.yesky.com/200206/217592.shtml), then reproduced multiple Linux and Java communities such as LinuxBYE.NET, CNJsp.COM, have not been discovered since the time test Error, you are as good as
safe to use.
Documentation is not ideal in the web page, if you want to get PDF of this document, or have any comments, you can mail to Roczhao@msn.com
Documents are long and distributed, this is the fourth, the following is the text: ------------------------------- --------------------------------------- * /
2 establish a symbolic connection
## Establish a symbol connection to the launcher, which is easy to restart the service later
Ln -s / usr / local / apache / bin / apachectl / usr / bin / apache
3 Edit the configuration file
## Set the default page, separated by spaces
DirectoryIndex index.html index.jsp index.xtp index.php index.php3
4 test Apache
Shell> Apache Start
Lynx http:// localhost
## If the Apache's document page, the installation is successful.
5 Create a startup script
## Creating a Apache Service
Touch /etc/rc.d/init.d/httpd
vi /etc/rc.d/init.d/httpd
## The contents of the file are as follows:
#! / bin / bash
#Start httpd service
/ usr / local / apache / bin / apachectl start
## Set file permissions
Chown -r root /etc/rc.d/init.d/httpd
CHMOD 700 / Etc/rc.d/init.d/httpd
## Connect to your default init level
Ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc5.d/s65httpd
-------------------------------------------------- ------------------------------------------
Step 10 PHP Install
## This version I use the DSO installation mode, so when you upgrade the PHP, you don't need to reinstall Apache.
1 Install PHP
CD ..
TAR XVZF PHP *
CD PHP *
= / usr / local / mysql --with-apxs = / usr / local / apache / bin / apxs --enable-track-vars --enable-sockets --enable-ftp // Set PHP compilation parameters
Make // Compile
Make install // Install CP ./php.ini-dist /usr/local/lib/php.ini // Copy Profile to / USR / local / lib
2 configure Apache
Vi /usr/local/apache/conf/httpd.conf // Configure Apache Support PHP
## Take PHP for keywords to find the following lines, remove the previous comment symbol
# Addtype Application / X-httpd-php .php
# Addtype application / x-httpd-php .php3 // The Bank needs to be added yourself, used to support PHP3
# Addtype Application / X-httpd-php-source .phps
# Restart Apache
Apache Restart
-------------------------------------------------- -------------------------------------------------- ------------------
Step 11 JVM Setup
CP / HOME / SRC / J2SDK-1_3_1-Linux-I386.bin / USR / LOCAL
CD / usr / local
CHMOD A X J2SDK-1_3_1-Linux-i386.bin
## The following instructions are a script, which should ask if you agree, enter Y, then it will install it it yourself.
./j2sdk-1_3_1-linux-i386.bin
## To create a symbolic connection for the current JDK version, the purpose is to connect to the system in the future, you can connect the new directory to / usr / local / jvm, so there is no need to modify many profiles
Ln -s /usr/local/jdk1.3.1_01 / usr / local / jvm
-------------------------------------------------- ------------------------------------------
Step 12 Classes Install
## This step is my habit. If you don't need Java or JSP development, you may not need this step. The purpose of this step is to set a home directory on your Java class library, then build subdirectory in this primary directory. Different kinds of class files.
## Here you need to explore the mysql driver. Everyone can see that I still use the MM driver below. Some netizens suggest that I use the driver that comes, I see caucho's site on Caucho Statement It is much faster than the MM driver, and related data; however The result of my test is RSIN driver in RS.Previous (); rs.first (); and rs.Last (); there is no effect, so I still use MM. .MYSQL-2.0.4-bin.jar.zip.
## Create a class library owner directory
MKDIR / USR / local / lib / java
## The following is installed in the JDBC driver, which is supported by JDBC2.0.
MKDIR / USR / LOCAL / LIB / JAVA / Drivers
CP /Home/SRC /MM.MYSQL-2.0.4-bin.jar.zip / usr / local / lib / java / drivers // mysql driver
## The following is installed, it needs to be explained, the downloaded JAF package is a Winzip file, I am decompressed on Windows, then create a JAF directory to put the activation.jar to the / home / src, you Can solve MKDIR / USR / LOCAL / LIB / JAVA / JAF
CP /Home/src/java/jaf/activation.jar / usr / local / lib / java / jaf // jaf class
## Install Javamail, my handling method is the same
MKDIR / USR / local / lib / java / javamail
Cp /Home/src/java/javamail/*.jar / usr / local / lib / java / javamail // javamail classes
-------------------------------------------------- ------------------------------------------
Step 13 Edit / etc / Profile
## This step is used to configure environment variables, and RESIN's installation needs to rely on this step.
VI / ETC / PROFILE
## Add the following below / etc / profile file:
Java_home = / usr / local / jvm
Resin_home = / usr / local / resin
Class_home = / usr / local / lib / java
ClassPath = $ ClassPath: $ java_home / lib / Tools.jar: $ java_home / lib / dt.jar: $ JAVA_HOME / JRE / LIB: $ RESIN_HOME / LIB: $ Class_Home / Drivers / mm.mysql-2.0.4-bin. JAR.ZIP: $ 22 JAR: $ Class_Home / Javamail / Mail.jar: $ Class_Home / JavaMail /smtp.jar: $ class_home / javamail /Pop3.jar: $ class_home / javamail / mailapi.jar: $ Class_home / javamail / IMap.jar
PATH = $ path: / bin: / sbin: / usr / bin: / usr / local / bin: / usr / local / jvm / bin: / usr / local / jvm / jre / bin: / usr / local / mysql / bin: / usr / bin / x11: / usr / x11r6 / bin
Export Java_Home Resin_Home Class_Home ClassPath Path
## Save the file After logging out, then re-enter, enter the following command to see if the system variable has taken effect:
Shell> ENV
-------------------------------------------------- ------------------------------------------
Step 14 Resin Install
1 Installing Resin
CD / Home / SRC
CP /Home/src/resin-2.0.5.tar.gz / usr / local
CD / usr / local
TAR XVZF RESIN *
CD RESIN *
./configure --with-apache = / usr / local / apache // Setting compilation parameters
(OR: ./configure --with-apxs = / usr / local / apache / bin / apxs)
Make // Compile Make Install // Installation
2 establish a symbolic connection
## Establish a symbolic connection of RESIN, the truth is the establishment of JVM symbolic connection
Ln -s /usr/local/resin2.0.5 / usr / local / resin
## Establish the symbolic connection of the Resin service program, and the truth is the establishment of Apache symbolic connection.
Ln -s /usr/local/resin/bin/httpd.sh / usr / bin / resin
3 Modify the configuration file
vi /usr/local/resin/conf/RESIN.conf
Modify ONE: Establish a connection pool, similar to DSN on NT (data source)
resource-ref>
## Some examples of the test part of the following example show how to call the data source
Modify TWO: Modify the default owner, if you use a virtual host, you can also ignore this place.
Modify Three: Modify the RESIN port, working with Apache
Modify Four: Add a virtual host that supports JSP
## Add a virtual host that supports JSP needs to do the following four aspects: DNS, FTP, Apache, Resin
1, add a DNS alias (of course, the host name can also be)
vi /var/named/yesgo.loc
# 追加 行, of course, you can customize other alias or host names
Www in cname ns.yesgo.loc.
/etc/rc.d/init.d/named restart // Restart DNS service
NSLOOKUP / / Test Whether to resolve success
2, add a FTP account
UserAdd www -s / dev / null -g ftpchroot // Add account passwd www // Change password
CHMOD 701 / HOME / WWW // Set permissions, otherwise the server will say that you have no authority
3, add a virtual host in Apache
vi /usr/local/apache/conf/httpd.conf
# Specify the IP address you use to build a virtual host
NamevirtualHost 192.168.1.2
# Add virtual host
4, add a virtual host in RESIN to support JSP
vi /usr/local/resin/conf/RESIN.conf
## Find Host> in the document, then add the following:
"note":
Follow the top floor, you put the Javabean directory is the class content under the site root directory. You can not die of hard / web-info / classes. The key to understand the truth, in fact, what you can set, such as AMAO, Agou Oh, huh, huh.
"Strong Suggestions": Set the permissions of the CLASSES directory, otherwise the client can browse and download your components
CHMOD 701 / HOME / WWW / CLASS / / Sets the permissions of the CLASSES directory to avoid illegal acquisition
4 test resin
## Starting Resin
Shell> Resin Start
## Restart Apache, because httpd.conf has just been modified, need to be restarted to take effect
Shell> Apache Restart
#Create a file
Touch /Home/www/index.jsp
Chown -r www /Home/www/index.jsp
Chmod 701 /Home/www/index.jsp
## Edit Source File
Vi /Home/www/index.jsp
## Source code only one sentence:
1 1 = <% = 1 1%>
## Test the program
Lynx http://www.yesgo.loc/
## The result of the output should be: 1 1 = 2