Howto: repair a mysql table

October 4, 2009    |   Posted by admin   |    Category: Mysql & PostGres SQL

If you receive the following error message on your website, which means the table is crashed.

“Table “tablename” is marked as crashed and should be repaired”

The Mysql table consists of 3 files, .MYI, .MYD and .frm. The .MYI file contains the structure and results in the error message if something goes wrong with it. There are 3 ways to repair the table:

1)  Login to your cPanel, goto “Mysql Databases” option and click “Repair DB” in front of the databases.

2) Login to your server, goto mysql directory /var/lib/mysql and execute the command:              myisamchk -r dbname/tablename.MYI

3) Login to your server, goto Mysql prompt and execute the Mysql query:                                                         repair table tablename;

Anyone of the above 3 steps will repair the table and site will be back online.

Comments Off on Howto: repair a mysql table

PHP pages asking for download

October 4, 2009    |   Posted by admin   |    Category: Linux Administration

If your .php files are prompting for download on browsing, make sure PHP is compiled with Apache and you have following lines in your Apache configuration file

AddHandler application/x-httpd-php .php .html

You can also add the above line in your .htaccess file of the domain.

Comments Off on PHP pages asking for download

Howto: install CSF on your server.

October 3, 2009    |   Posted by admin   |    Category: cPanel Management

Howto install CSF on your server:

1) cd /usr/local/src/
2) download csf: wget http://www.configserver.com/free/csf.tgz
3) tar -xzf csf.tgz
4) goto the csf directory : cd csf
5) ./install.sh

Once it is installed, you can either edit the configuration file from WHM >> Plugins >> “Config Server Security and Firewall” option.

If you don’t have WHM/cPanel on your server, the configuration and all the CSF related files are stored under /etc/csf directory. You need to edit the csf configuration file /etc/csf/csf.conf and make the changes as per your wish.

Once you make the required changes to your CSF configuration file and are sure, you are not going to block yourself out, change the following from

TESTING = “1”
to
TESTING = “0”

and restart the csf firewall using service csf restart command.

Comments Off on Howto: install CSF on your server.

Howto: Open port using IPtables

October 3, 2009    |   Posted by admin   |    Category: Linux Administration

Howto open ports using iptables, see the following examples:

Open port 25 (SMTP) for the SOURCE_IP address:

iptables -A INPUT -p tcp -s SOURCE_IP  –dport 25  -j ACCEPT

Open port 22 (SSH) for the SOURCE_IP address to a specific DESTINATION_IP address

iptables -A INPUT -p tcp -s SOURCE_IP –dport 22 -d DESTINATION_IP -j ACCEPT

More to come…

Comments Off on Howto: Open port using IPtables

Howto: change collation for mysql

October 3, 2009    |   Posted by admin   |    Category: Mysql & PostGres SQL

People may think of changing “collation” for their Mysql databases and here how to change it. First, there are two ways to check the current collation on your server. One from the command line and one from the mysql prompt:

root@server [~]# mysqladmin variables | grep collation
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |

OR

mysql> SHOW VARIABLES LIKE ‘collation%’;
+———————-+—————–+
| Variable_name | Value |
+———————-+—————–+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+———————-+—————–+
3 rows in set (0.00 sec)

As you can see the current collation is set to “utf8_general_ci”.

In order to change it to something for example “latin1_general_ci”, edit your /etc/my.cnf file and place the following code:

collation-server=latin1_general_ci

Save the file and restart mysql service.

Comments Off on Howto: change collation for mysql