Upgrading PostgreSQL on Cpanel Server

Guide available for CentOS / Fedora / RHEL

  • Make sure if you have postgresql intalled
    rpm -qa | grep postgres | tee /root/rpm_pgsql

    The above will list all the installed postgresql rpm packages and store the output to /root/rpm_pgsql. You can use this list to remove all the postgresql related rpm later.

  • Backup all your databases
    su postgres -
    mkdir backups 
    pg_dumpall > /var/lib/pgsql/backups/postgresql_backup
    exit

    exit will logout from the postgres user

  • Now stop the postgrsql daemon using the following command
    /sbin/service postgresql stop
  • Backup the whole database folder
    mv /var/lib/pgsql /var/lib/pgsql_old
  • Remove the old rpms using rpm -e, you can use the previously stored /root/rpm_pgsql to remove the postgresql rpm and its depended, for example the perl-DBD-pg depends on it. So you will be removing the /root/rpm_pgsql list + perl-DBD-gpFor example, it might differ on your servers
    rpm -e rh-postgresql-server
    rpm -e rh-postgresql
    rpm -e rh-postgresql-devel
    rpm -e rh-postgresql-python
    rpm -e rh-postgresql-libs
    rpm -e perl-DBD-Pg
  • Download the new version of postgreSQL from the postgresql download site into
    /usr/local/src or any directory you prefer.
  • After you have download the postgreSQL rpms from PostgreSQL download site.
    Download the following rpms

    postgresql-***-2PGDG.i686.rpm
    postgresql-contrib-***-2PGDG.i686.rpm
    postgresql-devel-***-2PGDG.i686.rpm
    postgresql-docs-***-2PGDG.i686.rpm
    postgresql-libs-***-2PGDG.i686.rpm
    postgresql-python-***-2PGDG.i686.rpm
    postgresql-server-***-2PGDG.i686.rpm

    To install

    rpm -Uhv postgresql*.rpm
  • After you have installed the new postgreSQL rpms login to WHM usinghttps://ip:2087
    under the SQL service Menu
    Postgres Config
    Install new configuration and change the password
  • To restore the old databases
    psql template1 < /var/lib/pgsql_old/postgresql_backup_file

    The above will restore the databases

  • Notes: This is a manual installation, on the current cPanel 11, /scripts/installpostgres will definitely do the job, the guide is pretty old, but still, this should be very easy to do.
  • VERY CAREFUL, in order to have apache/php working with postgres, you have to recompile, either from WHM, either from shell, with postgres support.

Original guide here

The remote server didn’t report a correct md5sum of the archive.

“The remote server didn’t report a correct md5sum of the archive. Please ensure you selected the correct type of remote server.”

If this error comes in,  and you are trying to move cPanel accounts between 2 servers, then you must be running Chirpy’s CSF. If so, do a quick allow on both servers, for each server’s main ips. It will work flawlessly.

Data transfer in  progress.

How do I fix this “ALTER TABLE smf_smileys ORDER BY LENGTH” error I am getting?

While upgrading and possibly editing smileys in the Smileys section of your Administration Panel, you may get an error similar to this:

Quote

This query:
ALTER TABLE smf_smileys
ORDER BY LENGTH(code) DESC;
Caused the error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘LENGTH(code) DESC’ at line 2
There are two solutions to resolve this error.

The first solution will fix both the issue with upgrading, as well as an issue with editing smileys in the Smileys and Message Icons section of your admin panel.
All you need to do is update your MySQL version. To update MySQL yourself, you will have to have server access. Otherwise, and more commonly the case, you will have to ask your host to upgrade MySQL on the server for you. Some older versions of MySQL seem to have this issue. At the moment the MySQL versions known with this are:

  • 5.0.37
  • 5.0.41
  • 5.0.42
  • 5.1.17(Unconfirmed)

There may be other versions of MySQL that have this issue as well, but upgrading MySQL to the latest version for the MySQL branch you are using may resolve the issue.

The second way to resolve this for upgrading is to open “upgrade_1-1.sql” with a text editor and find the following:

Code:

ALTER TABLE {$db_prefix}smileys
ORDER BY LENGTH(code) DESC;

Replacing this with:

Code:

ALTER TABLE {$db_prefix}smileys
ORDER BY code DESC;

For editing smileys in the Smileys and Message Icons section of your admin panel, open “/Sources/ManageSmileys.php” with a text editor and find the following code:

