Archive for the ‘Webhosting’ Category

Name-based Virtual Hosting with Addition of Domain

Wednesday, July 25th, 2007

The Problem: There is an existing domain running on an Apache name-based virtual hosting server (let’s call it domain_1.com, IP:123.123.123.121). Due to some requirement, another existing domain (let’s call it domain_2.com, IP:123.123.123.122) has to show the same content of domain_1.com (keep in mind that all the PHP scripts, Perl scripts, database, etc has to be in place).

The Solution: Since it is name-based virtual hosting, it is not possible to just point the “A” record for domain_2.com and www.domain_2.com to the 123.123.123.122.

The first thing I tried is to use mod_rewrite to try to rewrite the whole domain from www.domain_2.com to www.domain_1.com. However, it seems like if mod_rewrite will change the URL (redirect) if it is starting with “http://”.

After a bit of searching, I found that ServerAlias can be used to make more domain names using a single name-based virtual hosting. What I did is to add in:

<VirtualHost 203.81.56.2:80>
ServerName www.domain_1.com
ServerAlias www.domain_1.com domain_1.com www.domain_2.com domain_2.com

This way after the DNS is pointed to 123.123.123.121 for domain_2.com, it will share the same content (and scripts) with domain_1.com.

MySQL: Too many connections error

Tuesday, July 24th, 2007

The Problem: VBulletin gives the following error:

Database error in vBulletin :

mysql_connect() function.mysql-connect: Too many connections
/home/cozycot/public_html/forums/includes/class_core.php on line 274

MySQL Error :
Error Number :
Date : Monday, July 23rd 2007 @ 10:26:53 PM
Script : http://forums.myhosting.com/showthread.php?t=12133
Referrer :
IP Address : 123.123.123.123
Username :
Classname : vB_Database

The Solution: The solution to this is quite easy and posted on a lot of Websites. This is a typical “Too many connections” error from MySQL. To solve this, edit the file /etc/my.cnf and put in a line like the following:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
set-variable = max_connections=200
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
#old_passwords=1

[mysql.server]
user=mysql
#basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

and restart MySQL.

eAccelerator with WHM/CPanel

Wednesday, June 27th, 2007

The Problem: The same friend had a problem with installation of eAccelerator on WHM 11.2.0 hosting server. It seems like eAccelerator was installed but phpinfo() showed that caching and optimization is not enabled.

The Solution: It seemed like WHM installed PHP as CGI and that caused the problem. First, I changed PHP to be loaded as Apache Module by editing the httpd.conf. Uncomment the following lines:

LoadModule php5_module        libexec/libphp5.so
AddModule mod_php5.c

Restarted Apache Webserver using the command “/etc/init.d/httpd restart” and everything is cool now.

WHM/CPanel MySQL 5 Problem

Wednesday, June 27th, 2007

The Problem: My friend has a server freshly installed with WHM / CentOS 4.5. The problem was that after WHM is install with MySQL 5, MySQL Server refused to startup giving the message “Couldn’t find MySQL manager or server”.

The Solution: The hosting company for the dedicated server said that it is a paid support, so I searched around the Internet and found that the solution is simply to comment out a single line in /etc/my.cnf:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
#old_passwords=1

[mysql.server]
user=mysql
#basedir=/var/lib  ## comment out this line ##

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Then issue the command “/etc/init.d/mysql restart” and it works like a charm.