Marcio Garcia

Software Empowerment²

Archive for the ‘Apache’ Category

Ubuntu + Ruby on Rails + Apache + Passenger

without comments

Guia expresso para instalação de um ambiente de produção RoR/Apache/Passenger no Ubuntu

sudo apt-get install rubygems
 
sudo gem install rails
 
sudo apt-get install ruby
 
sudo apt-get install ruby rdoc irb libyaml-ruby libzlib-ruby ri libopenssl-ruby
 
wget http://rubyforge.rubyuser.de/rubygems/rubygems-1.3.1.tgz
 
tar xzvf rubygems-1.3.1.tgz 
 
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
 
sudo mv /usr/bin/gem /usr/bin/gem-old
 
sudo gem update --system
 
sudo gem install rails
 
sudo apt-get install build-essential ruby1.8-dev
 
sudo gem install mongrel
 
sudo gem install capistrano
 
sudo apt-get install mysql-client mysql-admin mysql-query-browser libmysqlclient15-dev
 
sudo apt-get install sqlite3 swig libsqlite3-ruby libsqlite3-dev
 
sudo gem install sqlite3-ruby
 
echo "export RUBYOPT=rubygems" >> ~/.profile
 
sudo apt-get install build-essential apache2-mpm-prefork apache2-prefork-dev libapr1-dev
 
sudo gem install passenger
 
sudo passenger-install-apache2-module
 

Written by Marcio

January 16th, 2009 at 12:17 am

Posted in Apache, RubyOnRails, Ubuntu

Tagged with , , ,

Ubuntu and Apache2

without comments

I don’t know exactly why but last time that I reinstall Ubuntu and Apache2 on my server, I got the message error:
unable to create worker thread
So, I added the following to /etc/apache/httpd.conf
ThreadStackSize 1000000
Then restart apache:
/etc/init.d/apache2 restart
What happened?

This configuration sets the limits the size of threads to 1Mb and creates a much less memory intensive apache.

Written by Marcio

July 19th, 2008 at 4:06 pm

Posted in Apache, Ubuntu

Tagged with ,

Apache + JBoss com mod_jk

without comments

