Install support for jsp/php WEB server under Linux

Source: Internet
Author: User
Tags character set include ini php web server socket touch domain tomcat
Js | server | web 0. Overview \ r
0.1 target \ r
Install a free WEB server on the Linux platform that supports SSL, URL rewriting, reverse proxy, page compression, CGI, PHP, JSP, \ r

0.2 License Agreement \ r
GNU Free Documentation License http://www.gnu.org/licenses/fdl.html
Allow arbitrary reprint, but please keep the integrity of this document
If you have any changes, you should inform the author

0.3 author
Blunt Knife Webmaster@yufeng.net

1. Download
1.1 Apache http://www.apache.org/dist/httpd/
1.2 PHP http://www.php.net/downloads.php
1.3 Tomcat http://www.apache.org/dist/jakarta/tomcat-4/
1.4 JTC (Jakarta tomcat connectors) http://www.apache.org/dist/jakarta/tomcat-4/source/

2. Installation
2.1 Apache
$ tar VFXZ httpd-2.0.46.tar.gz
$ CD httpd-2.0.46
$. / configure \
$-ENABLE-SO \
$-enable-ssl = shared \
$-enable-rewrite = shared \
$-enable-proxy = shared \
$-enable-deflate = shared \
$-with-mpm = worker \
$-prefix = / www / server / apache2
$ make
$ make Install
#-enable-so to use JK2 to connect Tomcat, you must have the Apache2 support module dynamically loaded
#-enable-ssl = shared supports SSL
#-enable-rewrite = shared Support URL Rewriting
#-enable-proxy = shared Support Agent \ r
#-enable-deflate = shared support for Web page compression \ r
#-with-mpm = worker using the MPM mode of worker to run
#-prefix = / www / server / apache2 installation directory

2.2 PHP
$ tar VFXZ php-4.3.2.tar.gz
$ CD php-4.3.2
$. / configure \
$-WITH-APXS2 = / WWW / SERVER / APACHE2 / BIN / APXS \
$-prefix = / www / server / php
$ make
$ make Install
$ CP Php.ini-dist / usr / local / lib / php.ini
#-with-apxs2 = / www / server / apache2 / bin / apxs is compiled as a apache2 module \ r
#-prefix = / www / server / php installation directory, and does not have much effect

2.3 Tomcat
$ tar VFXZ jakarta-tomcat-4.1.24.tar.gz
$ CP-R jakarta-tomcat-4.1.24 / www / server /
$ LN-S / home / data / www / jakarta-tomcat-4.1.24 / home / data / www / tomcat

2.4 JTC
#Compile errors, please refer to the following processing \ r
$ Lynx http://www.pubbitch.org/jboss/mod_jk2.html
$ tar VFXZ jakarta-tomcat-connectors-4.1.24-src.tar.gz
$ CD JAKARTA-TOMCAT-CONNECTORS-4.1.24-SRC

#The following two steps do not need to be done if there are no compilation errors \ r
$ CP / usr / java / j2sdk1.4.1_02 / include / linux / jni_md.h / usr / java / j2sdk1.4.1_02 / include /
$ LN-S / www / server / apache2 / lib / libapr-0.so / www / server / apache2 / lib / libapr.so

#Start compilation preparation
$ CD util
$ CP Build.properties.sample build.properties
$ CD. / Jk
$ CP Build.properties.sample build.properties
$ vi build.properties
Catalina.home = / www / server / tomcat
Tomcat40.home = $ {catalina.home}
Apache2.home = / www / server / apache2
#Modify the above
$ CD. / Coyote
$ CP Build.properties.sample build.properties
$ vi build.properties
Catalina.home = / www / server / tomcat
#Modify the above
$ CD. / Jk

#Compile JK2
$ ant native
$ CP Build / jk2 / apache2 / mod_jk2.so / www / server / apache2 / modules

3. Configure
3.1 apache2 / conf / httpd.conf
$ vi / home / data / www / apache2 / conf / httpd.conf
#Disable the default character set
#AddDefaultCharset iso-8859-1
#Load JK2
LoadModule Jk2_module modules / mod_jk2.so
#Support PHP
AddType application / x-httpd-php.php

#Support page compression \ r
Setoutputfilter DEFLATE
Deflatefilternote ratio
Setenvifnocase request_uri \. (?: Gif | jpe? G | png) $ no-gzip dont-vary
Setenvifnocase request_uri \. (?: Exe | t? Gz | zip | bz2 | sit | rar) $ no-gzip dont-vary
Setenvifnocase Request_uri \ .pdf $ no-gzip dont-vary

#Contains virtual host settings
Include conf / virtual_host.conf

