Archive for the Category » apache «

Saturday, November 01st, 2008 | Author: Angelo

Installation of apache module mod_limitipconn on cPanel server (apache version 2.X)

mod_limitipconn is used for limiting number of connections from each ip to particular site by enabling it in virtualhost of particular site. Suppose site name is mysitename.com and it’s cPanel username mysite.

Installation :: installing module mod_limitipconn

Download mod_limitipconn & untar the file. After downloading compile mod_limitipconn with apache using following command.

/usr/local/apache/bin/apxs -cia mod_limitipconn.c

Once you finish with installation of module mod_limitipconn

Uncomment following line in virtual host of site mysitename.com in /etc/httpd/conf/httpd.conf

Include "/usr/local/apache/conf/userdata/std/1/mysite/mysitename.com/*.conf"

Now fire following command to create directory mysitename.com with it’s parent directory mysite.

mkdir -p /usr/local/apache/conf/userdata/std/1/mysite/mysite.com
cd /usr/local/apache/conf/userdata/std/1/mysite/mysite.com

Then, touch a file called ipconn.conf and in it add following line. So that site will have max 3 connections from each ip.

<Location />
MaxConnPerIP 3
# exempting images from the connection limit is often a good
# idea if your web page has lots of inline images, since these
# pages often generate a flurry of concurrent image requests
NoIPLimit image/*
</Location>

Now restart apache service.

We can directly add above lines in virtualhost of domain mysitenaem.com. But when easyapache will be done in the server, the above changes will be overwritten. To avoid this we recommend above this method.

Now run following cPanel script and restart apache service.
/scripts/ensure_vhost_includes –user=mysite

Friday, October 17th, 2008 | Author: Angelo

What is Xcache ? :: Xcache help to accelerates the performance of PHP on servers. It optimizes performance by excluding compilation time of PHP scripts by caching the compiled state of PHP scripts into the RAM and uses the compiled version directly from the RAM. Which help to increase the rate of page generation time by up to 5 times as it also optimizes many other aspects of php scripts and help to reduce serverload.

Installing Xache module:

XCache is a fast, stable PHP opcode cacher that has been tested on linux server and running under high load.
XCache 1.2.1 is release is compatible with apache1/ZendOptimizer/ZendCore compatibility. This version support only support 4.3.x 4.4.x 5.1.x and 5.2.x but does not support the PHP 5.0.x series, also note Xcache is not compatible with IONCUBE.

Installation:
[root@linuxserver ~]# wget http://xcache.lighttpd.net/pub/Releases/1.2.1/xcache-1.2.1.tar.gz
[root@linuxserver ~]# tar -xzf xcache-1.2.1.tar.gz
[root@linuxserver ~]# cd xcache-1.2.1
[root@linuxserver ~]# phpize
[root@linuxserver ~]# ./configure –enable-xcache –enable-xcache-optimizer
[root@linuxserver ~]# make
[root@linuxserver ~]# make install

Adding extensions and configuring xcache in php.ini you can find location of php.ini file by following command
[root@linuxserver ~]# php -i | grep php.ini
Now edit php.ini file.
Under ? extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613" line add following parameter to enable xcache.

extension = xcache.so

[xcache.admin]
; Change xcache.admin.user to your preferred login name
xcache.admin.user = "admin" ? no need to add system user.

; Change xcache.admin.pass to the MD5 fingerprint of your password
; Use md5 -s "your_secret_password" to find the fingerprint
xcache.admin.pass = "cd959ac3debe8f587546a3fa353b3268" ? Password in MD5(op3nsesam3)

[xcache]
; Change xcache.size to tune the size of the opcode cache
xcache.size = 128M
xcache.shm_scheme = "mmap"
xcache.count = 2
xcache.slots = 8K
xcache.ttl = 0
xcache.gc_interval = 0

; Change xcache.var_size to adjust the size of variable cache
xcache.var_size = 8M
xcache.var_count = 1
xcache.var_slots = 8K
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
xcache.test = Off
xcache.readonly_protection = On
xcache.mmap_path = "/tmp/xcache"
xcache.coredump_directory = ""
xcache.cacher = On
xcache.stat = On
xcache.optimizer = On

[xcache.coverager]
xcache.coverager = On
xcache.coveragedump_directory = ""

save and quit.

Restart httpd service.

Now from xcache source copy the "admin" directory to your htdocs from where you can manage the xache.
http://server-ip/admin/

Wednesday, October 15th, 2008 | Author: Angelo

In apache error log if you find error for a account as “Warning: Cannot modify header information - headers already sent by blah,blah…”

Then simply open .htaccess and put following code
php_flag output_buffering on

In case of php-suexec server create php.ini file under respective directory and add turn on output buffering.

Monday, October 13th, 2008 | Author: Angelo

Child pid x exit signal File size limit exceeded:

The error is cause of File size limit. With 32 Bit system apache support max filesize upto 2GB. If any file accessed/required by apache exceeds this limit, you will get above error. You can check for the file under “/usr/local/apache/domlogs“. To sort all files under this directory by size use command ls -lSh | more. Once you get the file with size 2 GB simply recreate and assign appropriate ownership to the same.

Sunday, October 12th, 2008 | Author: Angelo

Disable directory listings using .htaccess.

If you want to disable directory listing for any folder then simply create one file as .htaccess in that directory & insert rule IndexIgnore * in that file.

IndexIgnore * means directory will not list any file or folder. If you want to disable listing of .jpg files only then rule would be IndexIgnore *.jpg with this rule directory will list all files and folders excluding files with extension .jpg.

Saturday, October 04th, 2008 | Author: Angelo

Hello,

While starting apache service on cPanel server if you are getting as given below.

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 or 443
no listening sockets available, shutting down
Unable to open logs

Then it is because httpd is stopped but http port 80 or 443 are still engaged with other service such as exim or mysql. In such case you need to execute following command to find with which service apache port is engaged.
netstat -nap | grep 0.0.0.0:80 or netstat -nap | grep 0.0.0.0:443

For example :: In output if you found exim ( tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 789/exim)
To fix this issue you need to simply restart the exim service on server .

Thursday, October 02nd, 2008 | Author: Angelo

Using mod_layout you can create a single look for your site by placing information at both the beginning and the end of a document (header and footer). It is useful for adding banners at the top or end of all web pages. Also if wish you can insert layouts in documents at any place dynamically.

Below are the steps to install mod_layout on your cPanel server.

Download tar file for installtion

A. wget http://www.tangent.org/download/mod_layout-3.2.1.tar.gz
B. tar xvfz mod_layout-3.2.tar.gz
C. cd mod_layout-3.2
D. vi Makefile
and find following
# the used tools
APXS=apxs
APACHECTL=apachectl
CC=`apxs -q CC`
INC=-I`apxs -q INCLUDEDIR` `$(APXS) -q CFLAGS` #-DLAYOUT_FILEOWNER_NAME
LD_SHLIB=`apxs -q LDFLAGS_SHLIB`

Replace the values with the following details :

# the used tools
APXS=/usr/local/apache/bin/apxs
APACHECTL=apachectl
CC=`/usr/local/apache/bin/apxs -q CC`
INC=-I`/usr/local/apache/bin/apxs -q INCLUDEDIR` `$(APXS) -q CFLAGS` #-DLAYOUT_FILEOWNER_NAME
LD_SHLIB=`/usr/local/apache/bin/apxs -q LDFLAGS_SHLIB`
save the file Makefile and then

E. make
F. make install
G. edit httpd.conf
And added LayoutHeader and LayoutFooter Directive as below.

<Virtualhost www.domainname.com>
LayoutHeader “<P> This is the beginning of things<P>”
LayoutFooter “<P> This is the tail end of things<P>”
</virtualhost>

You are done….