Thursday, May 2, 2013

Mac OSX - install mod_jk

 Steps to install mod_jk on OSX


  • Download source from apache site
    • http://apache.mirrors.hoobly.com//tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.41-src.tar.gz
  • Extract file and start building

           cd native
make clean
./configure CFLAGS='-arch x86_64' APXSLDFLAGS='-arch x86_64' --with-apxs=/usr/sbin/apxs
make
sudo make install

If you are seeing a compiler issues , follow below steps


The C compiler ("cc") is located inside of that xctoolchain directory.
I created a symlink for OSX10.8.xctoolchain to point to XcodeDefault.xctoolchain
and that fixed the issue of compiler issue.

cd /Applications/Xcode.app/Contents/Developer/Toolchains
sudo ln -s XcodeDefault.xctoolchain OSX10.11.xctoolchain


If internal directory doesn't exist. There was no MacOSX10.11.Internal.sdk intead the directory was MacOSX10.11.sdk. So to create a symlink:

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.Internal.sdk


Disable System Integrity by restarting the machine and holding [ Command + R ] until apple logo comes up.
then open the terminal from utilities and enter below command

csrutil disable   --> this is done because when installing apache mod_jk.so file is not getting installed in /usr/libexec/apache2 folder, throwing error permission denied.

again to enable enter below command


csrutil enable.



Configure Apache  mod_jk.conf ( /etc/apache2/other/mod_jk.conf )


ps=/
LoadModule    jk_module  /usr/libexec/apache2/mod_jk.so
JkShmFile    /var/log/apache2/mod_jk.shm
JkWorkersFile /etc/apache2/workers.properties
JkLogFile     /var/log/apache2/mod_jk.log
JkLogLevel    info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkRequestLogFormat "%w %V %T"
<Location /status>
    JkMount status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1 192.168.2.%
</Location>
# app2 Worker
JkMount /*.jsp worker1
JkMount /* worker1
## lb test - Worker
JkMount /lb lbloadbalancer
JkMount /lb/* lbloadbalancer



workers.properties (cd /etc/apache2/)

ps=/
worker.list=worker1, lbloadbalancer
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1
# worker1
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
  
worker.worker1.socket_connect_timeout=10000
worker.worker1.socket_keepalive=True
worker.worker1.ping_mode=A
worker.worker1.ping_timeout=10000
worker.worker1.connection_pool_minsize=0
worker.worker1.connection_pool_timeout=600
worker.worker1.retries=1
worker.worker1.recovery_options=7
worker.worker1.reply_timeout=10000



# LB - Loadbalancer
worker.lbloadbalancer.type=lb
worker.lbloadbalancer.balance_workers=worker1
worker.lbloadbalancer.sticky_session=True

 •Change Tomcat-server config
Edit file:
$TOMCAT_INSTALL/conf/server.xml
Change

Engine name="Catalina" defaultHost="localhost"
Into:
Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1"


That's it.


starting apache
cd /etc/apache2/
sudo apachectl start/stop

logs for mod_jk
cd /var/log/apache2
tail -f mod_jk.log


To enable server status for apache on Mac OSX.
This is the solution if you are running Mac OS X 10.11 El Capitan. Note: You need administrator privileges. (sudo)
 In your /etc/apache2/httpd.conf uncomment these lines
 LoadModule status_module libexec/apache2/mod_status.so
Include /private/etc/apache2/extra/httpd-info.conf

Now open /etc/apache2/extra/httpd-info.conf and make changes as below.
<Location /server-status>
  SetHandler server-status
  Require host localhost
  </Location>

Now you can open the URL http://localhost/server-status with your web browser and see the apache status.


Include below to see " It Works" when you enter localhost in your browser, however localhost/status page throws error now.


# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>


Create ElasticSearch cluster on single machine

I wanted to figure out how to create a multi-node ElasticSearch cluster on single machine. So i followed these instructions First i did...