martedì 19 ottobre 2010

Apache + Jetty su Ubuntu

1 scaricare apt-get install jetty

2 i file si trovano sotto /usr/share/jetty

3 configurare jetty sulla porta 8080 e abilitare dal suo file di configurazione /etc/init.d/default

4 configurare apache in modo che vada in proxy


<VirtualHost *>
        ServerName www.nomesito.it
        ServerAlias nomesito.it

        RewriteEngine On
        RewriteCond %{HTTP_HOST} !www.nomesito.it
        RewriteRule ^(.*)$ http://www.nomesito.it$1 [R=301,L]

        <Proxy *>
        Order deny,allow
        Allow from all
        </Proxy>

        ProxyPreserveHost On
        ProxyPass / http://www.nomesito.it:8080/
        ProxyPassReverse / http://www.nomesito.it:8080/

        ErrorLog /usr/local/customers/logs/nomesito_error_logs
        CustomLog /usr/local/customers/logs/nomesito_access_logs combined

</VirtualHost>



5 configurare jetty sotto /usr/share/jetty/etc/context/nomesito.xml


    <Configure class="org.mortbay.jetty.webapp.WebAppContext">

         <Call class="org.mortbay.log.Log" name="debug"><Arg>Configure  Sito</Arg></Call>
         <Set name="resourceBase">/usr/local/customers/nomesito/</Set>
         <Set name="contextPath">/</Set>
         <Set name="virtualHosts">
              <Array type="java.lang.String">
                   <Item>www.nomesito.it</Item>
               </Array>
          </Set>


          <Call name="addHandler">
              <Arg>
                 <New class="org.mortbay.jetty.handler.RequestLogHandler">
                  <Set name="requestLog">
                     <New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
                      <Arg><SystemProperty  name="jetty.logs" default="./logs"/>/yyyy_mm_dd.nomesito.request.log</Arg>
                           <Set name="retainDays">90</Set>
                           <Set name="append">true</Set>
                           <Set name="extended">false</Set>
                           <Set name="LogTimeZone">GMT</Set>
                     </New>
                 </Set>
              </New>
           </Arg>
       </Call>

   </Configure>

6 configurare il dns della macchina che punti al dominio interno 127.0.0.1 www.nomesito.it sul file /etc/hosts

7 service jetty start && service jetty stop

2 commenti:

Marco ha detto...

ops... il file di conf di jeyy si trova sotto /etc/default/jetty e NON sotto /etc/init.d/...

Marco ha detto...

ecco il mio file
/etc/default/jetty (Modified)


# Defaults for jetty see /etc/init.d/jetty for more

# change to 0 to allow Jetty to start
NO_START=0

# change to 'no' or uncomment to use the default setting in /etc/default/rcS
VERBOSE=yes

# Run Jetty as this user ID (default: jetty)
# Set this to an empty string to prevent Jetty from starting automatically
#JETTY_USER=jetty
JETTY_USER=www-data

# Listen to connections from this network host
# Use 0.0.0.0 as host to accept all connections.
# Uncomment to restrict access to localhost
#JETTY_HOST=$(uname -n)
JETTY_HOST=127.0.0.1

# The network port used by Jetty
#JETTY_PORT=8080

# Timeout in seconds for the shutdown of all webapps
#JETTY_SHUTDOWN=30

# Additional arguments to pass to Jetty
#JETTY_ARGS=

# Extra options to pass to the JVM
#JAVA_OPTIONS="-Xmx256m -Djava.awt.headless=true"
JAVA_OPTIONS="-Xms1024M -Xmx1024M -Djava.awt.headless=true -XX:+UseParallelGC -XX:-DisableExplicitGC -XX:PerSize=256M -XX:MaxPermSize=256M -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled"

# Home of Java installation.
#JAVA_HOME=

# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
# defined in /etc/default/jetty). Should contain a list of space separated directories.
#JDK_DIRS="/usr/lib/jvm/default-java /usr/lib/jvm/java-6-sun"

# Java compiler to use for translating JavaServer Pages (JSPs). You can use all
# compilers that are accepted by Ant's build.compiler property.
#JSP_COMPILER=jikes

# Jetty uses a directory to store temporary files like unpacked webapps
#JETTY_TMP=/var/cache/jetty

# Jetty uses a config file to setup its boot classpath
#JETTY_START_CONFIG=/etc/jetty/start.config

# Default for number of days to keep old log files in /var/log/jetty/
#LOGFILE_DAYS=14