PHP APC Extension memory limit

Recently a website of my client is acting like crazy. Certain links are not working but Apache itself is working, the main website is also working.
Upon checking on the Apache logs, I've found messages like below.

-
[Fri Aug 16 10:21:00 2012] [apc-warning] Unable to allocate memory for pool. in /var/www/vhosts/DOMAIN.com/httpdocs/modules/mod_roknavmenu/helper.php on line 25.
[Fri Aug 16 10:21:00 2012] [apc-warning] Unable to allocate memory for pool. in /var/www/vhosts/DOMAIN.com/httpdocs/modules/mod_roknavmenu/helper.php on line 41.
-


It was because of memory limitation in APC extension of PHP.
To fix it, you need to increase the memory limit of APC. Edit the file - /etc/php.d/apc.ini
Look for apc.shm_size and increase its size.

Connect your Java App to Apache via mod_jk


If there's a need to connect a Tomcat App to Apache, so that the web application can be access directly via port 80 (instead of 8080), I always use mod_proxy_ajp as it's very easy to configure. By default it's loaded in Apache in CentOS, while in Ubuntu you still have to load manually that module.

For some reasons, mod_proxy_ajp keeps on failing. It's throwing an error message like below:

[Thu Jun 21 10:21:29 2012] [error] proxy: AJP: failed to make connection to backend: localhost
[Thu Jun 21 10:21:31 2012] [error] proxy: AJP: disabled connection for (localhost)
[Thu Jun 21 10:22:04 2012] [error] proxy: AJP: disabled connection for (localhost)
[Thu Jun 21 10:23:49 2012] [error] (111)Connection refused: proxy: AJP: attempt to connect to 127.0.0.1:8009 (localhost) failed


I just can't fix it. Weird!

So I have decided to switch to mod_jk. I have done this in Ubuntu server.

Assuming that you've already got Tomcat and Apache working in your box, to install mod_jk:
apt-get install libapache2-mod-jk

Create your workers.properties file:
vim /etc/apache2/workers.properties

Insert the following:
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009



Configure Apache to use the worker that you have just created:
vim /etc/apache2/apache2.conf

Insert the following:
JkWorkersFile /etc/apache2/workers.properties
JkShmFile /var/log/apache2/mod_jk.shm
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "


Configure which site or URL is to be pass connected to Tomcat:
vim /etc/apache2/sites-enabled/000-default


For instance if you want to have the ROOT app from your Tomcat to be connected to Apache, insert this line:
JkMount / worker1

Enable connector port in Tomcat by uncommenting the following line in /etc/tomcat6/server.xml:
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


Restart Apache and Tomcat, that's it!






 

CVE-2012-2122 | MySQL Vulnerability

I just did a quick upgrade on 3 servers as they were vulnerable to CVE-2012-2122.
1and1 wasn't quick to send out newsletter on this, just now I have received an email from Softlayer and Mediatemple. Oh well, unmanaged is unmanaged!