Archive for November, 2009

How to Re-install Mysql on Freebsd

Monday, November 30th, 2009

freebsd

Say Mysql has completely crashed on your server and while restarting it is showing the below error :-

/usr/local/bin/mysqladmin: connect to server at ‘localhost’ failed error: ‘Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (61)’ Check that mysqld is running and that the socket: ‘/tmp/mysql.sock’ exists! mysql has failed, please contact the sysadmin (result was “mysql has failed”).

And from the mysql error logs you are getting

/libexec/ld-elf.so.1: /lib/libc.so.7: version FBSD_1.1 required by /usr/local/libexec/mysqld not found

If you have tried all other common fixes then lets now move on to mysql-reinstall.

The steps to reinstall mysql from ports on a freebsd – cpanel servers are as follows.

# cd /usr/ports/databases/

# pkg_info | grep -i mysql

It should display information on mysql packages , something like

bsdpan-DBD-mysql-4.013 DBD::mysql – MySQL driver for the Perl5 Database Interface

mysql-client-5.0.87 Multithreaded SQL database (client)

mysql-server-5.0.87 Multithreaded SQL database (server)

cd /usr/ports/databases/mysql50-server (see which version you have)

make clean

make

make deinstall

make reinstall

/usr/local/etc/rc.d/mysql-server start

/usr/local/etc/rc.d/mysql-server.sh start

Check if mysql is running

# ps wwaux | grep mysql

Make sure that you have given the symlink

# ln -s /var/db/mysql/mysql.sock /tmp

If it still shows down try to re-set the mysql password and restart mysql again .


Phpmyadmin shows ” No Database “

Monday, November 30th, 2009

While accessing Phpmyadmin via Cpanel , under databases it shows ” No Database ” . But you can see the databases while accessing through WHM.

phpmyadmin1

This can be due to many reasons . One of the reason I found is because the user doesn’t have SHOW DATABASES privilege .

From the server my.cnf remove the line

skip-show-database

Restart Mysql

Try to access Phpmyadmin .

About skip-show-database from Mysql Reference Manual .

–skip-show-database

With this option, the SHOW DATABASES statement is allowed only to users who have the SHOW DATABASES privilege, and the statement displays all database names. Without this option, SHOW DATABASES is allowed to all users, but displays each database name only if the user has the SHOW DATABASES privilege or some privilege for the database. Note that any global privilege is considered a privilege for the database.

Unable to fork: Cannot allocate memory

Monday, November 30th, 2009

While logging to a VPS from the host server(main node) , you see the message:

Unable to fork: Cannot allocate memory

This usually occurs when VPS is running out of resources especially RAM. Restarting the vps may be a temporary fix which allows you to enter the server . But it prevents executing some commands throwing the same error message .

You can increase privvmpages and kmemsize values for the VPS in order to solve the issue .From the client node in order to see each resource , run the command

cat /proc/user_beancounters

It has five values associated with it: current usage, maximum usage , barrier, limit, and fail counter. The meaning of barrier and limit is parameter-dependent; in short, those can be thought of as a soft limit and a hard limit. If any resource hits the limit, the fail counter for it is increased. This allows the owner to detect problems by monitoring /proc/user_beancounters in the container.

uid      resource         held        maxheld    barrier          limit failcnt

101:    kmemsize       5741113  8347532   2147483646  2147483646 453225323642

privvmpages    33656     44989       98304          98304 106507

In order to increase the value of the two parameters edit the below file from the main node

/etc/sysconfig/vz-scripts/101.conf ( 101 is my vps node)

You can see the value as below

PRIVVMPAGES=”98304:98304″

Increase the value as you need

PRIVVMPAGES=”100000:100000″

Restart your vps after the changes .

# vzctl restart 101

You can also raise the limit as sown below from the host node .

vzctl set 101 –privvmpages 100000:100000 –save

vzctl restart 101

kmemsize

Size of unswappable memory in bytes, allocated by the operating system kernel.

privvmpages

Memory allocation limit. Privvmpages parameter allows controlling the amount of memory allocated by applications.

