Enabling mod_rewrite in Apache 2.2

By default CentOS or RHEL flavours of Linux has Apache 2.2 installed. It often becomes a requirement to enable mod_rewrite on these servers. Techs who have been working with cPanel and server with control panels often finds it difficult to troubleshoot issues with a bare server. There are a few things to check or commands to execute in such case where mod_rewrite is shown enabled in the httpd.conf, but not working.

[root@cave html]# httpd -V
Server version: Apache/2.2.3

[root@cave html]# httpd -M
Loaded Modules:
core_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
auth_basic_module (shared)
auth_digest_module (shared)
….
…….
….
rewrite_module (shared)
proxy_module (shared)
proxy_balancer_module (shared)
proxy_ftp_module (shared)
proxy_http_module (shared)
proxy_connect_module (shared)

[root@cave html]# a2enmod rewrite

a2enmod is only to be used if the rewrite_module is not enabled in httpd.conf

Check for the “AllowOverride” settings. It should be set to “All“. By default it will be “None

Things should work fine after this. Also I found a small good script to check at this URL to see whether mod_rewrite is enabled or not http://www.webune.com/forums/how-to-test-check-if-mod-rewrite-is-enabled-t40.html

Good Luck guys!

Continue Reading

Recompile PHP for Litespeed webserver

LSAPI is LiteSpeed’s open-source API between external applications and LiteSpeed Web Server. This how-to is for compiling and installing PHP + LSAPI on Linux, OS X, FreeBSD, Solaris, and so on.  LiteSpeed  comes with PHP 4.4.x compiled with LSAPI. To change the LightSpeed php to the latest stable one, we need to recompile the php with the LSAPI for LiteSpeed.

I  am trying to provide some info for doing this task.

Instructions:

a)  Download the required php  from php.net

wget  http://in2.php.net/get/php-5.2.11.tar.bz2/from/this/mirror

tar -xzvf  php-5.2.11.tar.bz2

cd php-5.2.11/sapi

b) Download and  the  latest LSAPI for PHP from http://www.litespeedtech.com/ into the “sapi” folder of php source:

wget http://www.litespeedtech.com/packages/lsapi/php-litespeed-4.10.tgz

tar  -xvf php-litespeed-4.10.tgz

c) Change directory to root PHP source directory and run commands:

cd ..

touch ac*

./buldconf –force

d) Configure/Compiling

If you have an  apache compilation already , remove the part   option “–with-apxs” and use    ” –with-litespeed”  . Also  you may need to change the “prefix” option too . So a basic  configure command would be like  this

./configure  ‘–prefix=/lsphp5′ ‘–with-litespeed’ ‘with-mysql’

make

make install

Note: You must compile PCRE support inorder for the default auto-index php script to work correctly

Post Install Configurations

1. Replace the existing lsphp binary with the new one.

Change the directory to the current installation of “lsws” ( it varies on different machines)

cd  /usr/local/lsws/fcgi-bin

mv lsphp lsphp.old

cp /php-5.2.11/sapi/litespeed/php lsphp-5.2.11

ln -sf lsphp5 lsphp-5.2.11

Check Installation

/usr/local/lsws/fcgi-bin/lsphp5 -v

It should return something like:

PHP 5.2.11 (litespeed) (built: Sep26 2008 14:09:09)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

Notice litespeed in parenthesis. This means that the PHP binary has litespeed (LSAPI) support builtin.

2. php.ini

The php.ini file will be located at /usr/local/lsws/php/php.ini

If we want to use the old PHP.ini just copy it here.

# cd /usr/local/lsws/php
# mv php.ini php.ini.old
# cp /usr/local/ZEND/etc/php.ini .

3. Restart Litespeed Webserver

Finally restart LSWS and use our new PHP binary.

/usr/local/lsws/bin/lswsctrl restart 
Continue Reading

500 Internal Server due to low RLimitMem value

Website was causing 500 Internal Server error while loading the php pages. Error log was saying the error below

/usr/bin/php: error while loading shared libraries: libpthread.so.0: failed to map segment from shared object: Cannot allocate memory

Investigation led the issue to be RLimitMem directive enabled by the client being too low. RLimit directives of apache often gives a false feeling of limiting the user resources.

Commenting out RLimitMem value solved the issue. If that also didn’t fix the issue, check out for the limit settings in /etc/security/limits.conf

I hope this helps a bit sometime in the future for my fellow SAGEs

Continue Reading

Win32 style directory indexing in apache – Date and Size along with the name

Inorder to have win32 styled directory indexing in apache, you need to make sure that mod_autoindex module is installed and active in the server. In cPanel 11 servers, it will have the modules enabled in, /usr/local/apache/conf/extra/httpd-autoindex.conf

So for the client who want to have the fancy directory indexing to be enabled, just add the below lines to his .htaccess

Options +Indexes
IndexOptions FancyIndexing VersionSort

I hope this snippet will help someone!

Continue Reading

How would I see the available versions of cPanel and Apache in a cPanel installed server ?

Solution #1 : Keep browsing http://changelog.cpanel.net/ every day :-)

Solution #2 : /scripts/easyapache –latest-versions

Easy::Apache v3.2.0 Build 4660

[Apache]
1.3.41, 2.0.63, 2.2.11

[PHP 4]
4.4.6, 4.4.7, 4.4.8, 4.4.9

[PHP 5]
5.2.5, 5.2.6, 5.2.8, 5.2.9

Continue Reading

About this blog

This blog, acts as a knowledge repository for the world and is unofficial! Anything we find interesting in the cyber world will go here. Most cases, this blog will reflect the happiness of our staff in reaching successful solution to an issue (s)he worked on. A reference for other fellow SAGEs who come across similar issues later