UnixServerAdmin

Server Administration & Management

How to running PHP 4 and PHP 5 on the same cPanel

Here is following process to install and run on the same server php 4 and 5. Users will be allowed to choose what version to use for their scripts.
Although I personally don’t recommend this as it has many performance implications it’s something that small webhosts use so that they don’t have to have different servers for different php versions.

1. Compiler check

# /scripts/checkccompiler
# rm -rvf /home/cpphpbuild
# mkdir /home/cpphpbuild
# cd /home/cpphpbuild

2. Download and extract php

# wget http://us2.php.net/downloads.php
# tar -xzf php-5.2.4.tar.gz
# cd php-5.2.4

3. Configure and build the php installation (credits go to elix for an excellent work)

# echo “#define HAVE_SENDMAIL 1? >> /home/cpphpbuild/php-5.2.4/main/php_config.h
# wget http://www.elix.us/tutorials/php5.gen.cpanel
# chmod 700 php5.gen.cpanel
# ./php5.gen.cpanel
# make
# make install

4. Moving the files and finishing the configuration

# cp -f /usr/local/php5/bin/php5 /usr/local/cpanel/cgi-sys/php5
# chown root:wheel /usr/local/cpanel/cgi-sys/php5
# cp -p /home/cpphpbuild/php-5.2.4/php.ini-recommended /usr/local/php5/lib/php.ini
# chown root.root /usr/local/php5/lib/php.ini
# chmod 644 /usr/local/php5/lib/php.ini
# echo “cgi.fix_pathinfo = 1 ; needed for CGI/FastCGI mode” >> /usr/local/php5/lib/php.ini

5. Now we have to add a few lines to the httpd.conf file

# vim /usr/local/apache/conf/httpd.conf

6. Add in the section – “index.php5″ before index.php4 and Add after “AddType application/x-httpd-php .phtml”

—————————————————————————
Action application/x-httpd-php5 “/cgi-sys/php5″
AddHandler application/x-httpd-php5 .php5
—————————————————————————

7. Test the installation

# service httpd configtest

8. If you get any errors please check that you done all the steps properly. If everything is ok you can now restart apache.

# service httpd restart

Advertisements

October 29, 2012 Posted by | Apache, PHP | , | Leave a comment

How to view Stats without login to cPanel

You can view webalizer stats without login to your cPanel.

# cd /home/user/www

# mkdir stats

# cd stats

# ln -s /home/user/tmp/webalizer webalizer

# cd ../

# chown -R user:user stats

# cd ../

# chmod -R 0775 tmp

You can access it as http://domain/stats/

October 24, 2012 Posted by | cPanel | , | Leave a comment

How to enable Tomcat for a domain in cPanel

To enable .jsp pages for a domain

# /scripts/addservlets –domain=example.com

To disable .jsp pages for a domain

# /scripts/remservelets –domain=example.com

In some cases, these scripts won’t work. Manually check the setting for the domain.

1. Open up the Apache configuration file /usr/local/apache/conf/httpd.conf

# vim /usr/local/apache/conf/httpd.conf

2. Check if the directive given below in the virtual host entry of domain, if not add it.

