Web service configuration and application 5-Linux Enterprise Application-Linux server application information. The following is a detailed description. Configuration of the CGI running environment: CGI is an executable program running on the web server. It makes the web page interactive instead of static.
1. Installation of the perl interpreter
CGI can be written in any language, as long as it has standard input and output and environment variables. Perl is almost the endorsement word of CGI. Run the rpm-q perl check to check whether the interpreter of perl is installed.
2. httpd. conf file configuration
Set the directory permission for storing CGI files: It tells Apache which directories can be used to allow CGI programs to run. For example, for the CGI file to be executed in the main directory, you should add an ExecCGI option in the Options command of the main directory permission settings.
Mark the file type of the CGI program: Find the # sign in front of the # AddHandler cgi-script. cgi statement to tell the. cgi file with the Apache extension to be a CGI program. If you want to run a file with the extension. pl, add pl to the end of the statement.
3. Test the CGI running environment
Create a file named test. CGI in/var/www/html in the main directory where the cgi file is stored, and edit the file as follows:
#! /Usr/bin/perl
Print "Content-type: text/html \ n ";
Print "hello cgi world! \ N ";
Then run chmod + x/var/www/html/test. cgi.
In ie, add http: // ip address of the linux Server/test. cgi. If hello cgi world is displayed! It indicates the operation is successful.
PHP runtime environment configuration: PHP is a hypertext preprocessing language and an embedded HTML language. It has the following features:
Cross-platform, embedded HTML, simple language, high efficiency, support for a variety of databases, file access, text processing, complex variables, support for image processing.
1. Check whether the php interpreter rpm-q php is installed
2. set php. the conf file is in the Apache main configuration file httpd. by default, the conf file contains an Include conf file. d /*. conf statement, which indicates the directory/etc/httpd/conf. all in d *. the conf file is included in httpd. conf. The installer of the php interpreter automatically creates a configuration file named php. conf in the/etc/httpd/conf. d/directory, which contains the configuration options of php. Vi/etc/httpd/conf. d/php. conf find the statement AddType application/x-httpd-php. change php to AddType application/x-httpd-php. php. php3. If this statement does not exist, you can add it.
3. test the php running environment. Create a file named test. php In the Apache home directory. The content is as follows:
Enter http: // ip address of the linux Server/test. php in ie. If the php information page appears, the php running environment is successful.
Configuration of JSP runtime environment: Like ASP and PHP, JSP is a scripting language embedded in the html language. However, the difference is that traditional scripting languages such as ASP and PHP are directly explained by the server, JSP is a class file that is first converted to Servlet by a JSP Container (such as tomcat), and then compiled into binary by calling the javac compiler, the server eventually runs the class file. Note: apache is only a web server and cannot run JSP programs. To run JSP programs, you also need to install tomcat server software to run JSP programs by integrating apache and tomcat.
1. J2DK is a java Development Kit. All java-based development runs on this platform, and tomcat runs with J2DK support. Download URLs http://java.sun.com/javase/downloads/index_jdk5.jsp
2. Install J2SDK
The J2SDK Installation File is an executable file, so you must grant the executable permission first.
Chmod + x jdk-1_5_0_11-linux-i586-rpm.bin
Run commands
/Jdk-1_5_0_11-linux-i586-rpm.bin
This command will automatically decompress and install the RPM package
3. Create a symbolic connection
The default installation path of J2SDK is/usr/java/jdk1.0.5 _ 11. For future convenience, a symbolic connection is usually established using the J2DSK installation directory.
Ln-s/usr/java/jdk1.5.0 _ 11/usr/jdk
4. tomcat installation
Download http://jakarta.apache.org/site/downloads/downloads_tomcat-5.cgi
Install tar zxvf apache-tomcat-6.0.9.tar.gz-C/usr/local
Establish a symbolic connection ln-s/usr/local/apache-tomcat-6.0.9 // usr/local/tomcat
To set the system environment variable tomcat, you need to find the JDK installation directory based on the environment variable. Otherwise, it cannot be started or stopped normally.
Edit vi/usr/local/tomcat/bin/startup. sh and vi/usr/local/tomcat/bin/shutdown. sh files. Add the following statements after # ------------------- respectively.
Export JAVA_HOME =/usr/jdk
Export PATH = $ PATH: $ JAVA_HOME/bin
Export CLASSPATH = $ JAVA_HOME/lib
Start tomcat/usr/local/tomcat/bin/startup. sh: the startup is successful.
To enable tomcat to start automatically with the system, set/usr/local/tomcat/bin/startup. sh to the command/etc/rc. d/rc. the end of the local file.
Test tomcat http: // ip address of the linux Server: 8080
5. Integrate Apache and tomcat
Tomcat's web functions are far less powerful than Apache, so in actual applications, Apache and tomcat are connected through the mod_jk2 connector. Apache processes static requests. tomcat processes servlet and jsp programs.
Download URLs http://archive.apache.org/dist/jakarta/tomcat-connectors/jk2/binaries/linux/
Install and configure mod_jk2 xxx
Tar zxvf Fedora-Core-1-i386.tar.gz
Cd Fedora-Core-1-i386
Cp etc/httpd/conf/workers. properties/etc/httpd/conf
Cp etc/httpd/conf. d/jk2.conf/etc/httpd/conf. d
Cp usr/lib/httpd/modules/*/usr/lib/httpd/modules/
Cp-a usr/share/doc/mod_jk2 // usr/share/doc/mod_jk2/
Cp-a var/www/manual/mod_jk2/var/www/manual/mod_jk2/
To run the jsp program in the main directory, edit the configuration file/etc/httpd/conf/workers. properties of mod_jk2 and add the following statement at the end of the file.
[Uri:/*. jsp]
Worker = ajp13: localhost: 8009
Configure tomcat: to integrate apache and tomcat, you must set the main directory of apache and tomcat to be consistent, the default home directory of tomcat is/usr/local/tomcat/webapps/ROOT/. Therefore, edit the main configuration file/usr/local/tomcat/conf/server of tomcat. find the following statement in xml
UnpackWARs = "true" autoDeploy = "true"
XmlValidation = "false" xmlNamespaceAware = "false">
Add the following statement
Restart apache and tomcat
/Etc/init. d/httpd restart
/Usr/local/tomcat/bin/shutdown. sh
/Usr/local/tomcat/bin/startup. sh
Test the integration of apache and tomcat.
In the main directory, create a file named test. jsp in/var/www/html/. The content is as follows:
Hello, the time is <% = new java. util. Data () %>
Enter the http: // linux IP Address/test. jsp in the browser. If the current time is displayed, the test is successful.
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