Tomcat Course Notes #2 – CentOS mod_jk/mod_proxy Apache Tomcat

This is another ‘brain dump’ of some notes for the Tomcat Admin Course that I’m presenting in Adelaide on November 7 – 9 for http://etc-australia.com

This note is focussed on interfacing Tomcat on port 8080 (HTTP/1.1) or 8009 (for AJP/1.3 protocol) to Apache and port 80 access to URLs served by the Tomcat.

ie: So the Tomcat hosted content (webapps) are available via http://IP-Addr/ rather than http://IP-Addr:8080/

How To Install mod_jk to RHEL/CentOS ‘minimal’ package VPS:

yum -y install httpd-devel
yum -y install gcc-c++
yum -y install make
cd /usr/local/src/
wget https://archive.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.32-src.tar.gz
tar xzf tomcat-connectors-1.2.32-src.tar.gz
cd tomcat-connectors-1.2.32-src/native
./configure –with-apxs=/usr/sbin/apxs
make
make install
ls -latr /usr/lib64/httpd/modules/ |grep jk

mod_proxy is installed by CentOS/RHEL httpd package by default

[root@tomcatcas0 conf]# rpm -qf /usr/lib64/httpd/modules/mod_proxy.so
httpd-2.2.3-53.el5.centos.3

[root@tomcatcas0 conf]# grep -i proxy /etc/httpd/conf/httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
# Proxy Server directives. Uncomment the following lines to
# enable the proxy server:
#
#ProxyRequests On
#
#

#ProxyVia On
# CacheRoot “/var/cache/mod_proxy”
# End of proxy directives.

[root@tomcatcas0 conf]# diff httpd.conf httpd.conf-mod_jk
201,210c201,206
< ##mod_jk##LoadModule jk_module modules/mod_jk.so < ##mod_jk## < ##mod_jk##JkWorkersFile conf.d/workers.properties < ##mod_jk##JkLogFile logs/mod_jk.log < ##mod_jk##JkLogLevel debug < < ##mod_proxy_ajp## < ProxyRequests off < ProxyPreserveHost On --- -- http://IP-Addr/docs/balancer-howto.html Derived from http://httpd.apache.org/docs/current/mod/mod_proxy.html ProxyPass / balancer://mycluster/ lbmethod=bytraffic
BalancerMember http://server1.example.com:8080/
BalancerMember http://server2.example.com:8080/
BalancerMember http://server3.example.com:8080/

ProxyPassReverse / http://www.example.com/

Apache /etc/httpd/conf/httpd.conf entries for mod_jk

[root@tomcatcas0 conf]# diff httpd.conf httpd.conf-ORIG
201,207d200
< LoadModule jk_module modules/mod_jk.so < < JkWorkersFile conf.d/workers.properties < JkLogFile logs/mod_jk.log < JkLogLevel debug -- http://adcasein.blogspot.com/2010/06/install-modjk-on-centos-55.html If you do have VirtualHosts defined, then be aware that Jkmounts are not inherited in any way. So, or you define JkMount inside all the Virtual hosts you expect to serve your apps, or define them globally and use JkMountCopy in the vhosts. -- mod_jk workers.properties [root@tomcatcas0 conf.d]# cat /etc/httpd/conf.d/workers.properties # For Linux/Unix systems: # Setting Tomcat & Java Home workers.tomcat_home=/usr/local/apache-tomcat-6.0.33 workers.java_home=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64 ps=/ worker.list=worker1 # Settings for worker1 worker worker.worker1.port=8009 worker.worker1.host=localhost worker.worker1.type=ajp13 -- mod_jk vhost.conf extract [root@tomcatcas0 conf.d]# cat tomcatjkvhost.conf JkMount /* worker1 -- mod_proxy vhost.conf extract [root@tomcatcas0 conf.d]# cat tomcatproxyvhost.conf
Order deny,allow
Allow from all

ProxyPass /examples/jsp ajp://127.0.0.1:8009/examples/jsp
ProxyPassReverse /examples/jsp ajp://127.0.0.1:8009/examples/jsp

Order deny,allow
Allow from all


