<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SupportSages &#187; cPanel</title>
	<atom:link href="http://www.supportsages.com/blog/tag/cpanel-control-panel/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.supportsages.com/blog</link>
	<description>Technical Support and Server Management : Musings in the fox hole.</description>
	<lastBuildDate>Thu, 05 Jan 2012 03:05:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>cPanel Website Transfer &#8211; Part 1 &#8211; Changing an Add-on Domain to a Primary Domain</title>
		<link>http://www.supportsages.com/blog/2011/07/cpanel-website-transfer-part-1-changing-an-add-on-domain-to-a-primary-domain/</link>
		<comments>http://www.supportsages.com/blog/2011/07/cpanel-website-transfer-part-1-changing-an-add-on-domain-to-a-primary-domain/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 12:52:52 +0000</pubDate>
		<dc:creator>vince</dc:creator>
				<category><![CDATA[cPanel]]></category>
		<category><![CDATA[Howtos]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[transfer]]></category>
		<category><![CDATA[website]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.supportsages.com/blog/?p=728</guid>
		<description><![CDATA[For Beginners, Learn how to transfer and restore a website in a Linux cPanel envrioment]]></description>
			<content:encoded><![CDATA[<h3><span style="color: #ff0000;"><strong><em><strong><em>Converting an Add-on Domain to a Primary Domain</em></strong></em></strong></span></h3>
<p><strong>Skill Level : Beginner</strong></p>
<p>In this post, I will explain how to convert an add-on domain to a primary domain. Considering a complex case, lets consider the primary domain should be a different one from the one that holds the Add-on domain.</p>
<p><strong>Pre Requisites</strong></p>
<p>Server Platform : Linux</p>
<p>User requires     : cPanel and SSH access (root)</p>
<p>This is a Site transfer. Also both the sites I&#8217;ve mentioned here is on same server.</p>
<p><strong>Case</strong></p>
<p>The Add-on Domain under a website has to be converted as its Primary Domain. If you have a Full backup, its another case. I&#8217;ll explain it in another post.</p>
<p><strong>Solution</strong></p>
<p>Lets consider the Add-on Domain is addon.com under the user admin and the document root of the add-on domain is :</p>
<p>/home/admin/public_html/addon</p>
<p>Now it should be transferred as the Primary Domain</p>
<p>* Using WHM Create a New account primary.com, the document root is then say /home/primary<br />
We&#8217;ve to transfer the whole data from /home/admin/public_html/addon.com to /home/primary/public_html first.</p>
<p>* The Steps will be :</p>
<p>root@server [/home/admin/public_html/addon]# cp -r ./* /home/primary/public_html</p>
<p>This will recursively copy everything inside the PWD to the specified location<br />
<span id="more-728"></span></p>
<p>Don&#8217;t forget to copy .htaccess too</p>
<p>root@server [/home/admin/public_html/addon]# cp .htaccess /home/primary/public_html</p>
<p>* Thats it, the contents are moved, but there is a database too which has to be moved eventually.<br />
* I&#8217;ll site some type of websites like CMS and Blog :</p>
<p>For a Magento website, the database configuration is specified inside the local.xml file which is placed inside the /app/etc directory inside a domain. For example</p>
<p>root@server [/home/admin/public_html/addon]# cd /app/etc<br />
root@server [/home/admin/public_html/addon/app/etc]# cat local.xml</p>
<p>* Watch for these lines in the local.xml file</p>
<p>&lt;username&gt;&lt;![CDATA[admin_user]]&gt;&lt;/username&gt;<br />
&lt;password&gt;&lt;![CDATA[password]]&gt;&lt;/password&gt;<br />
&lt;dbname&gt;&lt;![CDATA[admin_db]]&gt;&lt;/dbname&gt;</p>
<p><![CDATA[admin_user]]&gt;</username></p>
<password><! [CDATA[password]]-->                     <!--[CDATA[admin_user]]&gt;</p>
<p>* From this the DB Name, DB Username and Password can be fetched.</p>
<p>DB Name            :    admin_db<br />
DB Username    :    admin_user<br />
Password       :    password</p>
<p><strong>Other DB Configuration Files</strong></p>
<p>For a WordPress website, the configuration file will be the wp-config.php. Check these lines for the Database configuration details :</p>
<p>// ** MySQL settings &#8211; You can get this info from your web host ** //<br />
/** The name of the database for WordPress */<br />
define(&#8216;DB_NAME&#8217;, &#8216;admin_db&#8217;);</p>
<p>/** MySQL database username */<br />
define(&#8216;DB_USER&#8217;, &#8216;admin_user&#8217;);</p>
<p>/** MySQL database password */<br />
define(&#8216;DB_PASSWORD&#8217;, &#8216;password&#8217;);</p>
<p>/** MySQL hostname */<br />
define(&#8216;DB_HOST&#8217;, &#8216;localhost&#8217;);</p>
<p>For a Joomla website it is the configuration.php where the database details would be defined.</p>
<p>* Access the cPanel of the new primary domain primary.com. Create a new MySQL Database from Databases -&gt; MySQL option, along with a new MySQL user. Make sure you are providing    exact names as in the local.xml file of the addon.com. Next add the user to the database. So the corresponding database credentials at primary.com will be :</p>
<p>DB Name           :    primary_db<br />
DB Username    :    primary_user<br />
Password                 :     password</p>
<p>Screen-shots of Creating a new database and database user :</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2011/05/1.png" class="thickbox no_icon" rel="gallery-728" title="1"><img class="alignnone size-medium wp-image-1860" title="1" src="http://www.supportsages.com/blog/wp-content/uploads/2011/05/1-300x68.png" alt="" width="300" height="68" /></a></p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2011/05/2.png" class="thickbox no_icon" rel="gallery-728" title="2"><img class="alignnone size-medium wp-image-1861" title="2" src="http://www.supportsages.com/blog/wp-content/uploads/2011/05/2-300x79.png" alt="" width="300" height="79" /></a></p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2011/05/3.png" class="thickbox no_icon" rel="gallery-728" title="3"><img class="alignnone size-medium wp-image-1862" title="3" src="http://www.supportsages.com/blog/wp-content/uploads/2011/05/3-300x140.png" alt="" width="300" height="140" /></a></p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2011/05/5.png" class="thickbox no_icon" rel="gallery-728" title="5"><img class="alignnone size-full wp-image-1863" title="5" src="http://www.supportsages.com/blog/wp-content/uploads/2011/05/5.png" alt="" width="276" height="118" /></a></p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2011/05/6.png" class="thickbox no_icon" rel="gallery-728" title="6"><img class="alignnone size-medium wp-image-1864" title="6" src="http://www.supportsages.com/blog/wp-content/uploads/2011/05/6-300x201.png" alt="" width="300" height="201" /></a></p>
<p><strong>Creating DB through Shell</strong></p>
<p>Access MySQL prompt :</p>
<p>$ mysql //Login as Root</p>
<p>mysql&gt; use mysql; //Use MySQL</p>
<p>﻿﻿﻿﻿﻿﻿mysql&gt; create database [﻿primary_db]; //Create a Database</p>
<p>mysql&gt; INSERT INTO primary_user (Host,User,Password) VALUES(&#8216;host&#8217;,'primary_user&#8217;,PASSWORD(&#8216;password&#8217;)); //Insert User</p>
<p>mysql&gt; grant all privileges on primary_db.sql to primary_user@localhost; //Granting all Privileges to user primary_user on the database</p>
<p>Perform Dump :</p>
<p>root@server [/home/primary]# mysqldump dbname &gt; dbname.sql   (Here mysqldump admin_db &gt; admin_db.sql)</p>
<p>* Enter the mysql terminal through the command mysql</p>
<p>mysql &gt; use newdatabasename;          (Here mysql &gt; use primary_db;)<br />
mysql &gt; source olddatabasename.sql;      (Here mysql &gt; source admin_db.sql;)</p>
<p>* For a normal website, you may backup the database by checking the config files and restore it. Use cPanel for that.</p>
<p>* Guess what, You&#8217;re done, the restoration is complete now. Now the primary.com should be working like addon.com.</p>
<div class="tweetthis" style="text-align:left;"><p> <a  class="tt" href="http://twitter.com/home/?status=cPanel+Website+Transfer+-+Part+1+-+Changing+an+Add-on+Domain+to+a+Primary+Domain+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F728" title="Post to Twitter"><img class="nothumb" src="http://www.supportsages.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a  class="tt" href="http://twitter.com/home/?status=cPanel+Website+Transfer+-+Part+1+-+Changing+an+Add-on+Domain+to+a+Primary+Domain+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F728" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.supportsages.com/blog/2011/07/cpanel-website-transfer-part-1-changing-an-add-on-domain-to-a-primary-domain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple backup script for remotely backing up databases</title>
		<link>http://www.supportsages.com/blog/2011/05/simple-backup-script-for-remotely-backing-up-databases/</link>
		<comments>http://www.supportsages.com/blog/2011/05/simple-backup-script-for-remotely-backing-up-databases/#comments</comments>
		<pubDate>Wed, 25 May 2011 18:23:38 +0000</pubDate>
		<dc:creator>George</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[cPanel]]></category>
		<category><![CDATA[cpanel mysql backup]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[remote mysql backup]]></category>

		<guid isPermaLink="false">http://www.supportsages.com/blog/?p=1847</guid>
		<description><![CDATA[This backup script is actually a small modification of another backup script available in Google. I am not able to get that URL to mark/link reference. Only modification I added is a four liner to remove a week old backup automatically. You may also see http://www.supportsages.com/blog/2011/05/applying-wildcards-in-grant-option-of-mysql/ as well. Indenting in python is lost, will fix tomorrow :)

[code lang="python"]

#!/usr/bin/env python
import ConfigParser
import os
import time

# Variable Definition
username = 'cpdbbackups'
password = 'p@ssw0Rd'
hostname = 're.mo.te.ip
backupfolder = '/home/dbbackups/servername'

filestamp = time.strftime('%Y-%m-%d-%H')
deletetime = time.time() - 7 * 86400

# Delete old files

for backup_file in os.listdir (backupfolder):
 full_file_path = os.path.join(backupfolder, backup_file)
 if os.path.getmtime(full_file_path) &#60; deletetime:
 os.unlink(full_file_path)

# Get a list of ...]]></description>
			<content:encoded><![CDATA[<p>This backup script is actually a small modification of another backup script available in Google. I am not able to get that URL to mark/link reference. Only modification I added is a four liner to remove a week old backup automatically. You may also see http://www.supportsages.com/blog/2011/05/applying-wildcards-in-grant-option-of-mysql/ as well. Indenting in python is lost, will fix tomorrow <img src='http://www.supportsages.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre class="brush: python; title: ; notranslate">

#!/usr/bin/env python
import ConfigParser
import os
import time

# Variable Definition
username = 'cpdbbackups'
password = 'p@ssw0Rd'
hostname = 're.mo.te.ip
backupfolder = '/home/dbbackups/servername'

filestamp = time.strftime('%Y-%m-%d-%H')
deletetime = time.time() - 7 * 86400

# Delete old files

for backup_file in os.listdir (backupfolder):
 full_file_path = os.path.join(backupfolder, backup_file)
 if os.path.getmtime(full_file_path) &lt; deletetime:
 os.unlink(full_file_path)

# Get a list of databases with :
database_list_command=&quot;mysql -u%s -p%s -h %s --silent -N -e 'show databases'&quot; % (username, password, hostname)
for database in os.popen(database_list_command).readlines():
 database = database.strip()

 if database == 'information_schema':
 continue
 filename = &quot;%s/%s-%s.sql&quot; % (backupfolder, database, filestamp)
 os.popen(&quot;mysqldump -u%s -p%s -h %s -e --opt -c %s | gzip -c &gt; %s.gz&quot; % (username, password, hostname, database, filename))
</pre>
<div class="tweetthis" style="text-align:left;"><p> <a  class="tt" href="http://twitter.com/home/?status=Simple+backup+script+for+remotely+backing+up+databases+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1847" title="Post to Twitter"><img class="nothumb" src="http://www.supportsages.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a  class="tt" href="http://twitter.com/home/?status=Simple+backup+script+for+remotely+backing+up+databases+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1847" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.supportsages.com/blog/2011/05/simple-backup-script-for-remotely-backing-up-databases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Applying wildcards in GRANT option of MySQL</title>
		<link>http://www.supportsages.com/blog/2011/05/applying-wildcards-in-grant-option-of-mysql/</link>
		<comments>http://www.supportsages.com/blog/2011/05/applying-wildcards-in-grant-option-of-mysql/#comments</comments>
		<pubDate>Wed, 25 May 2011 10:27:19 +0000</pubDate>
		<dc:creator>George</dc:creator>
				<category><![CDATA[cPanel]]></category>
		<category><![CDATA[Howtos]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[cPanel server backup]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysqldump]]></category>

		<guid isPermaLink="false">http://www.supportsages.com/blog/?p=1841</guid>
		<description><![CDATA[We had this particular requirement of creating a database user to be used to backup only the cPanel databases. Only recently the database mapping has been introduced by cPanel which allows the clients to create databases without the _ . However on all our client servers, we insist to have the old style with every database has Prefixing On.

Creating the database user to backup only the cPanel databases, means matching the databases with an underscore (_) in its name and that resulted in this particular SQL command to be executed as root user.

[bash]GRANT ALL PRIVILEGES ON `%\_%`.* TO `cpdbbackups`@`re.mo.te.ip` IDENTIFIED ...]]></description>
			<content:encoded><![CDATA[<p>We had this particular requirement of creating a database user to be used to backup only the cPanel databases. Only recently the database mapping has been introduced by cPanel which allows the clients to create databases without the _ . However on all our client servers, we insist to have the old style with every database has Prefixing On.</p>
<p>Creating the database user to backup only the cPanel databases, means matching the databases with an underscore (_) in its name and that resulted in this particular SQL command to be executed as root user.</p>
<pre class="brush: bash; title: ; notranslate">GRANT ALL PRIVILEGES ON `%\_%`.* TO `cpdbbackups`@`re.mo.te.ip` IDENTIFIED BY 'p@ssw0Rd' WITH GRANT OPTION;</pre>
<p>Read more about the cPanel&#8217;s DB mapping at http://www.cpanel.net/blog/integration/2010/05/more-details-about-db-mapping.html</p>
<div class="tweetthis" style="text-align:left;"><p> <a  class="tt" href="http://twitter.com/home/?status=Applying+wildcards+in+GRANT+option+of+MySQL+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1841" title="Post to Twitter"><img class="nothumb" src="http://www.supportsages.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a  class="tt" href="http://twitter.com/home/?status=Applying+wildcards+in+GRANT+option+of+MySQL+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1841" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.supportsages.com/blog/2011/05/applying-wildcards-in-grant-option-of-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL for Beginners</title>
		<link>http://www.supportsages.com/blog/2011/02/mysql-for-beginners/</link>
		<comments>http://www.supportsages.com/blog/2011/02/mysql-for-beginners/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 16:12:40 +0000</pubDate>
		<dc:creator>vince</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[cPanel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[repair]]></category>
		<category><![CDATA[WHM]]></category>

		<guid isPermaLink="false">http://www.supportsages.com/blog/?p=1753</guid>
		<description><![CDATA[In this post, I'll explain some basic MySQL tips that would be very useful for beginners

<strong>Reset MySQL root password</strong>

Log in as Root and Stop the MySQL daemon. Then Start the MySQL daemon and skip the grant tables which store the passwords.

[bash]# /etc/init.d/mysql stop[/bash]

[bash]# mysqld_safe --skip-grant-tables[/bash]

[bash]# mysql -u root[/bash]

[bash]mysql&#62; use mysql;[/bash]

Now you should be able to connect to mysql without a password. If not, it might be some other issues. Execute the command to reset the password

[bash]mysql&#62; update user set Password=PASSWORD('new-password') where user='root';
mysql&#62; flush privileges;
mysql&#62; exit[/bash]

After this you need to kill the running mysqld and restart it normally.

<strong>Creation of MySQL database, ...]]></description>
			<content:encoded><![CDATA[<p>In this post, I&#8217;ll explain some basic MySQL tips that would be very useful for beginners</p>
<p><strong>Reset MySQL root password</strong></p>
<p>Log in as Root and Stop the MySQL daemon. Then Start the MySQL daemon and skip the grant tables which store the passwords.</p>
<pre class="brush: bash; title: ; notranslate"># /etc/init.d/mysql stop</pre>
<pre class="brush: bash; title: ; notranslate"># mysqld_safe --skip-grant-tables</pre>
<pre class="brush: bash; title: ; notranslate"># mysql -u root</pre>
<pre class="brush: bash; title: ; notranslate">mysql&gt; use mysql;</pre>
<p>Now you should be able to connect to mysql without a password. If not, it might be some other issues. Execute the command to reset the password</p>
<pre class="brush: bash; title: ; notranslate">mysql&gt; update user set Password=PASSWORD('new-password') where user='root';
mysql&gt; flush privileges;
mysql&gt; exit</pre>
<p>After this you need to kill the running mysqld and restart it normally.</p>
<p><strong>Creation of MySQL database, user and access rights</strong></p>
<p>It should be very easy to create a database through cpanel or some other panel. But if you are on your own with only Shell access, try this :</p>
<pre class="brush: bash; title: ; notranslate"># mysql -u root -p
 mysql&gt; use mysql;
 mysql&gt; INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES  ('%','databasename','username','Y','Y','Y','Y','Y','N');
 mysql&gt; flush privileges;
</pre>
<p>Or you can use</p>
<pre class="brush: bash; title: ; notranslate">
mysql&gt; grant all privileges on databasename.* to username@localhost;
mysql&gt; flush privileges;
</pre>
<p><strong>MySQLdump and Restore</strong></p>
<p>The <strong>mysqldump</strong> client is a database backup.  It can be used to dump a         database or a collection of databases for backup or transfer to         another SQL server (not necessarily a MySQL server). The dump         typically contains SQL statements to create the table, populate         it, or both.</p>
<p>Creating a Mysqldump is quite easy. If you know the database name, say database :</p>
<pre class="brush: bash; title: ; notranslate"># mysqldump database &gt; database.sql</pre>
<p>When restoring a Database, make sure you login as the user. In other words, do not restore a database with root privileges. It may cause real damage. Assuming that you are logged in as the user</p>
<pre class="brush: bash; title: ; notranslate">&lt;strong&gt; &lt;/strong&gt;
mysql&gt; use dbname; //Which is the database which the backup has to be restored to
mysql &gt; source olddb.sql; //Backup
</pre>
<p><strong>Repair a corrupted Database</strong></p>
<p>Switch to the database directory which is having issues with, Like :</p>
<pre class="brush: bash; title: ; notranslate"># cd /var/lib/mysql/database</pre>
<p>Stop the MySQL server</p>
<pre class="brush: bash; title: ; notranslate"># /etc/init.d/mysql stop</pre>
<p>Check the tables</p>
<pre class="brush: bash; title: ; notranslate"># myisamchk *.MYI</pre>
<p>Repair the tables</p>
<pre class="brush: bash; title: ; notranslate"># myisamchk -r *.MYI</pre>
<p>Start the MySQL server</p>
<pre class="brush: bash; title: ; notranslate"># /etc/init.d/mysql start</pre>
<p><strong>phpMyadmin</strong></p>
<p>phpMyAdmin is an open source tool written in PHP intended to handle the administration of MySQL over the World Wide Web. It can perform various tasks such as creating, modifying or deleting databases, tables, fields or rows; executing SQL statements; or managing users and permissions.</p>
<p>If you are having a cPanel or WHM interface, its quite easy to manage a database. In cPanel interface, go to Databases section</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2011/02/cpanel_phpmyadmin.png" class="thickbox no_icon" rel="gallery-1753" title="cpanel_phpmyadmin"><img class="alignnone size-full wp-image-1770" title="cpanel_phpmyadmin" src="http://www.supportsages.com/blog/wp-content/uploads/2011/02/cpanel_phpmyadmin.png" alt="" width="513" height="114" /></a></p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2011/02/whm_phpmyadmin.png" class="thickbox no_icon" rel="gallery-1753" title="whm_phpmyadmin"><img class="alignnone size-large wp-image-1772" title="whm_phpmyadmin" src="http://www.supportsages.com/blog/wp-content/uploads/2011/02/whm_phpmyadmin-1024x191.png" alt="" width="500" height="110" /></a></p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2011/02/phpmyadmin_main.png" class="thickbox no_icon" rel="gallery-1753" title="phpmyadmin_main"><img class="alignnone size-medium wp-image-1775" title="phpmyadmin_main" src="http://www.supportsages.com/blog/wp-content/uploads/2011/02/phpmyadmin_main-300x127.png" alt="" width="500" height="250" /></a></p>
<p>This is the main phpMyadmin page.</p>
<p>In WHM, at SQL Services you can perform a variety of options. As mentioned earlier, the database repair option (for corrupted databases) can be performed here also. Access the option &#8216;Repair a Database&#8217;</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2011/02/repair_db_pma.png" class="thickbox no_icon" rel="gallery-1753" title="repair_db_pma"><img class="alignnone size-medium wp-image-1774" title="repair_db_pma" src="http://www.supportsages.com/blog/wp-content/uploads/2011/02/repair_db_pma-300x77.png" alt="" width="500" height="120" /></a></p>
<p>Select the Database name and Click Repair Database.</p>
<p>These are quite simple tasks associated with MySQL operations.</p>
<div class="tweetthis" style="text-align:left;"><p> <a  class="tt" href="http://twitter.com/home/?status=MySQL+for+Beginners+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1753" title="Post to Twitter"><img class="nothumb" src="http://www.supportsages.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a  class="tt" href="http://twitter.com/home/?status=MySQL+for+Beginners+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1753" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.supportsages.com/blog/2011/02/mysql-for-beginners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Gems not getting updated</title>
		<link>http://www.supportsages.com/blog/2010/10/ruby-gems-not-getting-updated/</link>
		<comments>http://www.supportsages.com/blog/2010/10/ruby-gems-not-getting-updated/#comments</comments>
		<pubDate>Fri, 22 Oct 2010 10:42:03 +0000</pubDate>
		<dc:creator>George</dc:creator>
				<category><![CDATA[cPanel]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[giving response code 302]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.supportsages.com/blog/?p=1425</guid>
		<description><![CDATA[On a cPanel server, I ran /scripts/installruby which updated the ruby version from 1.8.6 to 1.8.7

[bash]ruby -v
ruby 1.8.7 (2009-06-08 patchlevel 173) [i686-linux][/bash]

But when updating the gems and the gem itself, we were getting error as below,

<code>
gem update --system
Updating RubyGems...
ERROR:  While executing gem ... (Gem::RemoteSourceException)
    HTTP Response 302 fetching http://gems.rubyforge.org/yaml
</code>

Solution was to specify another source as below, which was the 302 redirection of http://gems.rubyforge.org/yaml . May be gem now handles the 302 redirection properly.

[bash]gem install rubygems-update --source http://production.s3.rubygems.org/ [/bash]

followed by the gem update itself.

[bash]sudo gem update --system --source http://production.s3.rubygems.org/[/bash]

To add the source permanently, use the command below ...]]></description>
			<content:encoded><![CDATA[<p>On a cPanel server, I ran /scripts/installruby which updated the ruby version from 1.8.6 to 1.8.7</p>
<pre class="brush: bash; title: ; notranslate">ruby -v
ruby 1.8.7 (2009-06-08 patchlevel 173) [i686-linux]</pre>
<p>But when updating the gems and the gem itself, we were getting error as below,</p>
<p><code><br />
gem update --system<br />
Updating RubyGems...<br />
ERROR:  While executing gem ... (Gem::RemoteSourceException)<br />
    HTTP Response 302 fetching http://gems.rubyforge.org/yaml<br />
</code></p>
<p>Solution was to specify another source as below, which was the 302 redirection of http://gems.rubyforge.org/yaml . May be gem now handles the 302 redirection properly.</p>
<pre class="brush: bash; title: ; notranslate">gem install rubygems-update --source http://production.s3.rubygems.org/ </pre>
<p>followed by the gem update itself.</p>
<pre class="brush: bash; title: ; notranslate">sudo gem update --system --source http://production.s3.rubygems.org/</pre>
<p>To add the source permanently, use the command below and for more help
<pre class="brush: plain; title: ; notranslate">gem help sources</pre>
<pre class="brush: bash; title: ; notranslate">gem sources -a http://production.s3.rubygems.org/</pre>
<div class="tweetthis" style="text-align:left;"><p> <a  class="tt" href="http://twitter.com/home/?status=Ruby+Gems+not+getting+updated++http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1425" title="Post to Twitter"><img class="nothumb" src="http://www.supportsages.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a  class="tt" href="http://twitter.com/home/?status=Ruby+Gems+not+getting+updated++http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1425" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.supportsages.com/blog/2010/10/ruby-gems-not-getting-updated/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to create a RPM from source package(Creating CSF RPM)</title>
		<link>http://www.supportsages.com/blog/2010/08/how-to-create-a-rpm-from-source-packagecreating-csf-rpm/</link>
		<comments>http://www.supportsages.com/blog/2010/08/how-to-create-a-rpm-from-source-packagecreating-csf-rpm/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 08:20:18 +0000</pubDate>
		<dc:creator>Fabian</dc:creator>
				<category><![CDATA[Howtos]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[cPanel]]></category>
		<category><![CDATA[csf]]></category>
		<category><![CDATA[csf rpm]]></category>
		<category><![CDATA[rpm]]></category>
		<category><![CDATA[rpm for csf]]></category>

		<guid isPermaLink="false">http://www.supportsages.com/blog/?p=1190</guid>
		<description><![CDATA[We create RPM's from the Source for a package. As an initial step, compile and install the source using normal procedures just to confirm all necessary libraries/dependencies are met.

Here I am explaining the whole process to create an RPM for CSF that could be  installed on cPanel servers.

<strong>Getting ready with the Source Files:</strong>

Download Latest CSF from here : http://www.configserver.com/free/csf.tgz

Extract the tarball.

[bash][root@server new]# tar -xvf csf.tgz
[root@server new]# ls
csf  csf.tgz[/bash]

Install to check all libraries/dependencies are met.

[bash][root@server csf]# cd csf
[root@server csf]# sh install.cpanel.sh
*WARNING* TESTING mode is enabled - do not forget to disable it in the configuration
Installation Completed[/bash]

We confirmed all libraries/dependencies are met ...]]></description>
			<content:encoded><![CDATA[<p>We create RPM&#8217;s from the Source for a package. As an initial step, compile and install the source using normal procedures just to confirm all necessary libraries/dependencies are met.</p>
<p>Here I am explaining the whole process to create an RPM for CSF that could be  installed on cPanel servers.</p>
<p><strong>Getting ready with the Source Files:</strong></p>
<p>Download Latest CSF from here : http://www.configserver.com/free/csf.tgz</p>
<p>Extract the tarball.</p>
<pre class="brush: bash; title: ; notranslate">[root@server new]# tar -xvf csf.tgz
[root@server new]# ls
csf  csf.tgz</pre>
<p>Install to check all libraries/dependencies are met.</p>
<pre class="brush: bash; title: ; notranslate">[root@server csf]# cd csf
[root@server csf]# sh install.cpanel.sh
*WARNING* TESTING mode is enabled - do not forget to disable it in the configuration
Installation Completed</pre>
<p>We confirmed all libraries/dependencies are met for installing CSF.  We need to rename the tarball to define a version so that it could be used in the SPEC file.</p>
<pre class="brush: bash; title: ; notranslate">[root@server csf]# cd ..
[root@server new]# ls
csf  csf.tgz
[root@server new]#mv csf csf-0.0.1
[root@server new]# tar -cvf csf-0.0.1.tar.gz csf-0.0.1</pre>
<p>0.0.1 defines the version. (Can assign any). Now we are ready with the source file for CSF csf-0.0.1.tar.gz that could be used to generate RPM.</p>
<p><strong>Building the RPM:</strong></p>
<p>Install RPMBUILD tool: <strong></strong></p>
<pre class="brush: bash; title: ; notranslate">[root@server ~]# yum install rpm-build</pre>
<p>We never build RPM&#8217;s as &#8216;root&#8217; users, but as normal users, because root can alter any file on the system, it was easy to inadvertently alter a running system by adding extraneous files or removing important files during interim builds of an RPM. Earlier RPM&#8217;s were build as root user but recently the RPM system changed to allow any user to build RPMs in a home directory. Building an RPM without the privileges of root prevents changes to core system files and hence we are on the safer side.</p>
<p>Initial Set-up:</p>
<p>We need to create a directory hierarchy for the rpm build tool to work with. To begin with, create a directory under your home directory which will act as the root directory for the build process. Lets make a directory &#8216;csfrpm&#8217; under home directory for this purpose.</p>
<pre class="brush: bash; title: ; notranslate">[sage@server ~]$ mkdir -p /home/your_username/csfrpm</pre>
<pre class="brush: bash; title: ; notranslate">[sage@server ~]$ cd /home/your_username/csfrpm</pre>
<p>Create Five sub-directories under csfrpm.</p>
<pre class="brush: bash; title: ; notranslate">[sage@server csfrpm]$ mkdir BUILD RPMS SOURCES SPECS SRPMS</pre>
<ul>
<li>BUILD: BUILD is used as a space to compile the software.</li>
<li>RPMS: RPMS contains the binary RPM that rpmbuild builds.</li>
<li>SOURCES: SOURCES is for source code.</li>
<li>SPECS: SPECS contains your spec file or files—one spec file per RPM you want to build.</li>
<li>SRPMS: SRPMS contains the source RPM built during the process.</li>
</ul>
<pre class="brush: bash; title: ; notranslate">[sage@server csfrpm]$ ls
BUILD  RPMS  SOURCES  SPECS  SRPMS</pre>
<p>Copy the source code that we have created(csf-0.0.1.tar.gz) to the SOURCES folder. Make sure that the owner  for source file is your_username.</p>
<pre class="brush: bash; title: ; notranslate">[sage@server ~]$ cp csf-0.0.1.tar.gz /home/your_username/csfrpm/SOURCES/</pre>
<p>Create the SPEC file:</p>
<p>SPEC file is noting but the configuration for rpmbuild tool.</p>
<pre class="brush: bash; title: ; notranslate">[sage@server csfrpm]$ vi SPECS/csf.spec</pre>
<pre class="brush: bash; title: ; notranslate"># This is a sample spec file for csf

%define _topdir         /home/your_username/csfrpm
%define name            csf
%define release         0
%define version         0.0.1
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Summary:                GNU csf
License:                GPL
Name:                   %{name}
Version:                %{version}
Release:                %{release}
Source:                 %{name}-%{version}.tar.gz
Group:                  Security/Tools

%description
A Stateful Packet Inspection (SPI) firewall, Login/Intrusion Detection and Security application for Linux servers.

%prep
%setup -q

%install
./install.cpanel.sh prefix=$RPM_BUILD_ROOT/usr/local

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-,root,root,0755)</pre>
<p>Finally Build the RPM:</p>
<pre class="brush: bash; title: ; notranslate">[sage@server csfrpm]$ rpmbuild -v -bb --clean SPECS/csf.spec</pre>
<p>You can see the result if everything went fine:</p>
<pre class="brush: bash; title: ; notranslate">Processing files: csf-0.0.1-0
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/csf-0.0.1-root
Wrote: /home/your_username/csfrpm/RPMS/i386/csf-0.0.1-0.i386.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.84469
+ umask 022
+ cd /home/your_username/csfrpm/BUILD
+ cd csf-0.0.1
+ /bin/rm -rf /var/tmp/csf-0.0.1-root
+ exit 0
Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.84469
+ umask 022
+ cd /home/yuor_username/csfrpm/BUILD
+ rm -rf csf-0.0.1
+ exit 0</pre>
<p>The RPM is written to /home/your_username/csfrpm/RPMS/i386/csf-0.0.1-0.i386.rpm</p>
<div class="tweetthis" style="text-align:left;"><p> <a  class="tt" href="http://twitter.com/home/?status=How+to+create+a+RPM+from+source+package%28Creating+CSF+RPM%29+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1190" title="Post to Twitter"><img class="nothumb" src="http://www.supportsages.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a  class="tt" href="http://twitter.com/home/?status=How+to+create+a+RPM+from+source+package%28Creating+CSF+RPM%29+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1190" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.supportsages.com/blog/2010/08/how-to-create-a-rpm-from-source-packagecreating-csf-rpm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgreSQL for the sage &#8211; Must know basics for the system administrators</title>
		<link>http://www.supportsages.com/blog/2010/08/postgresql-for-the-sage-must-know-basics-for-the-system-administrators/</link>
		<comments>http://www.supportsages.com/blog/2010/08/postgresql-for-the-sage-must-know-basics-for-the-system-administrators/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 16:24:44 +0000</pubDate>
		<dc:creator>victor</dc:creator>
				<category><![CDATA[cPanel]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Howtos]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[restore]]></category>

		<guid isPermaLink="false">http://www.supportsages.com/blog/?p=1144</guid>
		<description><![CDATA[﻿﻿PostgreSQL or Postgres is an object-relational database management system (ORDBMS). Unlike MySQL, PostgreSQL is not controlled by any single company, it is a community developed project. It is a advanced version of the 'Ingres' Database project (which is how the project gets the name post-ingres or postgres ).

Postgres is one of the best open-source database alternative which is fully object oriented and transactions compliant. It has stored procedures, multiple views and a huge set of datatypes. Some of the other notable features are as follows.

<strong>Objects and Inheritance</strong>

Database consists of objects and the database administrators can design custom or user-defined objects ...]]></description>
			<content:encoded><![CDATA[<p>﻿﻿PostgreSQL or Postgres is an object-relational database management system (ORDBMS). Unlike MySQL, PostgreSQL is not controlled by any single company, it is a community developed project. It is a advanced version of the &#8216;Ingres&#8217; Database project (which is how the project gets the name post-ingres or postgres ).</p>
<p>Postgres is one of the best open-source database alternative which is fully object oriented and transactions compliant. It has stored procedures, multiple views and a huge set of datatypes. Some of the other notable features are as follows.</p>
<p><strong>Objects and Inheritance</strong></p>
<p>Database consists of objects and the database administrators can design custom or user-defined objects for the tables. Inheritance is another feature. Tables can be set to inherit their characteristics from a &#8220;parent&#8221; table.</p>
<p><strong>Functions </strong></p>
<p>Functions can be used in Postgres. These can be written in the postgres&#8217; own procedural language called &#8216;PL/pgSQL&#8217; which resembles Oracle&#8217;s procedural language &#8216;PL/SQL&#8217; or any other common scripting languages which support posgtres&#8217; procedural language like PL/Perl, plPHP, PL/Python, PL/Ruby etc. Run the following in the psql client to determine if functions is enabled:</p>
<pre class="brush: bash; title: ; notranslate">SELECT true FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'; </pre>
<p>To create user-defined functions we use the CREATE OR REPLACE FUNCTION  command.  Example:</p>
<pre class="brush: bash; title: ; notranslate">CREATE OR REPLACE FUNCTION fib (

fib_for integer

) RETURNS integer AS $$

BEGIN

IF fib_for &lt; 2 THEN

RETURN fib_for;

END IF;

RETURN fib(fib_for - 2) + fib(fib_for - 1);

END;

$$ LANGUAGE plpgsql;</pre>
<p><strong>Indexes </strong></p>
<p>An index is like a summary of a certain portion of the table. It is an optimization technique which increases speed of accessing records from a database. PostgreSQL supports indexes like Btree, hash etc. User-defined index methods can also be created. Indexes are created on tables with respect to a particular field (based on which there are a number of queries). As an example for a table:</p>
<pre class="brush: bash; title: ; notranslate">CREATE TABLE name (

id integer,

fname varchar

lname varchar

);</pre>
<p>To create an index on table name with respective to the field id (as there are many queries on this table requesting for firstname or lastname from the id provided), we use the index:</p>
<pre class="brush: bash; title: ; notranslate">CREATE INDEX name_id_index ON name (id);</pre>
<p><strong>Triggers</strong></p>
<p>Triggers are events or functions run upon the action of certain SQL statements which modify data in some records. Depending on the kind of modification we can have multiple triggers in a database. Postgres supports multiple triggers written in PL/PgSQL or it&#8217;s scripting counterparts like PL/Python. The trigger function must be defined before the trigger can be created. The trigger function must be declared as a function taking no arguments and returning type trigger. CREATE TRIGGER command is used to declare triggers.</p>
<p><strong>Concurrency </strong></p>
<p>PostgreSQL ensures concurrency with the help of MVCC (Multi-Version Concurrency Control), which gives the database user a &#8220;snapshot&#8221; of the database, allowing changes to be made without being visible to other users until a transaction is committed.</p>
<p>PostgreSQL&#8217;s MVCC keeps all of the versions of the data together in the same partition in the same table. By identifying which rows were added by which transactions, which rows were deleted by which transactions, and which transactions have actually committed, it becomes a straightforward check to see which rows are visible for which transactions.</p>
<p>Inorder to accomplish this, Rows of a table are stored in PostgreSQL as a tuple. Two fields of each tuple are xmin and xmax. Xmin is the transaction ID of the transaction that created the tuple. Xmax is the transaction ID of the transaction that deleted it (if any).</p>
<p>Along with the tuples in each table, a record of each transaction and its current state (in progress, committed, aborted) is kept in a universal transaction log.</p>
<p>When data in a table is selected, only those rows that are created and not destroyed are seen. That is, each row&#8217;s xmin is observed. If the xmin is a transaction that is in progress or aborted, then the row is invisible. If the xmin is a transaction that has committed, then the xmax is observed. If the xmax is a transaction that is in progress or aborted and not the current transaction, or if there is no xmax at all, then the row is seen. Otherwise, the row is considered as already deleted.</p>
<p>Insertions are straightforward. The transaction that inserts the tuple simply creates it with the xmax blank and the xmin set to its transaction ID. Deletions are also straightforward. The tuple&#8217;s xmax is set to the current transaction. Updates are no more than a concurrent insert and delete.</p>
<p><strong>Views</strong></p>
<p>A view is a table which does not exist in the database. It is a virtual table created from fields in various tables and is joined together based on some criteria. Views can be used in place of tables and will accomplish the task same as that of a table. The CREATE VIEW statement is used to accomplish this eg:</p>
<pre class="brush: bash; title: ; notranslate">CREATE VIEW best_sellers AS

SELECT * FROM publishers WHERE demand LIKE 'high';</pre>
<p><strong>Foreign Keys</strong></p>
<p>The primary key used in one table which is used to refer to the records in a second table is called the foreign key of the second table.</p>
<pre class="brush: bash; title: ; notranslate">CREATE TABLE products (
    product_no integer PRIMARY KEY,
    name text,
    price numeric
);
CREATE TABLE orders (
    order_id integer PRIMARY KEY,
    product_no integer REFERENCES products (product_no),
    quantity integer
);</pre>
<p>Here product_no is the foreign key in the second table created. The foreign key field may have values which are repeated unlike primary keys.</p>
<p><strong>Files Users and Configuration</strong></p>
<p>The main configuration file of Postgres is postgresql.conf. This can be located in the &#8216;data&#8217; directory. It may be present either in /var/lib (/var/lib/pgsql/data/postgresql.conf) or /usr/local (/usr/local/pgsql/data/postgresql.conf). Temporary changes to the configurations can be made using postmaster command.</p>
<p>The init script that starts the postgres service is /etc/init.d/postgresql . It runs a number of child processes concurrently. The postgres server process is postmaster. These processes and files associated with PosgreSQL are owned by the user/group postgres. The default port used for database connections is 5432</p>
<p>The user postgres is the PostgreSQL database superuser. We can create a number of super users for the database (this accomplished by the create role command ), however, the default super user is postgres. The postgres user has the privilege to access all the databases and files in the server (Unless the user root is created in postgres as a superuser).</p>
<p>Client Authentication is controlled by the file pg_hba.conf in the data directory, e.g., /var/lib/pgsql/data/pg_hba.conf. (HBA stands for host-based authentication.)</p>
<p>Each record specifies a connection type, a client IP address range (if relevant for the connection type), a database name or names, and the authentication method to be used for connections matching these parameters.A record is typically in one of two forms:</p>
<p>local   database authentication-method [ authentication-option ]</p>
<p>host    database IP-address IP-mask authentication-method [ authentication-option ]</p>
<p>local : This record pertains to connection attempts over Unix domain sockets.</p>
<p>host : This record pertains to connection attempts over TCP/IP networks.</p>
<p>database : Specifies the database that this record applies to. The value all specifies that it applies to all databases, while the value sameuser identifies the database with the same name as the connecting user.</p>
<p>authentication methods</p>
<p>trust: The connection is allowed unconditionally.</p>
<p>reject: The connection is rejected unconditionally.</p>
<p>password: The client is required to supply a password which is required to match the database password that was set up for the user.</p>
<p>md5: Like the password method, but the password is sent over the wire encrypted using a simple challenge-response protocol.</p>
<p>ident: This method uses the &#8220;Identification Protocol&#8221; as described in RFC 1413. It may be used to authenticate TCP/IP or Unix domain socket connections, but its reccomended use is for local connections only and not remote connections.</p>
<p><strong>Front-ends </strong></p>
<p>The minimalistic front-end for PostgreSQL is the psql command-line. It can be used to enter SQL queries directly, or execute them from a file. phpPgAdmin is a web-portal used for PostgreSQL administration written in PHP and based on the popular phpMyAdmin. Likewise pgAdmin is a graphical front-end administration tool for PostgreSQL, which has support on multiple platforms. The latest stable version of the same is pgAdmin III.</p>
<p><strong>Some administration related commands</strong></p>
<p>Command to login to psql database mydb as user myuser:</p>
<pre class="brush: bash; title: ; notranslate">psql -d mydb -U myuser</pre>
<p>Command to login to psql database mydb as user myuser on a different host myhost:</p>
<pre class="brush: bash; title: ; notranslate">psql -h myhost -d mydb -U myuser</pre>
<p>If the port the server runs is different we use -p [port number] . Upon entering the psql shell the prompt will show the database name currently being used. In the above example it will show</p>
<pre class="brush: bash; title: ; notranslate">mydb=&gt; (if logged in as an ordinary user )</pre>
<pre class="brush: bash; title: ; notranslate">mydb=# (if logged in as a super user like postgres)</pre>
<p><strong>Create a PostgreSQL user </strong></p>
<p>There are two ways to create a postgres database user. The only user initially allowed to create users is postgres. So one has to switch to this user before creating other users with varying privileges.</p>
<p>1. Creating the user in the shell prompt, with createuser command.</p>
<p>switch to the postgres user with:</p>
<pre class="brush: bash; title: ; notranslate">su - postgres

createuser tom

Shall the new role be a superuser? (y/n) n

Shall the new role be allowed to create databases? (y/n) y

Shall the new role be allowed to create more new roles? (y/n) n</pre>
<p>2. Creating the user in the PSQL prompt, with CREATE USER command.</p>
<p>switch to the postgres user with:</p>
<pre class="brush: bash; title: ; notranslate">su - postgres

create user mary with password 'marypass';</pre>
<p><strong>Creating and deleting a PostgreSQL Database </strong></p>
<p>There are two way to create databases.</p>
<p>1. Creating database in the PSQL prompt, with createuser command.</p>
<pre class="brush: bash; title: ; notranslate">CREATE DATABASE db1 WITH OWNER tom;</pre>
<p>2. Creating database in the shell prompt, with createdb command.</p>
<pre class="brush: bash; title: ; notranslate">createdb db2 -O mary</pre>
<p>To delete an entire database from within the psql prompt do :</p>
<pre class="brush: bash; title: ; notranslate">DROP DATABASE db1;</pre>
<p><strong>Determining execution time of a query</strong></p>
<p>Turn on timing with</p>
<pre class="brush: bash; title: ; notranslate">\timing</pre>
<p>Now execute the qery:</p>
<pre class="brush: bash; title: ; notranslate">SELECT * from db1.employees ;

Time: 0.065 ms</pre>
<p><strong>Calculate postgreSQL database size in disk </strong></p>
<pre class="brush: bash; title: ; notranslate">SELECT pg_database_size('db1');</pre>
<p>to get the values in human readable format</p>
<pre class="brush: bash; title: ; notranslate">SELECT pg_size_pretty(pg_database_size('db1'));</pre>
<p>to calculate postgreSQL table size in disk</p>
<p>SELECT pg_size_pretty(pg_total_relation_size(&#8216;big_table&#8217;));</p>
<p><strong>Slash commands used in psql</strong></p>
<p>To list all slash commands and thier purpose. Login to psql and issue to the command \? . Some of the most commonly used slash commands are the following:</p>
<table>
<tbody>
<tr>
<td>List databases</td>
<td>\l</td>
</tr>
<tr>
<td>System tables</td>
<td>\dS</td>
</tr>
<tr>
<td>Types</td>
<td>\dT</td>
</tr>
<tr>
<td>Functions</td>
<td>\df</td>
</tr>
<tr>
<td>Operators</td>
<td>\do</td>
</tr>
<tr>
<td>Aggregates</td>
<td>\da</td>
</tr>
<tr>
<td>Users</td>
<td>\du</td>
</tr>
<tr>
<td>Quit from psql</td>
<td>\q</td>
</tr>
<tr>
<td>Connect to different database db2</td>
<td>\c db2</td>
</tr>
<tr>
<td>Describe Table/index/view/sequence</td>
<td>\d</td>
</tr>
</tbody>
</table>
<p>The below can be used with a specific table/index/view name for description of the specific table/index/view</p>
<table>
<tbody>
<tr>
<td>Tables</td>
<td>\dt</td>
</tr>
<tr>
<td>Indexes</td>
<td>\di</td>
</tr>
<tr>
<td>Sequences</td>
<td>\ds</td>
</tr>
<tr>
<td>Views</td>
<td>\dv</td>
</tr>
</tbody>
</table>
<p><strong>Useful Bash commands</strong></p>
<p>Bash command to list all the postgresql databases:</p>
<pre class="brush: bash; title: ; notranslate">psql -l #This can be run as a unix user who is also a super user in postgresql</pre>
<p>Indirect bash command to list all the postgresl users:</p>
<pre class="brush: bash; title: ; notranslate">psql -c '\du' #-c is used to run an internal or sql command in psql shell</pre>
<p><strong>Backing up and restoring databases</strong></p>
<p>To dump the database to an sql file use the bash command:</p>
<pre class="brush: bash; title: ; notranslate">pg_dump mydb &amp;gt; db.out</pre>
<p>To restore a database from an sql backup file (via bash)</p>
<pre class="brush: bash; title: ; notranslate">psql -d newdb -f backupdb.out

or

psql -f backupdb.out newdb</pre>
<p>(here the database newdb must be already created and the file backupdb.out must be present in the current directory)</p>
<p>To take the backup of all the Postgres databases in the server:</p>
<pre class="brush: bash; title: ; notranslate">pg_dumpall &gt; /var/lib/pgsql/backups/dumpall.sql</pre>
<p>(Only possible with the postgres or the database superuser )</p>
<p><strong>Resetting database user&#8217;s password</strong></p>
<p>To change the password for a database user (say &#8216;thomas&#8217;):</p>
<pre class="brush: bash; title: ; notranslate">ALTER USER thomas WITH PASSWORD 'newpassword';</pre>
<p>This same command can be used to reset the password for the postgresql super user postgres, but in this case, you will have to enable password less login for postgres user by adding the following line to the top of the file pg_hba.conf in the data directory of postgres. Once the password is reset this line can be removed:</p>
<pre class="brush: bash; title: ; notranslate">local	all	postgres	trust</pre>
<p>Next we issue the same command but for the user postgres</p>
<pre class="brush: bash; title: ; notranslate">ALTER USER postgres WITH PASSWORD 'newpassword';</pre>
<p>To create a super user via bash with multiple roles</p>
<pre class="brush: bash; title: ; notranslate">createuser -sPE mysuperuser</pre>
<p>Instead of this we can also use the below psql shell command:</p>
<pre class="brush: bash; title: ; notranslate">CREATE ROLE mysuperuser2 WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD 'mysuperpass2';</pre>
<p><strong>Physical database files in postgres</strong></p>
<p>The files in data/base are named by the oid (Object Identifier) of the database record in</p>
<p>pg_database, like this:</p>
<pre class="brush: bash; title: ; notranslate">cd /var/lib/pgsql/data/base

ls -l

total 33

drwx------ 22 postgres postgres 4096 Jul 23 20:06 ./

drwx------ 11 postgres postgres 4096 Aug  1 05:59 ../

drwx------  2 postgres postgres 4096 Jun 20 09:32 1/

drwx------  2 postgres postgres 4096 Mar  3 13:36 10792/

drwx------  2 postgres postgres 4096 Jun 20 15:09 10793/

drwx------  2 postgres postgres 4096 May 27 01:40 16497/

drwx------  2 postgres postgres 4096 May 27 01:40 16589/

drwx------  2 postgres postgres 4096 Jun 20 10:28 16702/

drwx------  2 postgres postgres 4096 May 27 01:40 16764/

drwx------  2 postgres postgres 4096 May 27 01:40 16785/

drwx------  2 postgres postgres 4096 Aug  1 04:37 16786/

drwx------  2 postgres postgres 4096 Aug  1 04:36 19992/

drwx------  2 postgres postgres 4096 May 27 01:40 19997/</pre>
<p>To obtain the oid, execute the following command in psql prompt</p>
<pre class="brush: bash; title: ; notranslate">postgres=# select oid,datname from pg_database order by oid;

   oid  |         datname

---------+--------------------------

1 | template1

10792 | template0

10793 | postgres

16497 | gadgetwi_Unable

16589 | vimusicc_filehost

16702 | personea_altissimo

16764 | shopping_businessfinance

16785 | ansonyi_wp2

16786 | ansonyi_wp

19992 | globook_PostgreSQL</pre>
<div class="tweetthis" style="text-align:left;"><p> <a  class="tt" href="http://twitter.com/home/?status=PostgreSQL+for+the+sage+-+Must+know+basics+for+the+system+administrators+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1144" title="Post to Twitter"><img class="nothumb" src="http://www.supportsages.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a  class="tt" href="http://twitter.com/home/?status=PostgreSQL+for+the+sage+-+Must+know+basics+for+the+system+administrators+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1144" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.supportsages.com/blog/2010/08/postgresql-for-the-sage-must-know-basics-for-the-system-administrators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prevent your mail/IP from getting marked as SPAM/Blacklisted, A few TIPS!</title>
		<link>http://www.supportsages.com/blog/2010/07/prevent-your-mailip-from-getting-marked-as-spamblacklisted-a-few-tips/</link>
		<comments>http://www.supportsages.com/blog/2010/07/prevent-your-mailip-from-getting-marked-as-spamblacklisted-a-few-tips/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 02:47:40 +0000</pubDate>
		<dc:creator>Fabian</dc:creator>
				<category><![CDATA[cPanel]]></category>
		<category><![CDATA[Howtos]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Webmail]]></category>
		<category><![CDATA[DKIM]]></category>
		<category><![CDATA[dkim cpanel]]></category>
		<category><![CDATA[DomainKeys]]></category>
		<category><![CDATA[exim]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[SenderID]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[SPF]]></category>

		<guid isPermaLink="false">http://www.supportsages.com/blog/?p=1031</guid>
		<description><![CDATA["<strong>SPAM</strong>"! A word familiar to all Netizens.

Emails plays a major role in today's business, one must be keen to preserve the authenticity of mails they sent to the users and fail to do so may result in getting your mail server IP blacklisted and mails ends-up in users junk folder and they die!

This post is not a perfect guide to prevent you from getting blacklisted by the spamcops, but a few tips that could save your "Time" and "Reputation".

1) All email is filtered against published blacklists of spam servers. Check whether your mailserver IP is already blacklisted : http://www.mxtoolbox.com/. If ...]]></description>
			<content:encoded><![CDATA[<p>&#8220;<strong>SPAM</strong>&#8220;! A word familiar to all Netizens.</p>
<p>Emails plays a major role in today&#8217;s business, one must be keen to preserve the authenticity of mails they sent to the users and fail to do so may result in getting your mail server IP blacklisted and mails ends-up in users junk folder and they die!</p>
<p>This post is not a perfect guide to prevent you from getting blacklisted by the spamcops, but a few tips that could save your &#8220;Time&#8221; and &#8220;Reputation&#8221;.</p>
<p>1) All email is filtered against published blacklists of spam servers. Check whether your mailserver IP is already blacklisted : http://www.mxtoolbox.com/. If listed, take necessary actions to remove it. You can temporarily switch the mail server IP to get the mails moving until your regular IP is released.</p>
<p>2) All mails will be filtered based on certain rules. It looks for senders email address, mail subject line and words on the message content. Avoid using blank subject line and using common spammers words like &#8220;offer, discount, sale, free etc&#8230; There are a lot more..</p>
<p>3) Maintain a regular time intervals while sending mails to a particular sender. This could be setup on exim configuration file. (Needs admin privileges)</p>
<p>4) <strong>Enable SPF</strong>:<br />
Sender Policy Framework (SPF), is an e-mail validation system designed to prevent e-mail spam by addressing a common vulnerability, source address spoofing. SPF allows administrators to specify which hosts are allowed to send e-mail from a given domain by creating a specific DNS SPF record in the public DNS for that domain. Mail exchangers then use the DNS to check that mail from a given domain is being sent by a host sanctioned by that domain&#8217;s administrators.</p>
<p>If SPF record is enabled for a domain, spammers and phishers are less likely to forge e-mails pretending to be from that domain. Spam filters now check for SPF records and hence eliminate the chance of forged mails, spams. Hence an SPF protected domain is less attractive to spammers and phishers and is less likely to be blacklisted by spam filters and ligitimate mails will go through.</p>
<p>SPF keeps the detail of the machine which is only authorized to send mails for that particular domain. This is done by adding additional a TXT record to their existing DNS records. Mail receivers that checks for SPF records check the domain DNS and finds whether the server is allowed to send mails for that domain.</p>
<p><span id="more-1031"></span></p>
<p>The key issue in SPF is the specification for the new DNS information that domains set and receivers use. Eg is :</p>
<p>example.com. IN SPF &#8220;v=spf1 a mx -all&#8221;</p>
<p>&#8220;v=&#8221; defines the version of SPF used. &#8220;v=&#8221; defines the version of SPF used. The following words provide mechanisms to use to determine if a domain is eligible to send mail. The &#8220;a&#8221; and &#8220;mx&#8221; specify the systems permitted to send messages for the given domain. The &#8220;-all&#8221; at the end specifies that, if the previous mechanisms did not match, the message should be rejected.</p>
<p>On a cPanel server, one can easily enable SPF records.</p>
<p>Login to cPanel account for that particular domain ==&gt; Email Authentication ==&gt; Scroll down to SPF section ==&gt; and Click on Enable.</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2010/07/spf_disabled.jpg" class="thickbox no_icon" rel="gallery-1031" title="spf_disabled"><img class="aligncenter size-medium wp-image-1033" title="spf_disabled" src="http://www.supportsages.com/blog/wp-content/uploads/2010/07/spf_disabled-260x300.jpg" alt="" width="260" height="300" /></a></p>
<p>Enable SPF :</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2010/07/spf_enabled.jpg" class="thickbox no_icon" rel="gallery-1031" title="spf_enabled"><img class="aligncenter size-medium wp-image-1034" title="spf_enabled" src="http://www.supportsages.com/blog/wp-content/uploads/2010/07/spf_enabled-300x90.jpg" alt="" width="300" height="90" /></a></p>
<p>SPF record on Domain DNS.</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2010/07/spf_dns.jpg" class="thickbox no_icon" rel="gallery-1031" title="spf_dns"><img class="aligncenter size-medium wp-image-1035" title="spf_dns" src="http://www.supportsages.com/blog/wp-content/uploads/2010/07/spf_dns-300x12.jpg" alt="" width="300" height="12" /></a></p>
<p>5) <strong>Enable SenderID:</strong></p>
<p>SenderID is also an anti-spoofing method to save emails from Junk. SenderID is heavily based on SPF with a few additions. Like in SPF, DNS entries are used on the domain DNS to ensure the authenticity of emal. But they differ on what rules they apply to what fields contained in the message header.</p>
<p>How SenderID works:</p>
<ul>
<li>Sender sends an e-mail to Receiver.</li>
<li>Receiver’s inbound e-mail server receives e-mail and calls its Sender ID Framework.</li>
<li>The Sender ID Framework looks up the SPF record of the domain that Sender is using for sending the mail.</li>
<li>The receiving Mail Transfer Agent (MTA) determines if the outbound Mail Server IP address matches IP addresses that are authorized to send mail for the user</li>
</ul>
<p>DNS entry for SenderID enabled domain looks like,</p>
<p style="text-align: center;"><a  href="http://www.supportsages.com/blog/wp-content/uploads/2010/07/senderid.jpg" class="thickbox no_icon" rel="gallery-1031" title="senderid"><img class="aligncenter size-full wp-image-1090" title="senderid" src="http://www.supportsages.com/blog/wp-content/uploads/2010/07/senderid.jpg" alt="" width="500" height="18" /></a></p>
<p>You can Generate SenderID from here : <a  href="http://www.microsoft.com/mscorp/safety/content/technologies/senderid/wizard/" target="_blank">http://www.microsoft.com/mscorp/safety/content/technologies/senderid/wizard/</a></p>
<p>6) <strong>Enable Domain Keys:</strong></p>
<p>DomainKeys is the branded name created by Yahoo. It has been introduced by Yahoo to fight against spams. DomainKeys is a PGP-like (Pretty Good Privacy) protocol for validating and authenticating an email. This system includes the creation of a public and private key. You keep your private key private and give your public key to your trusties. We encrypt data with our private key and users can decrypt messages with our public key.  This prevents others from seeing our data. Domain Keys takes this idea one step further. Instead of encrypting the email, it encrypts the email headers and creates a hash value from that encryption. The hash value is send/placed in the email header. When a site receives an email, it locates the public key which is located in the DNS server for the user listed in the From: line of the email and encrypts the email once again to compare the hash value.  If the hash values match after the second encryption test, the email passes validation.</p>
<p>DomainKeys is an system that allows for incoming mail to be checked against the server it was sent from to verify that the mail has not been modified and thereby ensures that messages are actually coming from the listed sender and allows abusive messages to be tracked with more ease.</p>
<p>Yahoo check for domankeys  on a domain if they are requested to whitelist the IP. Below are the steps to enable DomanKeys on a cPanel server.</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2010/07/spfndkenabled.jpg" class="thickbox no_icon" rel="gallery-1031" title="spfndkenabled"><img class="aligncenter size-medium wp-image-1036" title="spfndkenabled" src="http://www.supportsages.com/blog/wp-content/uploads/2010/07/spfndkenabled-300x113.jpg" alt="" width="300" height="113" /></a></p>
<p>DNS entries for DomainKeys and SPF</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2010/07/domain_keysnspf.jpg" class="thickbox no_icon" rel="gallery-1031" title="domain_keysnspf"><img class="aligncenter size-large wp-image-1039" title="domain_keysnspf" src="http://www.supportsages.com/blog/wp-content/uploads/2010/07/domain_keysnspf-1024x85.jpg" alt="" width="491" height="41" /></a></p>
<p>Once DomainKeys are enabled you can check whether it is setup correctly by sending a test mail addresses set up to  dk@dk.crynwr.com</p>
<p>7) <strong>Enable DKIM</strong> :</p>
<p>DKIM is the result of combining Yahoo’s DomainKeys technology with Identified Internet Mail which was developed at Cisco which is another methodology of PGP-like technique.<br />
DomainKeys and DKIM sounds similar but there are different. DKIM was created to provide a more robust solution that would survive more types of modification to which messages are frequently subjected. DomainKeys Identified Mail (DKIM) lets an organization take responsibility for a message while it is in transit.  The organization is a handler of the message, either as its originator or as an intermediary. Their reputation is the basis for evaluating whether to trust the message for delivery. Technically DKIM provides a method for validating a domain name identity that is associated with a message through cryptographic authentication.</p>
<p>DKIM is not available as a ready-made option in cPanel server till now. If you are running an VPS and know basic administration, you can get it enabled. Login to the server via SSH and check if if exim is compiled with DKIM support enabled.</p>
<pre class="brush: bash; title: ; notranslate">﻿root@server # /usr/sbin/exim -dd 2&gt;&amp;1 | grep Experimental_DKIM

Support for: crypteq iconv() IPv6 PAM Perl OpenSSL Content_Scanning Old_Demime Experimental_SPF Experimental_SRS
Experimental_DomainKeys Experimental_DKIM</pre>
<p>Generate the SSL keys</p>
<pre class="brush: bash; title: ; notranslate">cd /usr/local/cpanel/etc/exim</pre>
<pre class="brush: bash; title: ; notranslate">openssl genrsa -out dkim.key 1024</pre>
<pre class="brush: bash; title: ; notranslate">openssl rsa -in dkim.key -out dkim.public -pubout -outform PEM</pre>
<p>You will find two keys, dkim.key &amp; dkim.public</p>
<p>Open dkim.public and copy the contents excluding the –Begin– and –End– section. This is your DKIM key.  Now open exim configuration file and append the below entries under the section ‘remote_smtp’</p>
<p>Sample file:<br />
vi /etc/exim.conf</p>
<pre class="brush: plain; title: ; notranslate">remote_smtp
driver = smtp
dkim_domain=your_domain_name.com
dkim_selector=mail
dkim_private_key=/usr/local/cpanel/etc/exim/dkim.key #path to the dkim.key key.
interface = ${if exists {/etc/mailips}{${lookup{$sender_address_domain}lsearch*{/etc/mailips}{$value}{}}}{}}
helo_data = ${if exists {/etc/mailhelo}{${lookup{$sender_address_domain}lsearch*{/etc/mailhelo}{$value}{$primary_hostname}}}
{$primary_hostname}}</pre>
<p>Now on WHM, open DNS editor for the particular domain and add the TXT entry with DKIM key like below.</p>
<pre class="brush: plain; title: ; notranslate">mail._domainkey.example.com. IN TXT &quot;v=DKIM1;g=*;k=rsa; p=GIGmGA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDv4PSEG9PcxlI2tRojAUQ9hpRQ0Zj/XG4SK08/DrhG/CaspJAKZm9rZDAw18TrmuXeRgsGWAdS2vJ4Oa/kXqX0NG2eBJcGasu4GeNXANGXvC1uGz+8GC6rEPlE/Ucau4tGAHOZL0HJ9IDd/PIxoTkeTG3GjGeqvKBLbdvVIDXbcQIDAQAB&quot;</pre>
<p>Here p=the_key_you_have_copied_from_dkim.public</p>
<p>Restart exim and named services.</p>
<pre class="brush: bash; title: ; notranslate">/scripts/restartsrv exim</pre>
<pre class="brush: bash; title: ; notranslate">/scripts/restartsrv named</pre>
<p>To check whether DKIM is setup properly, send a mail to dkimtest@atmail.org , if setup properly, you will get a reply like below ,else a failure message.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Subject:    AutoReply from dkimtest@atmail.org<br />
From:    spftest@example.com<br />
Date:    Fri, Jul 9, 2010 10:27 pm<br />
To:    spftest@example.com<br />
*** DKIM TEST SUCCESSFUL ***<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>8 ) <strong>Join JMRP : </strong></p>
<p>JMRP/Junk Mail Report Program is a free service to provide reports on junk e-mail issues reported by  Windows Live Hotmail users. You can use this free service to which is developed commercial mailers and e-mail administrators to identify/fix issues in sending mails to hotmails ID&#8217;s. JMRP returns the full message with headers of any e-mail marked as “junk” or “phishing” by a recipient.  Provides senders an opportunity to clean their e-mail lists and improve the quality of their content and helps identify potential problems with your marketing practices and content and also improves sender reputation by removing unwanted subscribers from lists.</p>
<p>You can join LMRP from here : <a  href="https://support.msn.com/default.aspx?st=1&#038;website=msn&#038;tenant=oss&#038;brand=msn&#038;as=1&#038;timestmp=634147865953276556&#038;acty=ProductList&#038;ctl=oss%2fcontent%2fmsn_support_home&#038;wf=OSS&#038;trl=OSS~ProductList&#038;c=oss_msn&#038;ln=en-us&#038;productKey=edfsjmrpp&#038;sub=free" target="_blank">http://bit.ly/JMRP</a></p>
<p>N:B :- Mail server mentioned here is cPanel Exim, you may replace this with any other mail server.</p>
<div class="tweetthis" style="text-align:left;"><p> <a  class="tt" href="http://twitter.com/home/?status=Prevent+your+mail%2FIP+from+getting+marked+as+SPAM%2FBlacklisted%2C+A+few+TIPS%21+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1031" title="Post to Twitter"><img class="nothumb" src="http://www.supportsages.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a  class="tt" href="http://twitter.com/home/?status=Prevent+your+mail%2FIP+from+getting+marked+as+SPAM%2FBlacklisted%2C+A+few+TIPS%21+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F1031" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.supportsages.com/blog/2010/07/prevent-your-mailip-from-getting-marked-as-spamblacklisted-a-few-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to resolve : Internal Server Error when accessing cpanel/WHM/Webmail</title>
		<link>http://www.supportsages.com/blog/2010/06/how-to-resolve-internal-server-error-when-accessing-cpanelwhmwebmail/</link>
		<comments>http://www.supportsages.com/blog/2010/06/how-to-resolve-internal-server-error-when-accessing-cpanelwhmwebmail/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 19:13:12 +0000</pubDate>
		<dc:creator>vince</dc:creator>
				<category><![CDATA[Howtos]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Specials]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[cPanel]]></category>
		<category><![CDATA[inode issue]]></category>
		<category><![CDATA[inodes]]></category>
		<category><![CDATA[internal server error]]></category>
		<category><![CDATA[more than 400 attempts to make a session failed]]></category>
		<category><![CDATA[Webmail]]></category>
		<category><![CDATA[WHM]]></category>

		<guid isPermaLink="false">http://www.supportsages.com/blog/?p=927</guid>
		<description><![CDATA[Imagine you are accessing your Website WHM or cPanel or Webmail hosted (in your VPS) and what if you see this

<a href="http://www.supportsages.com/blog/wp-content/uploads/2010/06/cpanel-inode-full-issue.png"><img class="alignnone size-medium wp-image-929" title="cpanel inode full issue" src="http://www.supportsages.com/blog/wp-content/uploads/2010/06/cpanel-inode-full-issue-300x63.png" alt="Image showing the issue" width="300" height="63" /></a><span style="text-decoration: underline;"><strong> </strong></span>

<span style="text-decoration: underline;"><strong>How to solve this</strong></span>

Pre-Requisites : You should have Shell access (as root) to the Node server.

Mostly this happens due to inode issue. The inodes allocated to the server maybe full. <strong>inode</strong> is a data structure on a traditional Unix-style file system such as UFS. An inode stores basic information about a regular file, directory, or other file system object.

<strong>Steps</strong>

Say ...]]></description>
			<content:encoded><![CDATA[<p>Imagine you are accessing your Website WHM or cPanel or Webmail hosted (in your VPS) and what if you see this</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2010/06/cpanel-inode-full-issue.png" class="thickbox no_icon" rel="gallery-927" title="cpanel inode full issue"><img class="alignnone size-medium wp-image-929" title="cpanel inode full issue" src="http://www.supportsages.com/blog/wp-content/uploads/2010/06/cpanel-inode-full-issue-300x63.png" alt="Image showing the issue" width="300" height="63" /></a><span style="text-decoration: underline;"><strong> </strong></span></p>
<p><span style="text-decoration: underline;"><strong>How to solve this</strong></span></p>
<p>Pre-Requisites : You should have Shell access (as root) to the Node server.</p>
<p>Mostly this happens due to inode issue. The inodes allocated to the server maybe full. <strong>inode</strong> is a data structure on a traditional Unix-style file system such as UFS. An inode stores basic information about a regular file, directory, or other file system object.</p>
<p><strong>Steps</strong></p>
<p>Say we are logged into the Node Server. There we are going to list all the Containers existing on the Hardware Node. By default, only running Containers are shown.</p>
<pre class="brush: bash; title: ; notranslate">
[root@linuxvps1 ~]# vzlist -a
CTID    NPROC STATUS   IP_ADDR        HOSTNAME
100     18  running    100.20.11.111  WEB.EXAMPLE.COM
101     63  running    100.20.12.203  -
102     169 running    100.20.92.182  server2.example.com
103     81  running    100.20.56.169  example.net
78965   236 running    100.20.77.204  server1.example.com
</pre>
<p>Assume your container is 103. So simply enter into 103 by this command</p>
<pre class="brush: bash; title: ; notranslate">
[root@linuxvps1 ~]# vzctl enter 103
</pre>
<p>Check if the inodes are full in the container</p>
<pre class="brush: bash; title: ; notranslate">
[root@linuxvps1 ~]# df -i
</pre>
<p>Most Probably it should display something like this :</p>
<pre class="brush: bash; title: ; notranslate">
Filesystem      Inodes      IUsed        IFree     IUse%      Mounted on
/dev/vzfs       200000      200000       0         100%       /
none            65536       95           65441     1%         /dev
</pre>
<p>Bang ! The inodes on /dev/vzfs mounted on / are full. You&#8217;ve to go nowhere else to see why that error was delivered. A simple solution will work out, you&#8217;ve to increase the inode limit. You&#8217;ve two options, either through Shell or through the Node Control Panel (like Parallels Infrastructure Manager)</p>
<p>First we will go through Shell mode with this command :</p>
<pre class="brush: bash; title: ; notranslate">$ vzctl set veid --diskinodes softlimit:hardlimit </pre>
<p>Where &#8216;veid&#8217; is the VPS ID</p>
<pre class="brush: bash; title: ; notranslate">root@linuxvps1 ~]# vzctl set 103 --diskinodes 7680100:7680200</pre>
<p>Second we are going for Node Control Panel. In the infrastructure, you will see your VPS with a ! sign. That indicates your VPS is having some sort of issue.</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2010/06/cp12.png" class="thickbox no_icon" rel="gallery-927" title="cp1"><img class="alignnone size-full wp-image-934" title="cp1" src="http://www.supportsages.com/blog/wp-content/uploads/2010/06/cp12.png" alt="" width="195" height="159" /></a></p>
<p>So you&#8217;ve seen the Alert. Next access the VPS, go to Resources tab. I&#8217;m sorry to tell you that I grabbed this screenshot after resolving the issue, but it will help you anyway</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2010/06/cp2.png" class="thickbox no_icon" rel="gallery-927" title="cp2"><img class="alignnone size-full wp-image-935" title="cp2" src="http://www.supportsages.com/blog/wp-content/uploads/2010/06/cp2.png" alt="" width="616" height="408" /></a></p>
<p>You should see the &#8216;Disk Inodes&#8217; is full under &#8216;Disk Usage&#8217; category (Here it is not !). Next Click Configure to settle this one</p>
<p><a  href="http://www.supportsages.com/blog/wp-content/uploads/2010/06/cp41.png" class="thickbox no_icon" rel="gallery-927" title="cp4"><img class="alignnone size-full wp-image-937" title="cp4" src="http://www.supportsages.com/blog/wp-content/uploads/2010/06/cp41.png" alt="" width="1192" height="394" /></a>See the Highlighted part, the inodes should be limited to some size. Increase it or remove the check mark to make it unlimited.  Make sure you save the changes. Now try again accessing cpanel/WHM/Webmail. It should load with out any issues.That makes a smile in your face, isn&#8217;t it ? <img src='http://www.supportsages.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<div class="tweetthis" style="text-align:left;"><p> <a  class="tt" href="http://twitter.com/home/?status=How+to+resolve+%3A+Internal+Server+Error+when+accessing+cpanel%2FWHM%2FWebmail+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F927" title="Post to Twitter"><img class="nothumb" src="http://www.supportsages.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a  class="tt" href="http://twitter.com/home/?status=How+to+resolve+%3A+Internal+Server+Error+when+accessing+cpanel%2FWHM%2FWebmail+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F927" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.supportsages.com/blog/2010/06/how-to-resolve-internal-server-error-when-accessing-cpanelwhmwebmail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cPanel, postgresql and a default database issue with 8.4.x versions of postgres</title>
		<link>http://www.supportsages.com/blog/2010/05/cpanel-postgresql-and-a-default-database-issues-with-8-4-x-versions-of-postgres/</link>
		<comments>http://www.supportsages.com/blog/2010/05/cpanel-postgresql-and-a-default-database-issues-with-8-4-x-versions-of-postgres/#comments</comments>
		<pubDate>Sun, 23 May 2010 20:18:01 +0000</pubDate>
		<dc:creator>arnold</dc:creator>
				<category><![CDATA[cPanel]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[default database]]></category>
		<category><![CDATA[template1]]></category>

		<guid isPermaLink="false">http://www.supportsages.com/blog/?p=614</guid>
		<description><![CDATA[The issue was there, because customer wanted a latest version of Postgresql, latest than what cPanel support by default.

<strong>Issue reported in the phppGAdmin page was</strong>

[plain]
FATAL:  password authentication failed for user &#34;cPanel_username&#34;
FATAL:  permission denied for database &#34;template1&#34;
DETAIL:  User does not have CONNECT privilege.
[/plain]

<span id="more-614"></span>

<strong>Solution</strong>

[bash]
# su - postgres
-bash-3.2$ psql
psql (8.4.2)
Type &#34;help&#34; for help.

postgres=# alter user cPanel_username with password 'password_here';
ALTER ROLE
postgres=# alter user cPanelusername_username with password 'password_here';
[/bash]

Check for issues in /var/lib/pgsql/pgstartup.log . That is where postgreSQL throws out errors which will be helpful in debugging the issues.

In prior releases, template1 was used both as a default connection for utilities like ...]]></description>
			<content:encoded><![CDATA[<p>The issue was there, because customer wanted a latest version of Postgresql, latest than what cPanel support by default.</p>
<p><strong>Issue reported in the phppGAdmin page was</strong></p>
<pre class="brush: plain; title: ; notranslate">
FATAL:  password authentication failed for user &quot;cPanel_username&quot;
FATAL:  permission denied for database &quot;template1&quot;
DETAIL:  User does not have CONNECT privilege.
</pre>
<p><span id="more-614"></span></p>
<p><strong>Solution</strong></p>
<pre class="brush: bash; title: ; notranslate">
# su - postgres
-bash-3.2$ psql
psql (8.4.2)
Type &quot;help&quot; for help.

postgres=# alter user cPanel_username with password 'password_here';
ALTER ROLE
postgres=# alter user cPanelusername_username with password 'password_here';
</pre>
<p>Check for issues in /var/lib/pgsql/pgstartup.log . That is where postgreSQL throws out errors which will be helpful in debugging the issues.</p>
<p>In prior releases, template1 was used both as a default connection for utilities like createuser, and as a template for new  databases.  This caused CREATE DATABASE to sometimes fail, because a new database cannot be created if anyone else is in the template database. With this change, the default connection database is now postgres, meaning it is much  less likely someone will be using template1 during CREATE DATABASE.</p>
<p>Also, do change the postgresql configuration file of cPanel installation,  /usr/local/cpanel/base/3rdparty/phpPgAdmin/conf/config.inc.php</p>
<p>Look for</p>
<pre class="brush: plain; title: ; notranslate">
$conf['servers'][0]['defaultdb'] = 'template1';
</pre>
<p>and change it to</p>
<pre class="brush: plain; title: ; notranslate">
$conf['servers'][0]['defaultdb'] = 'postgres';
</pre>
<p>Don&#8217;t forget to chattr also. BTW now a days, cPanel is intelligent enough to detect and remove the chattrs also <img src='http://www.supportsages.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<div class="tweetthis" style="text-align:left;"><p> <a  class="tt" href="http://twitter.com/home/?status=cPanel%2C+postgresql+and+a+default+database+issue+with+8.4.x+versions+of+postgres++http%3A%2F%2Fwww.supportsages.com%2Fblog%2F614" title="Post to Twitter"><img class="nothumb" src="http://www.supportsages.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a  class="tt" href="http://twitter.com/home/?status=cPanel%2C+postgresql+and+a+default+database+issue+with+8.4.x+versions+of+postgres++http%3A%2F%2Fwww.supportsages.com%2Fblog%2F614" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.supportsages.com/blog/2010/05/cpanel-postgresql-and-a-default-database-issues-with-8-4-x-versions-of-postgres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