Unable to open pty: No such file or directory

Monday, November 30th, 2009

You may receive the following message on entering a VPS:

# vzctl enter 101

enter into VE 101 failed

Unable to open pty: No such file or directory

The reason behind this is the missing tty/pty files . You can create it using the MAKEDEV program, execute the following commands on the host server ( main node ).

# vzctl exec VEID /sbin/MAKEDEV tty
# vzctl exec VEID /sbin/MAKEDEV pty

Replace VEID with your actual vps id . In our example its 101 .

Restart vps .

#vzctl restart VEID

Thats a temporary fix. To Fix this issue permanently follow the below steps after entering to your vps client node (101 in our case) .

1) #vzctl enter VEID

2) Edit the file /etc/rc.sysinit

3) Comment the line
#/sbin/start_udev

4) Add the following lines after /sbin/start_udev:
/sbin/MAKEDEV tty
/sbin/MAKEDEV pty

5) Reboot your VPS client node .
vzctl restart VEID

You can also access the file /etc/rc.sysinit for the node 101 from the main VPS node . It should be from /vz/private/VEID/etc/rc.sysinit .

You can also try the below steps by updating the startup files

# vzctl exec VEID update-rc.d -f udev remove
# vzctl restart veid

Above fixes may not work for ubuntu servers . In that case you can try the below command

# vzctl exec VEID ‘dpkg –force-depends –purge udev’

How to install software’s using Plesk Autoinstaller

Friday, November 27th, 2009

Plesk Auto-Installer is a utility used by Plesk control panel for retrieving and installing software updates and upgrades . This article describes how to install software’s from back-end .

Lets see how to install webmail using autoinstaller . Control Panel shows webmail is not installed and is grayed out .

webmail

1) Ssh to your server .

2) Search for the binary autoinstaller. Most probably it should be under /usr/local/psa/bin/

# cd /usr/local/psa/bin/

3) Check for various options available .

[root@admin /usr/local/psa/admin/bin]# ./autoinstaller –help

It should list something like

Usage: parallels_installer [OPTIONS]

Product and operating system updates source:

–source <URL or absolute path to .inf3 file>

