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

PHP script to send emails

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

Use the following PHP code to send emails from your server:

$mail_to=”destination@address.com”;
$mail_subject=”Hello”;
$mail_from=”yourname@yourdomain.com”;
$mail_body_client=”Hello”;
mail($mail_to,$mail_subject,$mail_body_client,”FROM:”. $mail_from);

where,

$mail_to is the receipent.
$mail_from is the sender.

Comments Off on PHP script to send emails