1 - Instale o Apache
2 - Instale o JBoss
3 - Instale o mod_jk (download em: http://tomcat.apache.org/download-connectors.cgi)

Faça o download do modulo e copie-o no diretorio de modules do apache.

4 - Configure o mod_jk no Apache
Crie o arquivo: mod-jk.conf no diretorio conf do apache e insira o conteudo:

# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicates to send SSK KEY SIZE
# Note: Changed from +ForwardURICompat.
# See http://tomcat.apache.org/security-jk.html
JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"
# Mount your applications
JkMount /application/* loadbalancer
# You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
JkMountFile conf/uriworkermap.properties
# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
# Note: Replaced JkShmFile logs/jk.shm due to SELinux issues. Refer to
# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=225452
JkShmFile run/jk.shm
# Add jkstatus for managing runtime data
<location>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
<location>


5 - Inclua a chamada para o mod-jk.conf no httpd.conf do Apache:
Altere o arquivo httpd.conf do Apache, inserindo a linha:
Include conf/mod-jk.conf

6 - Crie o arquivo workers.properties
# Define list of workers that will be used
# for mapping requests
# The configuration directives are valid
# for the mod_jk version 1.2.18 and later
#
worker.list=loadbalancer,status
#
# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=localhost
worker.node1.type=ajp13
worker.node1.lbfactor=1
# worker.node1.connection_pool_size=10 (1)
#
# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host=localhost
worker.node2.type=ajp13
worker.node2.lbfactor=1
# worker.node1.connection_pool_size=10 (1)
#
# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
#
# Status worker for managing load balancer
worker.status.type=status


Esclarecimentos:

(1) You should only set the connection_pool_size if the number of allowed connection to the Httpd is higher than maxThreads in server.xml

If you specify worker.loadbalancer.sticky_session=Off, each request will be load balanced between node1 and node2. But when a user opens a Session on one server, it is a good idea to always forward this user’s requests to the same server. Otherwise the user’s session data would need to be synchronized between both servers. This is called a “sticky session”, as the client is always using the same server he reached on his first request. Session stickiness is enabled by default.

Side Note: a non-loadbalanced setup with a single node required the “worker.list=node1″ entry before mod_jk would function correctly. Without this setting I would only get a 500 error and no other useful messages in log or otherwise. -Harlequin516

Side Note: I tried both loadbalanced and single node methods on Fedora 4. Both setups causing jk.shm errno=13 and jk-runtime-status errno=13 in the mod_jk.log. Could only get 500 errors. As a last resort disabled selinux on apache server. Restarted service and connection was made first try. -paulbrown

7 - Criar o arquivo de mapeamento (uriworkermap.properties)
Crie o arquivo uriworkermap.properties no diretorio conf do Apache.

# Simple worker configuration file
#
#
# Mount the Servlet context to the ajp13 worker
/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
/web-console=loadbalancer
/web-console/*=loadbalancer


Esclarecimento: Isso fara com que toda requisição feita ao apache a /web-console e jmx-console seja direcionada para o JBoss.

8 - Configuração do Tomcat do JBoss

Altere o arquivo: server.xml, localize o trecho:

<Engine name="jboss.web" defaulthost="localhost" jvmroute="node1">
.
</Engine>


inclua o jvmRoute=”node1″

Verifique se o conector AJP1.3 nao esta comentado:

<Connector port="8009" address="${jboss.bind.address}">
emptySessionPath="true" enableLookups="false" redirectPort="8443"
protocol="AJP/1.3"/></Connector>


Altere o arquivo jboss-service.xml fazendo com q o atributo UseJK seja igual a true:

<attribute name="UseJK">true</attribute>


9 - Start
Inicie o Apache e o JBoss e acesse: http://localhost/web-console

Fonte: Jboss-Wiki

Written by Marcio

July 15th, 2007 at 11:41 pm

Posted in Apache, JBoss, Java, Linux, Tomcat

Configurando um Virtual Host no Apache

without comments

1 - download do apache
http://httpd.apache.org/download.cgi


2 - configurar o host para que o dominio seja direcionado a para a sua maquina
Se vc utiliza o windows, o arquivo de hosts pode ser encontrado em: %WINDOWS%\system32\drivers\etc
Inclua uma linha definindo no primeiro parametro o ip da maquina que deve responder pelo segundo parametro, que sera um dominio.
Estou configurando para q a minha maquina (localhost) responda por contigo.abril.com.br
Isso quer dizer, sempre que eu abrir o meu browser e digitar: contigo.abril.com.br o browser sera redirecionado para o localhost (minha maquina local).




3 - configurar o dominio no apache para que ele responda pelo dominio
Após a instalação do Apache, abra o arquivo httpd.conf que fica em: %APACHE%\conf.
no final do arquivo vc encontrará várias diretivas de Include comentada, insira um Include da seguinte forma:


NameVirtualHost 192.168.18.130:80

Include %APACHE%/conf/contigo.conf




Crie o arquivo %APACHE%/conf/contigo.conf com o seguitne conteudo:



<VirtualHost 192.168.18.130:80>
ServerName contigo2.abril.com.br
DocumentRoot C:/Apache2.2/www/contigo/
DefaultType text/html
Options Includes
DirectoryIndex index.html index.shtml index.htm index.shl




SetEnvIf Request_URI \.gif$ image-request
SetEnvIf Request_URI \.jpg$ image-request
SetEnvIf Request_URI \.png$ image-request




<Directory C:/Apache2.2/www/contigo>
DirectoryIndex index.html
DefaultType text/html
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>



VirtualHost = seu ip
ServerName = nome do dominio
ServerAlias = apelidos que o dominio também devera responder
DocumentRoot = Diretorio em que o servidor localizará os arquivos requisitados
Directory = configurações relativas ao DocumentRoot





4 - Finish
Acesse: contigo2.abril.com.br note que sua maquina esta respondendo pelo dominio contigo2.abril.com.br.

Written by Marcio

July 14th, 2007 at 12:26 pm

Posted in Apache