URL (http://your-mirror.com/) or absolute path

to an .inf3 file on your hard disk.

Examples:

‘http://autoinstall-ctp.plesk.com/’

‘/root/parallels/PSA_8.1.0/plesk-8.1.0-deb3.1-i386.inf3′

–disable-plesk-sys-updates

Do not use operating system updates shipped

with Plesk and other product(s)

–add-source <type,priority,url[,username,environment variable with password]>

Specify the additional source of packages.

You can specify either of the following source

types: repodata, directory.

Examples:

‘repomd,500,http://download.fedora.redhat.com/fedora/updates/2/i386′

‘directory,500,/mnt/updates’

–show-additional-source-types

Show possible source types for –add-source

–show-additional-sources

Show the additional sources you configured

Proxy server options:

–proxy-host <host> When using a proxy server or a firewall, use this

option to specify the proxy server’s domain name

or IP address.

–proxy-port <port> Default port for connecting to proxy server is 3128.

If your proxy server uses a different port number,

you should specify it using this option.

–proxy-user <user> Set username for authorization at the proxy server

–proxy-password <password>

Set password for authorization at the proxy server

Select a product version:

–select-product-id <product id>

Select the product name

(‘plesk’ (by default) or ‘sitebuilder’)

–select-release-id <release id>

Use this option to specify the product version that you

want to install or whose properties you want to view.

–select-release-latest

Select the latest product version available for

your operating system

–select-release-current

Select the same product version as the one installed

on your machine

Options for selecting components:

–install-component <component id>

Install the product component with specified

identifier

–install-everything

Install all components of the selected product version

–upgrade-installed-components

Upgrade all installed components of the selected

product version

Installer options:

–allow-kernel-install

Allow kernel upgrade. By default, the auto-installer

does not make any kernel upgrades.

Note that auto-installer installs new kernels to the system, leaving the older

kernel aside so that you can revert to it at any time.

–ignore-key-errors

Allow upgrading product even if upgrade of the license

key fails.

–use-existing-ports

FreeBSD specific option

(You may want to use this to prepare the machine for installing the product.)

–no-space-check Install packages even if you are low on disk space.

Use the following options for selecting and installing packages,

and setting up mirrors:

–show-releases Specify this option to retrieve a list of available

product versions for the operating system where the

auto-installer is executed. You will be given a list

of release identifiers and release descriptions.

The release identifiers are what you will need to

deal with.

–show-all-releases This option shows all product versions available from

the official product updates server.

–show-os-list Use this option to find out on which operating systems

the product version you selected can run.

–show-components Use this option to obtain the information on the

components available for the selected product version.

Components descriptions and names will be displayed.

The component names are what you need to specify when

selecting additional components to install.

–show-packages Show additional packages required for installation of

selected components.

–mirror-os <id> This option activates the mirroring feature in

auto-installer. If you want to mirror product versions

for different operating systems, you should specify

this option per each operating system.

–install-package <name>

Install package with specified name

Options for interaction with other software:

–enable-xml-output Specify this option to have all output of

auto-installer in XML format. Note that this option

disallows auto-installer to report errors by exit code.

Exit code is always zero and all errors are reported

inside XML output.

–query-status Use this option to find out if auto-installer is

active. This will return either an exit code

(0 – auto-installer is idle, 1 – auto-installer is

running and busy), or XML-formatted output.

–check-updates Specify this option to check the updates server for

updates applicable to your product version.

A list of releases that you can update or upgrade to

will be shown.

–no-daemon Perform installation process in the foreground

–web-interface Opens the Web-based installation wizard in

a Web browser.

–ssl-cert <file.pem>

Specifies the path to the SSL certificate file that

should be used for securing connections.

–without-ssl Specifies that connections to the Web-based

installation wizard will not be secured.

FreeBSD specific options:

–cvsup-host <hostname>

Hostname of CVS server for retrieving updates for

FreeBSD ports

Override operating system detection results:

–override-os-name <arg>

Override detected operating system name

–override-os-vendor <arg>

Override detected operating system vendor

–override-os-version <arg>

Override detected operating system version

–override-os-arch <arg>

Override detected operating system architecture

–override-environment <arg>

Override detected environment

(possible values are ‘dedicated’, ‘vz’, ‘vserver’)

Interactive user interface options:

–no-clear Do not clear screen when moving between wizard’s pages

General options:

–target <dir> The directory where downloaded files must be stored.

–notify-email <email>

Use this option to have the auto-installer send you

status reports by e-mail. A successful completion

report includes a list of installed or upgraded

packages with a detailed log.

–truncate-log Clear log file on auto-installer start

–separate-log Use new log file for each start of auto-installer

–debug Turn on detailed output into log file

–version Show auto-installer’s version

–usage,

–help Show this help page

That clearly shows what does each option do .

You can see all the product versions using :-

[root@admin /usr/local/psa/admin/bin]# ./autoinstaller –show-all-releases

Downloading the file products.inf3: 100% done.

Downloading the file plesk.inf3: 10%..21%..30%..41%..50%..61%..70%..81%..90%..100% done.

Downloading the file ppsmbe.inf3: 76%..100% done.

Downloading the file sitebuilder.inf3: 15%..35%..55%..96%..100% done.

Downloading the file sso.inf3: 10%..24%..37%..51%..64%..78%..91%..100% done.

Downloading the file setemplates.inf3: 38%..87%..100% done.

— prod_id release_id (description) —

plesk PLESK_9_2_3 (Parallels Plesk Panel 9.2.3)

plesk PLESK_9_2_2 (Parallels Plesk Panel 9.2.2)

plesk PLESK_9_2_1 (Parallels Plesk Panel 9.2.1)

plesk PLESK_9_0_1 (Parallels Plesk Panel 9.0.1)

plesk PLESK_9_0_0 (Parallels Plesk Panel 9.0.0)

plesk PLESK_8_6_0 (Plesk 8.6.0)

plesk PLESK_7_5_4 (Plesk 7.5.4)

plesk PLESK_8_0_0 (Plesk 8.0.0)

plesk PLESK_8_0_1 (Plesk 8.0.1)

plesk PLESK_8_1_0 (Plesk 8.1.0)

plesk PLESK_8_1_1 (Plesk 8.1.1)

plesk PLESK_8_2_0 (Plesk 8.2.0)

plesk PLESK_8_2_1 (Plesk 8.2.1)

plesk PLESK_8_3_0 (Plesk 8.3.0)

plesk PLESK_8_4_0 (Plesk 8.4.0)

ppsmbe PPSMBE_10_0_0 (Parallels Small Business Panel 10.0.0)

sitebuilder SB_4_5_0 (Sitebuilder 4.5.0)

sso SSO_2_0 (SSO 2.0)

sso SSO_2_1 (SSO 2.1)

To retrieve a list of components for the “selected product version”, you can use

[root@admin /usr/local/psa/admin/bin]# ./autoinstaller –select-release-id PLESK_8_6_0 –show-components

Here I have selected product version as PLESK_8_6_0 Or else with the current release if I need to see what all components can be installed and what are already installed .

4 ) [root@admin /usr/local/psa/admin/bin]# ./autoinstaller –select-release-current –show-components

