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

Howto: Check Apache Connections

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

How to check number of connections to the Apache server?

netstat command will show you the accurate connections to each of your service. In order to check the number of connections to port 80, use the netstat command and grep the Apache port.

List the connections to port 80:

netstat -alntp | grep :80

To check the number of connections to port 80:

netstat -alntp | grep :80 | wc -l

List the remote IPs connecting to your server on port 80:

netstat -alntp | grep :80 | awk ‘{print $5}’ | cut -d: -f1 | sort

List the uniq remote IPs and the number of connections from each IP:

netstat -alntp | grep :80 | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n

Please note: If you copy paste the above commands on your server, the single quote around the {} brackets may change to dots (.) and the command will fail, so make sure you replace those dots with the singe quote and execute the command.

vzquota : (error) Quota is running, stop it first

October 1, 2009    |   Posted by admin   |    Category: VPS Management

If you receive the error message “vzquota : (error) Quota is running, stop it first” while restarting a VPS, you will first have to turn off it’s quota and then drop it

vzquota off  VEID
vzquota drop VEID

Once done, restart the VPS and it will re-initialize the quota for the VPS and will start the VPS. If the problem persist, remove the /var/vzquota/quota.veid file

rm -f /var/vzquota/quota.veid

and then start the VPS. This should also display the correct disk space used by the VPS.

Comments Off on vzquota : (error) Quota is running, stop it first

CSF dropping the packets while dowloading

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

You may have notice packet drops when CSF firewall is enabled and you are downloading something. The only reason is the option

PACKET_FILTER = “1”

By default the “PACKET_FILTER” is ON which drops packets that looks illegal or out of sequence. If it’s generating false alarms and causing the valid packet to drop, you should better turn OFF the option in /etc/csf/csf.conf file

PACKET_FILTER = “0”

Save the file and restart CSF firewall.

Comments Off on CSF dropping the packets while dowloading

Got a packet bigger than ‘max_allowed_packet’ bytes

October 1, 2009    |   Posted by admin   |    Category: cPanel Management, Linux Administration, Plesk Management

“Got a packet bigger than ‘max_allowed_packet’ bytes”

The message is displayed when you try to restore a database and the packet size if more than the default one OR the one defined in the my.cnf file.You can check the existing bytes with the following command

root@server [~]# mysqladmin variables | grep max_allowed_packet
| max_allowed_packet              | 1048576
|

To overcome the issue, add the following parameter in the my.cnf file

max_allowed_packet = 2097152

The value should be more than the default one. Save the file and restart the mysql service.

Comments Off on Got a packet bigger than ‘max_allowed_packet’ bytes