Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

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!






 

Kansas vs Kentucky - resulting to 200mbps burst of bandwidth

Today is NCAA Men's Basketball finals, it's Kansas Jayhawks vs Kentucky Wildcats.
One of the server that I'm handling is hosting a webzine for NCAA Men's Basketball. Though it has no video streaming feature of the current match, the site is bursting up to 200mpbs of bandwidth for the past hour.

Wow! I thought 1and1 is shaping the bandwidth for dedicated servers to burst only up to 100mbps?
Does this mean that we can burst up to 1gbps? We'll never know unless we'll experience it, so I might do some stress testing within this month.

Okay, let me go back to the game. It's 2nd quarter now.

Tomcat down after reboot


Help! My Tomcat isn't running anymore after reboot!


Eh.. first thing's first. Verify if Tomcat is running or not. Login to your server through SSH and issue the following command:

-bash-3.2# telnet localhost 8080
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

 -bash-3.2# /etc/init.d/tomcat5 status
tomcat6 is stopped.

If you see those results, that means Tomcat isn't running in the first place.
Make sure that it's enabled for start-up. The next time your server will be rebooted, Tomcat should start.

To enable Tomcat for start-up, do:

-bash-3.2# chkconfig tomcat5 on