Downloading the file products.inf3: 100% done.

Downloading the file plesk.inf3: 10%..21%..30%..41%..50%..61%..70%..81%..90%..100% done.

Downloading the file ppsmbe.inf3: 33%..76%..100% done.

Downloading the file sitebuilder.inf3: 15%..35%..55%..96%..100% done.

Downloading the file sso.inf3: 10%..24%..37%..64%..78%..100% done.

Downloading the file setemplates.inf3: 38%..87%..100% done.

Checking for installed packages…

Downloading the file PSA_9.2.3/plesk-9.2.3-fr6.1-i386.inf3: 12%..21%..30%..44%..53%..71%..80%..93%..100% done.

Preparing ports for product installation:

Removing unnecessary packages from the system.

done

Preparing ports for product installation:

Deploying product ports…

Downloading the file PSA_9.2.3/dist-pkg-FreeBSD-6.1-i386/ports/ports-common.tar.gz: 10%..20%..30%..40%..50%..60%..70%..80%..90%..100% done.

Downloading the file PSA_9.2.3/dist-pkg-FreeBSD-6.1-i386/ports/psa-ports-9.2.3.tar.gz: 10%..20%..30%..40%..50%..60%..70%..80%..90%..100% done.

done

Re-installing port ‘swsoft/ports-common’…done

Detecting installed product components.

Detecting installed product components.

base [up2date] – Base packages of Plesk

psa-autoinstaller [up2date] – Plesk Updater

postgresql [up2date] – PostgreSQL server support

vault [install] – Application vault packages

ppwse [install] – Plesk Professional Web Site Editor

api [up2date] – Plesk API [former Plesk Agent]

pmm-ded [install] – Plesk migration manager

sb-publish [install] – SiteBuilder publishing support for Plesk

sbm [install] – SiteBuilder module migration suite

miva [install] – Miva Empresa support

billing [install] – Plesk billing

mod-bw [install] – Bandwidth Limiter For Apache support (mod_bw)

asp [install] – Apache ASP support

java [install] – Tomcat Java Servlets support

mod_python [install] – Apache mod_python module

ruby [install] – Ruby on Rails support

php4 [install] – PHP4 support

php5 [up2date] – PHP5 support

qmail [up2date] – Qmail mailserver

postfix [install] – Postfix mailserver

psa-firewall [install] – Plesk Firewall module

psa-vpn [install] – Plesk VPN module

psa-fileserver [install] – Plesk Fileserver module and SMB file server package

sshterm [install] – SSHTerm – SSH Terminal java applet

watchdog [install] – Watchdog (System monitoring module)