Code:

			// Sort all smiley codes for more accurate parsing (longest code first).
			db_query("
				ALTER TABLE {$db_prefix}smileys
				ORDER BY LENGTH(code) DESC", __FILE__, __LINE__);

Replacing this with:

Code:

			// Sort all smiley codes for more accurate parsing (longest code first).
			db_query("
				ALTER TABLE {$db_prefix}smileys
				ORDER BY code DESC", __FILE__, __LINE__);

This section of code will appear twice in “/Sources/ManageSmileys.php“, You will find this approximatively on lines 654 and 990.

Source

Sorry, the nameserver ip cannot be removing since it is still registered with an ICANN register.

If any time this issue will pop up if on your cPanel server while modifying nameserver ip’s, do :

whm > tweak settings  ==> “Disable whois lookups for the nameserver IP manager.” <- tick this box.

Then you’re on your way

How do I disable the IPv6 protocol?

Red Hat Enterprise Linux 4 has Internet Protocol Version 6 (IPv6) enabled by default. In certain situations, it may be desirable to disable IPv6.

To do this, first remove this line from /etc/modprobe.conf if this line exists. (Most Red Hat Enterprise Linux systems will not have one).

alias net-pf-10 ipv6

Next, add the following line to /etc/modprobe.conf:

alias net-pf-10 off

Reboot the system. IPv6 support should now be disabled.

To re-enable IPv6, simply remove the alias net-pf-10 off line from /etc/modprobe.conf and reboot the machine.

UPDATE: the ipv6 still it’s not disabled, so we continue with:

Add to /etc/sysconfig/network file:   
NETWORKING_IPV6=no
/etc/sysconfig/network-scripts/ifcfg-XXXXX file;
IPV6INIT=no

Ftp passive mode. Cant login. Entering Passive Mode

Greetings,

If you are not able to login to your ftp account with correct password and if it hangs messaging Entering Passive Mode with your local machince Ip or server IP:Random_port_no then you can try this.

Open the port range from 30000 to 50000. See the range that you are getting in your error. Open the port range according to the error that you get.

iptables -A INPUT -p tcp –dport 30000:50000 -j ACCEPT

/etc/init.d/iptables save

/etc/init.d/iptables restart.

Go to your ftp configration file. If its pure-ftp then you will have option there

to /etc/pure-ftpd.conf (without the leading #):
PassivePortRange 30000 35000
Then restart pure-ftpd and csf and pass

I am not sure about other ftp software like vsftpd or proftpd.

Else you can stp firewall and try login to ftp that will even solve your problem but its better to use above method rather then stopping firewall cause disabling firewall is insecure way. :)

Cheers..!

Fix OpenDNS Servers with cpanel

OpenDNS servers sunt o problema, load care nu e necesar pe server, si mi se pare ca se poate face si update la dns zones de catre persoane neautorizate, in zonele hostate pe serverul respectiv. Incercati, si daca aveti probleme, comment, si dau infos.

#!/usr/bin/perl

@ips = `ifconfig`;
chomp @ips;

print “\n\nacl \”trusted\” {\n”;
foreach my $line (@ips) {
if ($line =~ /inet addr:(\d+\.\d+\.\d+\.\d+)/) {
print ”        $1;\n”;
}
}
print “};\n\n”;
print “options {\n”;
print ”        directory \”/var/named\”;\n”;
print ”        dump-file \”/var/named/data/cache_dump.db\”;\n”;
print ”        statistics-file \”/var/named/data/named_stats.txt\”;\n”;
print ”        version \”not currently available\”;\n”;
print ”        allow-recursion { trusted; };\n”;
print ”        allow-notify { trusted; };\n”;
print ”        allow-transfer { trusted; };\n”;
print “};\n\n”

save thhe above text in file name x.pl

type perl x.pl >> out.txt

copy the data in the output in your named.conf

restart named.conf

for any bugs or trouple feel free to comment

Displaying the Logon Status using Data shaping via ADSI

Pt Active Directory, pentru admini care au nevoie, un script interesant, pe care il folosesc ocazional la work.

Being able to display logon information via the various Exchange administrator tools has been around for a while but until Exchange 2003 there was never any scriptable interface you could use to display this data . Although for various reasons this data is never 100% accurate it can be used to get an indication of who’s logged onto the server and what client they are using. If you shape the data you can retrieve using Exchange_logon with a full list of mailboxes on that server retrieved via ADSI then you can get a bit more of a clear picture as to who is logged on, who is not logged on, how many people are logged on to one particular mailbox, how they are logged on (OWA or Outlook) and what version of outlook they are using.

The script itself uses the same ADO data shaping techniques I described in this post. Some different bits and pieces that have been added to this script are

Front End
The Front end of the code accepts two command line variables the first is the severname of the Exchange server you want to run it against and the second is the type of logon you want to report on. With the second parameter there are 5 options which should be self explanatory

OWA -Show user logged on via Outlook Web Access”
Outlook -Show users logged on via Outlook”
Loggedon -Show All logged on Users”
Loggedout -Show Users not Logged On”
ALL -Show all users Logged in and Out”

Displaying the Outlook version

The Exchange_Logon class displays the version of Outlook that is being used by the client to connect to exchange. There is a complete list of which versions relates to which Outlook build on http://www.cdolive.com/build.htm . I’ve taken this list and dropped it into a Case statement in the script so I can display the friendly Outlook build name instead of the the build version number. If you are using a build number not on the list then the script should just output the version number

Displaying IP address and Cache/Online Mode if the client is using Outlook 2003

Outlook 2003 now allows you to track weather a user is in cache mode or online mode as well as the IP address of the client PC. The WMI class returns an integer indicating weather the client is using cache mode or online so I’ve added a simple function to convert this to a friendly name. The IP address is displayed if possible if not it just shows blank.

With the ADSI query it only shows the visible users in the GAL for that server and ignores any hidden mailboxes. If you wanted to include hidden mailboxes you’ll need to tweak the ADSI.

The WMI query will differ based on the command line parameters you enter in. The rest of the script is pretty straight forward. One thing to note is i haven’t tested this with OMA user logging on.(I think it will show them as OWA users)

To run the script use something like cscript displogon.vbs servername ALL

I’ve put a downloadable copy of the script here the code itself looks like

if WScript.Arguments.Count <> 2 then
call DisplayUsage
else
call Main()
end if

sub main()
servername = wscript.arguments(0)
showarg = lcase(wscript.arguments(1))
set conn = createobject(“ADODB.Connection”)
set com = createobject(“ADODB.Command”)
set conn1 = createobject(“ADODB.Connection”)
strConnString = “Data Provider=NONE; Provider=MSDataShape”
conn1.Open strConnString
Set iAdRootDSE = GetObject(“LDAP://RootDSE”)
strNameingContext = iAdRootDSE.Get(“configurationNamingContext”)
strDefaultNamingContext = iAdRootDSE.Get(“defaultNamingContext”)
set objParentRS = createobject(“adodb.recordset”)
set objChildRS = createobject(“adodb.recordset”)
strSQL = “SHAPE APPEND” & _
” NEW adVarChar(255) AS ADDisplayName, ” & _
” NEW adVarChar(255) AS ADLegacyDN, ” & _
” ((SHAPE APPEND ” & _
” NEW adVarChar(255) AS WMIDisplayName, ” & _
” NEW adVarChar(255) AS WMILegacyDN, ” & _
” NEW adVarChar(255) AS WMILoggedOnUserAccount, ” & _
” NEW adVarChar(255) AS WMIClientVersion, ” & _
” NEW adVarChar(255) AS WMIClientIP, ” & _
” NEW adVarChar(255) AS WMIClientMode ” & _
“)” & _
” RELATE ADLegacyDN TO WMILegacyDN) AS rsADWMI ”
objParentRS.LockType = 3
objParentRS.Open strSQL, conn1
Conn.Provider = “ADsDSOObject”
Conn.Open “ADs Provider”
svcQuery = “”<LDAP://” & strNameingContext & “”>;(&(objectCategory=msExchExchangeServer)(cn=” & Servername & “));cn,name,distinguishedName,legacyExchangeDN;subtree”
Com.ActiveConnection = Conn
Com.CommandText = svcQuery
Set Rs = Com.Execute
while not rs.eof
GALQueryFilter = “(&(&(&(& (mailnickname=*)(!msExchHideFromAddressLists=TRUE)(| (&(objectCategory=person)(objectClass=user)(msExchHomeServerName=” & rs.fields(“legacyExchangeDN”) & “)) )))))”
strQuery = ” com.Properties(“Page Size”) = 100
Com.CommandText = strQuery
Set Rs2 = Com.Execute
while not rs2.eof
objParentRS.addnew
objParentRS(“ADDisplayName”) = rs2.fields(“displayname”)
objParentRS(“ADLegacyDN”) = rs2.fields(“legacyExchangeDN”)
objParentRS.update
rs2.movenext
wend
wscript.echo “finished 1st AD of Mailbox’s”
rs.movenext
wend

strWinMgmts =”winmgmts:{impersonationLevel=impersonate}!//”& servername &”/root/MicrosoftExchangeV2″
Select case showarg
case “owa” sqlstate = “Select * FROM Exchange_Logon where StoreType = 1 and ClientVersion = ‘HTTP'”
case “outlook” sqlstate = “Select * FROM Exchange_Logon where StoreType = 1 and ClientVersion <> ‘SMTP’ AND ClientVersion <> ‘OLEDB’ AND ClientVersion <> ‘HTTP'”
case else sqlstate = “Select * FROM Exchange_Logon where StoreType = 1 and ClientVersion <> ‘SMTP’ AND ClientVersion <> ‘OLEDB'”
end select
Set objWMIExchange = GetObject(strWinMgmts)
Set listExchange_ExchangeLogons = objWMIExchange.ExecQuery(sqlstate,,48)
objChildRS.LockType = 3
Set objChildRS = objParentRS(“rsADWMI”).Value
For each objExchange_ExchangeLogon in listExchange_ExchangeLogons
if objExchange_ExchangeLogon.LoggedOnUserAccount <> “NT AUTHORITY\SYSTEM” then
objChildRS.addnew
objChildRS(“WMIDisplayName”) = objExchange_ExchangeLogon.MailboxDisplayName
objChildRS(“WMILegacyDN”) = objExchange_ExchangeLogon.MailboxLegacyDN
objChildRS(“WMILoggedOnUserAccount”) = objExchange_ExchangeLogon.LoggedOnUserAccount
objChildRS(“WMIClientVersion”) = objExchange_ExchangeLogon.ClientVersion
objChildRS(“WMIClientIP”) = objExchange_ExchangeLogon.ClientIP
objChildRS(“WMIClientMode”) = objExchange_ExchangeLogon.ClientMode
objChildRS.update
end if
Next
wscript.echo “finished Exchange WMI query”
Wscript.echo “Dislay Results ” & showarg
wscript.echo
objParentRS.MoveFirst
Do While Not objParentRS.EOF
Set objChildRS = objParentRS(“rsADWMI”).Value
objChildRS.sort = “WMILoggedOnUserAccount”
select case showarg
case “all” Wscript.echo objParentRS.fields(“ADDisplayName”)
if objChildRS.recordcount = 0 then Wscript.echo ” ” & “Not Logged On”
case “loggedon” if objChildRS.recordcount <> 0 then Wscript.echo objParentRS.fields(“ADDisplayName”)
case “owa” if objChildRS.recordcount <> 0 then Wscript.echo objParentRS.fields(“ADDisplayName”)
case “outlook” if objChildRS.recordcount <> 0 then Wscript.echo objParentRS.fields(“ADDisplayName”)
case “loggedout”if objChildRS.recordcount = 0 then Wscript.echo objParentRS.fields(“ADDisplayName”)
case else Wscript.echo objParentRS.fields(“ADDisplayName”)
end select
if showarg <> “loggedout” then
Do While Not objChildRS.EOF
currec = objChildRS.fields(“WMILoggedOnUserAccount”) & objChildRS.fields(“WMIClientVersion”) & objChildRS.fields(“WMIClientIP”) & objChildRS.fields(“WMIClientMode”)
if currec <> prevrec then
Wscript.echo ” ” & objChildRS.fields(“WMILoggedOnUserAccount”) & ” ” & getversion(objChildRS.fields(“WMIClientVersion”)) & ” ” & _
getmode(objChildRS.fields(“WMIClientMode”)) & ” ” & objChildRS(“WMIClientIP”)
end if
prevrec = currec
objChildRS.MoveNext
Loop
end if
objParentRS.MoveNext
Loop

end sub

function getversion(version)

Select case version
case “4.0.994.0” getversion = “Outlook 97 Initial release in Q1/1997.”
case “5.0.1457.0” getversion = “Outlook 97 Ships only with Microsoft Exchange 5.0 Service Pack 1”
case “5.0.1458.0” getversion = “Outlook 97 Ships only with Microsoft Office 97 SR-1”
case “5.0.1960.0” getversion = “Outlook 97 Ships only with Microsoft Exchange Server 5.5 and Microsoft Exchange 5.0 Service Pack 2”
case “5.0.2178.0” getversion = “Outlook 98 Initial release in Q1/1998.”
case “5.0.2819.0” getversion = “Outlook 2000 Initial release in Q2/1999”
case “5.0.3121.0” getversion = “Outlook 2000 update included with Office 2000 SR1 (and SR1a)”
case “5.0.3136.0” getversion = “Outlook 2000 security update patch”
case “5.0.3144.0” getversion = “Outlook 2000 with Service Pack 2 installed”
case “10.0.0.3311” getversion = “Outlook 2002 with hotifx”
case “8.00.3511” getversion = “Outlook 97 Initial release in Q1/1997.”
case “8.01.3817” getversion = “Outlook 97 Ships only with Microsoft Exchange 5.0 Service Pack 1”
case “8.02.4212” getversion = “Outlook 97 Ships only with Microsoft Office 97 SR-1”
case “8.03.4629” getversion = “Outlook 97 Ships only with Microsoft Exchange Server 5.5 and Microsoft Exchange 5.0 Service Pack 2”
case “8.04.5619” getversion = “Outlook 97 Ships only with Microsoft Office 97 SR-2”
case “8.5.5104.6” getversion = “Outlook 98 Initial release in Q1/1998. Is included with the Microsoft Exchange 5.5 Service Pack 1 CD-ROM (not available for download at the Microsoft site)”
case “8.5.5603.0” getversion = “Outlook 98 Microsoft Outlook 98 Security Patch 2 ”
case “8.5.7806” getversion = “Outlook 98 Outlook 98 security update”
case “9.0.0.2711” getversion = “Outlook 2000 Initial Release in Q2/1999”
case “9.0.0.3011” getversion = “Outlook 2000 Microsoft Office 2000 Developer Edition released in Q3/1999”
case “9.0.0.3821” getversion = “Outlook 2000 update included with Office 2000 SR1 (and SR1a)”
case “9.0.0.4201” getversion = “Outlook 2000 security update patch installed.”
case “9.0.0.4527” getversion = “Outlook 2000 with Service Pack 2 installed”
case “9.0.0.6673” getversion = “Outlook 2000 – SP3”
case “10.0.0.2625” getversion = “Outlook 2002 Initial release in Q1/2001.”
case “10.0.0.2627” getversion = “Outlook 2002 Initial release in Q1/2001.”
case “10.0.0.3513” getversion = “Outlook 2002 with Service Pack 1”
case “10.0.0.3501” getversion = “Outlook 2002 with Service Pack 1”
case “10.0.0.4115” getversion = “Outlook 2002 with Service Pack 2”
case “10.0.0.3416” getversion = “Outlook 2002 with Service Pack 1”
case “10.0.0.4219” getversion = “Outlook 2002 with Service Pack 2”
case “10.0.0.6515” getversion = “Outlook 2002 with Service Pack 3”
case “10.0.0.6626” getversion = “Outlook 2002 with Service Pack 3”
case “11.0.5604.0” getversion = “Outlook 2003 Initial release Oct. 2003 RTM Build”
case “11.0.5606.0” getversion = “Outlook 2003 Initial release Oct. 2003 RTM Build”
case “11.0.5608.0” getversion = “Outlook 2003 Initial release Oct. 2003 RTM Build”
case “11.0.5703.0” getversion = “Outlook 2003 with critical update releases on 11.4.2003”
case “11.0.6353.0” getversion = “Outlook 2003 SP1, released August 2003. ”
case “11.0.6352.0” getversion = “Outlook 2003 SP1, released August 2003. ”
case “HTTP” getversion = “Outlook Web Access”
case else getversion = version
end select

end function

function getmode(clientmode)
select case clientmode
case 1 getmode = “Classic Online”
case 2 getmode = “Cached Mode”
case else getmode = ” ”
end select
end function

public sub DisplayUsage
WScript.echo “usage: cscript displogon.vbs ”
WScript.echo “Vaid Modes”
WScript.echo ” OWA – Show user logged on via Outlook Web Access”
WScript.echo ” Outlook -Show users logged on via Outlook”
WScript.echo ” Loggedon -Show All logged on Users”
WScript.echo ” Loggedout -Show Users not Logged On”
WScript.echo ” ALL -Show all users Logged in and Out”
end sub

“You don’t have permission to do that.”

 “You don’t have permission to do that.” – M-am confruntat de o o gramada de ori in ultima vreme cu mesajul asta – si pe wp 2.0 si pe 2.1 si pe 2.2.

Un pic de google si solutia vine in felul urmator: cautati fisierul de mai jos, si la linia 295 o sa aveti ceva de genul:

wp-includes/pluggable.php

$cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie']));
// AJAX scripts must pass cookie=document.cookie
foreach ( $cookie as $tasty ) {
if ( false !== strpos($tasty, USER_COOKIE) )
$user = urldecode(substr(strstr($tasty, '='), 1)); // Nasty double encoding
if ( false !== strpos($tasty, PASS_COOKIE) )
$pass = urldecode(substr(strstr($tasty, '='), 1));
}

Comentati toata sectiunea, // in fata fiecarui rand. Inlocuiti cu:

$user = $_COOKIE[USER_COOKIE];
$pass = $_COOKIE[PASS_COOKIE];

Stiu ca nu e cpanel tutorial, dar presimt ca nu o sa stau eu de cautat bugs in wordpress, so enjoy.