Subsequent Tomcat Course Notes will talk about scaling Tomcats, including DNS, Apache httpd and Tomcat settings, going through to clustering, JDBC, Troubleshooting and much more.

Posted in Network Presence | Tagged , , , | Comments Off on Tomcat Course Notes #2 – CentOS mod_jk/mod_proxy Apache Tomcat

Weekly Tweets for 2011-11-06

  • Busy days setting up courseware & student VMs for a Tomcat Admin Course I present this week in #Adelaide http://t.co/SxLwPgQC #sysadmin #
  • I've updated my Reading List by Amazon in LinkedIn for current and recent work.. #NetPres #
  • Customer rang to thank #NetPres for excellent service, after their competitor paid for premium AdWords. Our QoS scares their competition! #
  • From a longboard on a good wave too! "businesses should be commenting on things that are happening in their industry" http://t.co/QYmLprgv #
  • Network Presence customers should please follow us @netpresops #NetPres #
  • Tomcat VPS Appliance (Managed VPS with install/setup & support) at Network Presence http://t.co/hOcY1kJ0 #NetPres #
  • Thought long & hard on this & fundamentally #Qantas has shown it can't relate to its staff. This is v.bad. I can't rely on @QantasAirways #

Powered by Twitter Tools

Posted in Tweets | Comments Off on Weekly Tweets for 2011-11-06

Busy days setting up coursewar…

Busy days setting up courseware & student VMs for a Tomcat Admin Course I present this week in #Adelaide http://t.co/SxLwPgQC #sysadmin

Posted in Tweets | Comments Off on Busy days setting up coursewar…

I’ve updated my Reading List b…

I’ve updated my Reading List by Amazon in LinkedIn for current and recent work.. #NetPres

Posted in Tweets | Comments Off on I’ve updated my Reading List b…

Customer rang to thank #NetPre…

Customer rang to thank #NetPres for excellent service, after their competitor paid for premium AdWords. Our QoS scares their competition!

Posted in Network Presence, Sales, Tweets | Tagged , , | Comments Off on Customer rang to thank #NetPre…

From a longboard on a good wav…

From a longboard on a good wave too! “businesses should be commenting on things that are happening in their industry” http://t.co/QYmLprgv

Posted in Network Presence, Sales, Tweets | Tagged , | Comments Off on From a longboard on a good wav…

WordPress site in 5 mins after we install your VPS with cPanel

You’ve bought one of our VPS Plans and asked us to install cPanel (you’ve bought your license for cPanel already from http://buycpanel.com, after we gave you your VPS’ IP Address as soon as you paid) to your new VPS, as per our “Sysadmin As A Service” capability.

We’ve given you your VPS WHM URL (typically http://VPS-Hostname-or-IP-Addr/whm) and the root user’s password so you can login to WHM to start, but you want a WordPress CMS site going ASAP. We understand and here’s how to have that WordPress Site going in less than 5 minutes from there.

Start the Clock now!

a) Create a User Account in the VPS’ WHM via Account Functions -> Create a New Account
and filling in that page with the Sitename (created beforehand on the relevant name servers) and let’s call it ‘Customer-site-name’ and nominate a cPanel Username (let’s call it “cpaneluser”) and set a password for it (use the Password Generator if you like).

This creates the Apache ‘Virtual Host’ for that site name & the above URL and creates all the relevant users/settings for cPanel, FTP, the directories etc. Once this is done you can FTP to the VPS’ IP itself and login as FTP user: cpaneluser with the above passwd, and see the default cPanel User directory tree and FTP content for the website to the ‘www’ directory once logged in by FTP.

b) With the cPanel User created above (cpaneluser) you can login to the cPanel as that user & passwd to perform actions relevant to that site
at the URL: https://VPS-Hostname-or-IP-Addr:2083

In cpaneluser’s cPanel you can setup the Database for WordPress via the “MySQL Databases” link on the user’s cPanel page.

Create a MySQL User for the DB (eg: username: cpaneluser_wpuser) and gave it a MySQL Password and click “Add User”.

Then back on the MySQL Databases page, create a new DB (eg: database: cpaneluser_wpdb) by entering the DB name & click “Create Database”, then go back to the main MySQL Databases page, which now lists our created MySQL User & DB.

