Thursday, 28 August 2008

How to Fix PHPMyAdmin 403 Forbidden Error

If you have installed phpMyAdmin in your linux server (centos/RHEL/debian), and tried to access phpMyAdmin in most cases you will get this 403 forbidden error. I have seen this issue very often if you are installing phpmyadmin using yum or by apt-get. By default phpmyadmin installed path is /usr/share/phpmyadmin and the apache configuration file is located in /etc/httpd/conf.d/phpmyadmin.conf

Wednesday, 13 August 2008

Spamd child process causing high server load

Sometimes, spamd child process for a particular user can cause high server load. This is a bug with spamassassin :

To fix the issue, apply the patch mentioned in the bug.

For  servers, run the following scripts:

/scripts/autorepair spamd_dbm_fix
/etc/init.d/ restart

Sunday, 10 August 2008

Wordpress admin login issue -due to siteurl

During the wordpress installation, customers set the Site URL as http://www.domainName/wordpress. But in the configuration file (or wordpress folder) it will be "WordPress". Due to this customer can't login wordpress admin using http://www.domaName/WordPress/wp-login.php.

Fix: In that case you need to modify the wordpress database table entry.

Use the word press database and the following update:
select * from wp_options where option_name="siteurl"G;
update wp_options set option_value="http://www.domainName/WordPress" where option_name="siteurl";


Note: Replace the domainName by corresponding domain name. The wordpress prefix wp_ will change a
ccording to the situation.

Perl mail script

#!/usr/bin/perl

# This is a simple script to test sendmail.
# Replace "me" with a from address and "mydom.com" with the #sending domain.
# Replace "you" with a username to send to and "yourdom.com" #with the recipient's domain name.
# Upload this to the public_html folder as mailtest.pl and CHMOD it to 755
print "Content-type: text/plainnn";
unless(open (MAIL, "|/usr/sbin/sendmail -t")) {
print "error.n";
warn "Error starting sendmail: $!";
}
else{
print MAIL "From: me@mydom.comn";
print MAIL "To: you@yourdom.comn";
print MAIL "Subject: test subjectnn";
print MAIL "Perl Sendmail is working, please check your code.";
close(MAIL) || warn "Error closing mail: $!";
print "Mail sent.n";

}

Monday, 14 July 2008

Awstats full year view error

Error will be look like in following way: Full year view has not been allowed from a browser Setu
p ('/home/domain/etc/awstats/awstats.domain.com.conf' file, web server or permissions) may be wron
g. Check config file, permissions and AWStats documentation (in 'docs' directory).
1. Edit "AllowFullYearView" option in the /home/domain/etc/awstats/awstats.domain.com.conf
2. To view the full year, the option should be "AllowFullYearView=3".

Saturday, 12 July 2008

Space full on device

Whenever you start Apache, it keeps crashing with error “semget: No space left on device”.

# tail /etc/httpd/logs/error_log
semget: No space left on device
semget: No space left on device
[Wed Sep 12 10:54:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
– Unclean shutdown of previous Apache run? semget: No space left on device
[Wed Sep 12 10:56:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
– Unclean shutdown of previous Apache run? semget: No space left on device
[Wed Sep 12 10:58:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
– Unclean shutdown of previous Apache run? semget: No space left on device
[Wed Sep 12 11:00:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
– Unclean shutdown of previous Apache run? semget: No space left on device

If you have similar problem as mine above + if your disk space is nowhere near/above 100% + /var/messages and /usr/local/apache/logs/error_log shows no clue about this problem + any files in /etc/httpd/logs/ and /etc/httpd/domlogs nowhere near/above 2GB in size, its most probably semaphore problem. Use the following script to cure your Apache.

#!/bin/bash

ipcs -s | grep nobody | perl -e ‘while () {
@a=split(/s+/); print `ipcrm sem $a[1]`}’

/scripts/restartsrv httpd

Script how to:
- SSH as root to your CPanel server
- Go to root dir

# cd /root

- Create a httpdsemclean.sh blank file

# pico httpdsemclean.sh

- Write above script
- Save

Ctrl + O

- Exit pico

Ctrl + X

- Chmod httpdsemclean.sh to 777

# chmod 777 httpdsemclean.sh

- Execute the script

./httpdsemclean.sh

If all goes fine, you’ll see something like this:


resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
Waiting for httpd to restart…………..finished.

httpd started ok

Do this at your own risk, we do not guarantee this will work on all CPanel servers

Thursday, 10 July 2008

How to find the PostgreSQL database size




PostgreSQL is a powerful, open source relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.
If you want to find the size of a database, in our example the sqview database, please tape:

sqview-# SELECT pg_database_size(’sqview’);
pg_database_size
——————
111415944
(1 ligne)

The result in octal, for a pretty print we will use the pg_size_pretty function which converts the size in bytes to human understandable format.
sqview-# SELECT pg_size_pretty(pg_database_size(’sqview’));
pg_size_pretty
—————-
106 MB
(1 ligne)

Well if we need to get the size of all databases
sqview-# SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database;
datname | size
———–+———
postgres | 3537 kB
template1 | 3537 kB
template0 | 3480 kB
freedom | 25 MB
anakeen | 6081 kB
sqview | 106 MB
rt | 8201 kB
(7 lignes)

PostgreSQL can also give the size of a table ‘users’ like this

sqview-# SELECT pg_size_pretty(pg_relation_size(‘users’));
pg_size_pretty
—————-
64 kB
(1 ligne)

This value exclude indexes and some auxiliary data.
If you want to include them use pg_total_relation_size instead of pg_relation_size as shown below.
sqview-# SELECT pg_size_pretty(pg_total_relation_size(‘users’));
pg_size_pretty
—————-
152 kB
(1 ligne)

to find the largest table in the postgreSQL database.
sqview-# SELECT relname, relpages FROM pg_class ORDER BY relpages DESC limit 1;
relname | relpages
———+———-
sqview | 9666
(1 ligne)