Archive for the ‘Cpanel’ Category

How to Re-install Mysql on Freebsd

Monday, November 30th, 2009

freebsd

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

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

And from the mysql error logs you are getting

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

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

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

# cd /usr/ports/databases/

# pkg_info | grep -i mysql

It should display information on mysql packages , something like

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

mysql-client-5.0.87 Multithreaded SQL database (client)

mysql-server-5.0.87 Multithreaded SQL database (server)

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

make clean

make

make deinstall

make reinstall

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

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

Check if mysql is running

# ps wwaux | grep mysql

Make sure that you have given the symlink

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

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


Phpmyadmin shows ” No Database “

Monday, November 30th, 2009

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

phpmyadmin1

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

From the server my.cnf remove the line

skip-show-database

Restart Mysql

Try to access Phpmyadmin .

About skip-show-database from Mysql Reference Manual .

–skip-show-database

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

How to Add Exim Interface IP

Tuesday, October 20th, 2009

Consider your mail server IP got blacklisted by any of the RBLs . In such situations a quick solution is to route the emails through a secondary IP address on the same server which is not black listed . While you may have given the IP unblock request , but the advantage here is we needn’t want to wait till they remove the IP .

Follow the steps:-

1) ssh to your server

2) Make a copy of current configuration .

# cp /etc/exim.conf /etc/exim.conf.backup

3)  Stop exim

# /etc/init.d/exim stop

4)  Edit your exim configuration file.

# vi /etc/exim.conf

Find remote_smtp under Transports section . It would look like :

e1

Now remove the lines interface and helo_date and add the new interface .

It should look like :

e2

5) Save your changes and exit .

6) Set an attribute to exim configuration file so that it wont get reset to default during cpanel updates ( If you are changing the IP through Exim configuration editor under whm , it won’t get reset after a cpanel update) .

# chattr +aui /etc/exim.conf

7) Restart exim

#service exim restart

or

# /etc/init.d/exim restart

How to change via Exim configuration editor under WHM.

a) Follow step 1, 2 and 3 above .

b) Login to WHM

c) Navigate to Server Configuration >> Exim Configuration >> Advanced editor

e3

d) Go to Transports section

e4

Now you can make the changes as described in step 4 .

e) Save .

Note that while selecting the IP , you should make sure that it is not black listed anywhere . It would be better not to choose an IP on the same network and choose the one which is free . You can check if

there is any free IPs from WHM >> IP Functions >> Show IP address Usage .

The first priority should be determining why you were listed on these blacklists . If your server is sending spam unbeknownst to you, changing the IPs will merely result in getting a new set of IPs blacklisted, which ultimately doesn’t resolve your problem .

SuPHP Permission Issue

Tuesday, October 20th, 2009

suPHP enhances overall server security. When migrating from a server that is not running suphp to a server running these, permission and ownership issues occur . When you access your domain you usually see

s1

Tail the Apache error logs to see what the error is

# tail -f /usr/local/apache/logs/error_logs

You can see the error

[Thu Jul 12 09:00:09 2007] [error] [client XXX.XXX.X.X] SoftException in Application.cpp:601: Directory “/home/user/public_html/test.php” is writable by group .

[Thu Jul 12 09:00:11 2007] [error] [client XXX.XXX.X.X] Premature end of script headers:

The script fail if the php file or folder is writable for anyone other that the owner. Check the permission and ownership .

# cd /home/user/public_html/

# ll | grep test.php

-rwxrwxrwx 1 nobody nobody 158 2008-05-13 04:32 test.php

That shows test.php has full permission and is not owned by the user . Change the permission and ownership.

# chmod 644 test.php

# chown user.user test.php

If it is a server wide issue , then its difficult to change it for each user . Here is a script (for cpanel servers) that fixes all the files and folder permissions that occurs when server changes to suphp.

1) Save the script to a file .

# vi /root/suphpfix.sh

     #!/bin/bash
     for user in `ls /var/cpanel/users`; do
     chown ${user}:${user} /home/${user}/public_html
     chmod 755 /home/${user}/public_html
     find /home/${user}/public_html -group nobody -print0 | xargs -0 chgrp ${user}
     find /home/${user}/public_html -type f -print0 | xargs -0 chmod 644
     find /home/${user}/public_html -type d -print0 | xargs -0 chmod 755
     done

2) Make the script executable.

# chmod u+x /root/suphpfix.sh

3) Execute the script

# bash /root/suphpfix.sh

Done!!