3.2 apache2 / conf / virtual_host.conf
$ touch / www / server / apache2 / conf / virtual_host.conf
$ vi / www / server / apache2 / conf / virtual_host.conf
Namevirtualhost 123.456.78.9:80
<virtualhost 123.456.78.9:80>
Documentroot / www / host / www.domain.com / htdocs
ServerName www.domain.com
Serveralias domain.com
Errorlog / www / host / www.domain.com / logs / apache_error.log
Customlog / www / host / www.domain.com / logs / apache_access.log Common
</ VirtualHost>
#Reverse proxy for virtual host \ r
<virtualhost 123.456.78.9:80>
ServerName www2.domain.com
Rewriteengine on
Proxyrequests off
Usecanonicalname off
Rewriterule ^ / (. *) $ Http://192.168.0.1/$1 [p, l]
</ VirtualHost>

3.3 apache2 / conf / ssl.conf
$ vi / www / server / apache2 / conf / ssl.conf
Namevirtualhost 123.456.78.9:443
<virtualhost 123.456.78.9:443>
DocumentRoot "/www/host/www.domain.com/htdocs"
ServerName www.domain.com
ServerAdmin webmaster@domain.com
Errorlog / www / host / www.domain.com / logs / ssl_error.log
Transferlog / www / host / www.domain.com / logs / ssl_access.log
Sslcertificatefile / www / host / www.domain.com / server.crt
Sslcertificatekeyfile / www / host / www.domain.com / server.key
Sslcertificatechainfile / www / ca.crt
Customlog / www / host / www.domain.com / logs / ssl_request.log \
"% t% h% {ssl_protocol} x% {ssl_cipher} x \"% r \ "% b"
</ VirtualHost>

3.4 apache2 / conf / workers2.properties
$ touch / www / server / apache2 / conf / workers2.properties
$ vi / www / server / apache2 / conf / workers2.properties
[SHM]
File = $ {serverroot} /logs/shm.file
size = 1048576

# Example Socket channel, override port and host.
[Channel.socket: example]
port = 8009
host = 127.0.0.1

# define the worker
[Ajp13: example]
Channel = channel.socket: example
# [status: status]

# Uri Mapping
# [uri: / jkstatus / *]
#worker = status: status

# Uri Mapping
[Uri: / *. Jsp]
Worker = ajp13: example

# [uri: / examples / *]
#worker = ajp13: example

3.5 tomcat / conf / jk2.properties
$ touch / www / server / tomcat / conf / jk2.properties
$ vi / www / server / tomcat / conf / jk2.properties
# The default port is 8009 but can use another one
# channelsocket.port = 8019

3.6 Tomcat / conf / web.xml
$ vi / www / server / tomcat / conf / web.xml
<servlet>
<servlet-name> default </ servlet-name>
<servlet-class>
Org.apache.catalina.servlets.DefaultServlet
</ servlet-class>
<init-param>
<param-name> debug </ param-name>
<param-value> 0 </ param-value>
</ init-param>
<init-param>
<param-name> listings </ param-name>
#Important here, disable directory list \ r
<param-value> false </ param-value>
</ init-param>
<load-on-startup> 1 </ load-on-startup>
</ servlet>

3.7 Tomcat / conf / tomcat-users.xml
$ vi / www / server / tomcat / conf / tomcat-users.xml
#Add tomcat admin
<user name = "xxx" password = "xxx" roles = "manager" />

3.8 Tomcat / conf / server.xml
$ vi / www / server / tomcat / conf / server.xml
#Set up virtual host \ r
debug = "0"
Appbase = "/www/host/www.domain.com/webapps"
Unpackwars = "true">
<Alias> crcchem.com </ Alias>
<logger classname = "Org.apache.catalina.logger.FileLogger"
directory = "/www/host/www.domain.com/logs"
Prefix = "Catalina."
suffix = ". Log"
Timestamp = "true" />
<context path = ""
Docbase = "/www/host/www.domain.com/htdocs"
debug = "0" />
</ Host>

4. Test
4.1 apache2
$ touch / www / host / www.domain.com / htdocs / test.html
$ vi / www / host / www.domain.com / htdocs / test.html
$ / www / server / apache2 / bin / apachectl Configtest
$ / www / server / apache2 / bin / apachectl Startssl
$ lynx http://www.domain.com/test.html

4.2 SSL
$ lynx https://www.domain.com/test.html

4.3 Reverse proxy \ r
$ lynx http://www2.domain.com/

4.4 PHP
$ touch / www / host / www.domain.com / htdocs / test.php
$ vi / www / host / www.domain.com / htdocs / test.php
<? phpinfo () ;?>
$ lynx http://www.domain.com/test.php

4.5 JSP
touch / www / host / www.domain.com / htdocs / test.jsp
$ vi / www / host / www.domain.com / htdocs / test.jsp
<% = new java.util.Date ();%>
$ lynx http://www.domain.com/test.jsp

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.