mailman [up2date] – Mailman mailing list manager support

kav [install] – Kaspersky antivirus module

drweb [up2date] – Dr. Web antivirus

spamassassin [install] – SpamAssassin support

backup-ded [install] – Plesk Backup Manager

de-DE-locale [install] – German language pack

ja-JP-locale [install] – Japanese language pack

es-ES-locale [install] – Spanish language pack

ru-RU-locale [install] – Russian language pack

fr-FR-locale [install] – French language pack

it-IT-locale [install] – Italian language pack

zh-CN-locale [install] – Chinese language pack for China

zh-TW-locale [install] – Chinese language pack for Taiwan

nl-NL-locale [install] – Dutch language pack for Netherlands

horde [install] – Horde webmail support

atmail [install] – AtMail webmail support

If you want to install backup for the selected product version PLESK_8_6_0 , use

./autoinstaller –select-release-id PLESK_8_6_0 –install-component backup-ded

(Give the correct component name shown under show-components.It may vary)

Or for the current release if you need webmail

5) [root@admin /usr/local/psa/admin/bin]# ./autoinstaller –select-release-current –install-component horde

After this completes you should be able to access webmail .

webmail2

More details on downloading the auto-installer binary can be found here .

P.S Before you start , always take the backup of plesk psa database , just in case if anything went wrong . ‘Better safe than sorry’ ;)

cd /var/lib/mysql

mysqldump -uadmin -p`cat /etc/psa/.psa.shadow` psa > psabackup.sql

How to Run ASP.NET on Linux With Apache Web Server

Tuesday, November 3rd, 2009

Answer is Mod_Mono . Mod_Mono is an Apache 2.0/2.2 module that allows for hosting of ASP.NET pages .

On Cpanel servers you can easily install this using /scripts/easyapache . But most of the time I have seen it resulted in failure . Cpanel provides another script located at http://bugzilla.cpanel.net/attachment.cgi?id=403 which works like a charm .

Just copy the contents from the site to a file and execute the file . Installing via YUM can be done as below :

# cd /etc/yum.repos.d/
# vi mono.repos
[mono]
name=Mono for rhel-4-i386 (stable)
baseurl=http://go-mono.com/download-stable/rhel-4-i386/
enabled=1
gpgcheck=0

See if it lists the modules# yum list mono*

You will need mono-core , xsp and mod_mono to be installed .

Install the mono-core files:

# yum install mono-core

You may get dependency errors as 

Unable to satisfy dependencies 
Package mono-core needs libicudata.so.26, this is not available. 
Package mono-core needs libicui18n.so.26, this is not available. 
Package mono-core needs libicuuc.so.26, this is not available. 

Then install
# yum install libgdiplus-devel
# yum install mono-core xsp mod_mono

Make sure that you have the mod_mono.conf file, like this in your Apache configuration file:

Include /usr/local/mod_mono/mod_mono.conf

Lets upload a sample file and test its working. Consider your domain name is example.com

# cd /home/example/public_html/

# vi hello.aspx

<%@ Page language="c#" src="hello.aspx.cs" 
Inherits="HelloApp.HelloPage" AutoEventWireup="true" %> 
<html> 
  <body> 
	<form  runat="server"> 
	  What is your name: <asp:TextBox id="name" runat="server" /> 
	  <asp:Button id="greet" Text="Enter" onClick="OnEnterClick" runat="server"/> 
	</form> 
	<br /><strong><asp:Label id="message" runat="server">Hi ! 
			</asp:Label></strong> 
  </body> 
<html> 

# vi hello.aspx.cs

using System; 
using System.Web.UI.WebControls; 
namespace HelloApp 
{ 
public class HelloPage : System.Web.UI.Page 
{ 
protected Label message; 
protected Button Enter; 
protected TextBox name; 
public void OnEnterClick(Object sender, EventArgs e) 
{ 
message.Text = "Hello " + name.Text; 
} 
} 
} 

# chown example.example hello.aspx

# chown example.example hello.aspx.cs

modmono1

modmono2