Then Add the (MySQL) User to the Database (on the main MySQL Database page, below the Add New User section) by selecting the relevant user & DB and clicking “Add” and giving that user “All Privileges” (on the MySQL Account Maintenance page that comes up from clicking the above “Add” button) and clicking “Make Changes” to add that user to have all privs for that DB.

PS: All this is on WordPress’ site, see http://codex.wordpress.org/Installing_WordPress#Using_cPanel

c) To get the WordPress content files onto the site’s ‘www’ directory, download the latest WordPress from http://wordpress.org/download (wordpress-3.2.1.zip) and use any FTP Client software (eg: Filezilla) to upload that zip file to the server (FTP to your VPS’ IP Addr or Hostname as FTP user: cpaneluser with its password set in WHM) into the ‘www’ directory.

d) In the cPanel of the cpaneluser on the VPS, browse to the “File Manager” page & select the uploaded file (wordpress.zip (say) after clicking ‘reload’ to see it listed) and click ‘Extract’ and the default destination directory is fine.

The files in the .zip file are in a directory named ‘wordpress’, which will be created in the ‘www’ (aka ‘public_html’) folder on the server (click ‘reload’ to see changes after unzip if you need to).
You can use ‘select all’ on all files & dirs in the ‘wordpress’ folder in the File Manager and then ‘Move File’ and enter the top level folder name of the web content (/public_html/) to move all those files to the top-level DocumentRoot folder (‘www’ aka ‘/public_html’).

e) Configure the now installed WordPress to know its site name and DB access details, as per: http://codex.wordpress.org/Installing_WordPress#Famous_5-Minute_Install

Meaning that in the File Manager we select the file ‘wp-config-sample.php’ and click the ‘copy’ button and enter the destination filename of ‘wp-config.php’, then click ‘reload’ in the File Manager and select the ‘wp-config.php’ file and click the ‘Edit’ button to enter a web-based file editor on the wp-config.php file.

Set the relevant DB ‘defines’ in that file using the Editor, as per below, using the DB info from using cPanel, above:

define('DB_NAME', 'cpaneluser_wpdb');
define('DB_USER', 'cpaneluser_wpuser');
define('DB_PASSWORD', 'hereeisapassword');
define('DB_HOST', 'localhost');

Just below those DB settings, change the phrase

‘put your unique phrase here’

for the relevant Key / Salt / Auth defines to whatever you’d like.

That’s all the config needed to get to the WordPress Install pages themselves, so click the “Save Changes” button in the file editor page and close the editor.

f) Browse to http://Customer-site-name/wp-admin/install.php to continue the WordPress setup.

Stop the Clock! Easily done (including WordPress download) in under 5 minutes from VPS handover.

I leave it to you from here for that WordPress site’s specific setup, but contact us as a Network Presence customer if you need help inside WordPress itself.

Posted in Network Presence, Sales | Tagged , , , | Comments Off on WordPress site in 5 mins after we install your VPS with cPanel

Network Presence customers sho…

Network Presence customers should please follow us @netpresops #NetPres

Posted in Network Presence, Tweets | Tagged | Comments Off on Network Presence customers sho…

Tomcat VPS Appliance (Managed V…

Tomcat VPS Appliance (Managed VPS with install/setup & support) at Network Presence http://t.co/hOcY1kJ0 #NetPres

Posted in Network Presence, Tweets | Tagged , , | Comments Off on Tomcat VPS Appliance (Managed V…

No traffic/data/Internet Quotas in Nov & Dec for NetPres VPS

Release the Hounds! We’ve been adding to our network connectivity for some time and now we believe that it’s “effectively unlimited” for most VPS customers of Network Presence.

But we want to prove it, so in November and December 2011, we’re not going to bill any customers for their over-quota network traffic, and we’re going to try to provide such network connectivity the best we can!

There you have it, “go nuts”, “have at it”, “release the hounds”, our hosting customers (VPS customers only) can use whatever network traffic we have on offer for their VPS during this special for how they wish.

FYI & Regards,
Richard.

Posted in Network Presence, Sales | Tagged , | 1 Comment