———————————————————————————————————————–
Include “/usr/local/apache/conf/userdata/std/2/username/domainname/*.conf”
———————————————————————————————————————–

3. Now navigate to the directory

# cd /usr/local/apache/conf/userdata/std/2/

4. check whether the folder named username(replace username with appropriate username) exist if not, create it.

# mkdir username
# cd username
# cd example

5. If the directory “example” is not present, create it

6. Check for the file cp_jkmount.conf here, if it is not present, create it with the following contents
——————————————–
 <IfModule mod_jk.c>
      JkMount /*.jsp ajp13
      JkMount /servlet/* ajp13
    JkMount /servlets/* ajp13
    JkMount /*.do ajp13
 </IfModule>
——————————————–

7. Check the file /usr/local/jakarta/tomcat/conf/server.xml Add the entry for host http://www.example.com

# vim /usr/local/jakarta/tomcat/conf/server.xml

——————————————————————————————————-
 <Host name=”example” appBase=”/home/username/public_html”>
    <Alias>www.example</Alias>
      <Context path=”” reloadable=”true”
               docBase=”/home/username/public_html” debug=”1″/>
      <Context path=”/manager” debug=”0″ privileged=”true”
        docBase=”/usr/local/jakarta/tomcat/server/webapps/manager”>
      </Context>
     </Host>
——————————————————————————————————-

8. Restart the services

# /usr/local/jakarta/tomcat/bin/shutdown.sh

# /usr/local/jakarta/tomcat/bin/startup.sh

# /scripts/restartsrv_tomcat

9. Restart Apache

October 19, 2012 Posted by | cPanel, Tomcat | , , | Leave a comment

APF Error – Unable to load iptables module (ipt_state), aborting

# cd /etc/apf/

# apf -s

Unable to load iptables module (ipt_state), aborting.

Here is the fix

# vim /etc/apf/internals/functions.apf

Replace the lines
==============
ml ipt_state 1
ml ipt_multiport 1
==============

With
==============
ml xt_state
ml xt_multiport
==============

Restart apf

# cd /etc/apf/

# apf -s

October 14, 2012 Posted by | Firewall | , | Leave a comment

RoundCube – Service currently not available errror no. [0x01F4]

Mostly we received following error after browsing RoundCube – “RoundCube – Service currently not available errror no. [0x01F4]

As well as RoundCube error logs showing following logs

[02-Oct-2012 08:34:56 -0400] DB Error: _doQuery: [Error message: Could not execute statement] [Last executed query: PREPARE MDB2_STATEMENT_mysql_8c77e0752a8db2da365c3c7a19fe8842c84663aa7 FROM ‘INSERT INTO messages\n (user_id, del, cache_key, created, idx, uid, subject, `from`, `to`, cc, date, size, headers, structure)\n         VALUES (?, 0, ?, now(), ?, ?, ?, ?, ?, ?, FROM_UNIXTIME(), ?, ?, ?)’]
[Native code: 1064] [Native message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘), ?, ?, ?)’ at line 3] in /usr/local/cpanel/base/3rdparty/roundcube/program/include/rcube_mdb2.inc on line 265
[02-Oct-2012 08:35:20 -0400] DB Error: _doQuery: [Error message: Could not execute statement] [Last executed query: PREPARE MDB2_STATEMENT_mysql_d6ee872839dbf41a18e11e2f09d1f4d9790e462d7 FROM ‘INSERT INTO messages\n (user_id, del, cache_key, created, idx, uid, subject, `from`, `to`, cc, date, size, headers, structure)\n         VALUES (?, 0, ?, now(), ?, ?, ?, ?, ?, ?, FROM_UNIXTIME(), ?, ?, ?)’]
[Native code: 1064] [Native message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘), ?, ?, ?)’ at line 3] in /usr/local/cpanel/base/3rdparty/roundcube/program/include/rcube_mdb2.inc on line 265

The error is occur because MySQL could not insert the values from UNIXTIME. To avoid this error simply open file /usr/local/cpanel/base/3rdparty/roundcube/program/include/rcube_mdb2.php and replace following code

# vim /usr/local/cpanel/base/3rdparty/roundcube/program/include/rcube_mdb2.php

From

return “FROM_UNIXTIME($timestamp)”;

To

return sprintf(“FROM_UNIXTIME(%d)”, $timestamp);

Now clear cache from your local machine refresh RoundCube error page.

October 9, 2012 Posted by | Mail | , | Leave a comment

How to hide Lighttpd software version

Useful: there is really no need to disclose this information to everyone. As shown in “Discover the web server software and version of a remote server” anyone can find valuable information from our web server banner. Hiding it  will not protect in any way from real vulnerabilities if they exist, but it will at least make their life harder. This will also not stop more complex fingerprinting programs to detect some information on the web server, but at least we should not make their life easier ;) .

Compared with Apache (apache by default will show a lot of information even about the linux distribution and installed apache modules), lighttpd will only show its server version in the header. This is good enough, but still we probably want to hide that information anyway. For this, we will use the global lighttpd variable server.tag that defines the string returned by the server. The default (if not defined) is:

server.tag = “lighttpd <current-version>”

and this will look in a regular header output like:

Server: lighttpd/1.4.19

To overwrite this, we just have to define our own output for the server.tag variable in lighttpd.conf. Usually I like to define it like this:
server.tag = “lighttpd”
leaving the lighty name, but taking out the version; you can of course enter anything you like (even to forge an apache or iis server output, etc.)
server.tag = “Apache/1.3.29 (Unix) mod_perl/1.29 PHP/4.4.1 mod_ssl/2.8.16 OpenSSL/0.9.7g”

Conclusion: if you want to provide minimum information about your system then customize your lighty server.tag: server.tag = “lighttpd”

October 4, 2012 Posted by | Lighttpd, Tips & Tricks, Unix/Linux | , , , | Leave a comment