Switching to php 5.4 causing my site to crash

With versions 5.4 and onward, certain php.ini directives can cause your site to no longer load.

Make sure all references to the following are removed from your php.ini:

allow_call_time_pass_reference
magic_quotes_gpc

You can place a semi-colon in front of those lines to preserve the old values in case you need them for future reference.

;allow_call_time_pass_reference
;magic_quotes_gpc

Enabling apc (php alternative cache) on your Centos VPS

Here is how to enabled php’s apc on a CentOS VPS:

1. yum -y install php-pear pcre-devel php-pear php-devel httpd-devel gcc
2. pecl install apc (press enter to accept the default response for each option)
3. echo “extension=apc.so” > /etc/php.d/apc.ini
4. service httpd restart
5. cp /usr/share/pear/apc.php /home/YOUR_USER_NAME/www/some_private_file_name.php

The apc.php page can be loaded to view the cache status. We recommend you rename it to something other than apc.php

Setting up yum for end-of-life CentOS 4 VPS

CentOS 4 is no longer supported by the developers and we do not recommend you install it. If you have a special case which requires CentOS 4, you will find that yum will not update or perform installs because the repository URL’s are no longer valid.

To make yum work with vault.centos.org, edit your :

/etc/yum.repos.d/CentOS-Base.repo

to have these lines:


[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://vault.centos.org/4.9/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=1
protect=1

#released updates
[update]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://vault.centos.org/4.9/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=1
protect=1

yum update, yum install, etc. will now work.

I’ve lost my email password. How can I reset it?

[ Note : These are the complete step-by-step instructions. In many cases, your email password is the same as your control panel password. You may wish to try that password first.]

Here is the best method to reset an email password.

1. Login to your hosting control panel at:

https://phpwebhosting.com/login/

2. If you know your “postmaster” (master) password, skip to step 3. If you do not know your “postmaster” (master) password, click on :

“Password: change”

in the side left section of your control panel.

Here you can change your password. The new password will affect your hosting control panel, ftp and master email password.

3. After you have your master email password, click the “email” link near the top of the control panel.

4. Click “Configure your email accounts”

5. Login here with :

POP Account: postmaster
password: your postmaster password set in step #2
domain: your-domain.com

6. Click :

Edit existing address:

7. Click the red circle under “Modify User” for the user you wish to change the password for.

Send mail using Pear:Mail

How can I send mail from php using a specific smtp host, for example, smtp1.phpwebhosting.com or my private smtp server?

Use the pear mail package.

include(‘Mail.php’);

$from = ““;
$to = ““;
$subject = “Test”;
$body = “Test”;

$host = “smtp1.phpwebhosting.com”; // enter the smtp server you wish to use here
$port = “25”; // smtp port
$username = “your_smtp_user@domain.com”; // your smtp-auth username
$password = “your_password”; // your smtp-auth password

$headers = array (‘From’ => $from,
‘To’ => $to,
‘Subject’ => $subject);
$smtp = Mail::factory(‘smtp’,
array (‘host’ => $host,
‘port’ => $port,
‘auth’ => true,
‘username’ => $username,
‘password’ => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo(“

” . $mail->getMessage() . “

“);
} else {
echo(“

Message successfully sent!

“);
}

ssh will not connect – Connection closed by remote host

Question:

When I try to connect with ssh I get an error such as “ssh_exchange_identification: Connection closed by remote host”. I know that ssh is enabled on my account. What is wrong?

Answer:

Usually these errors are caused when an attacker is scanning for badly configured servers with default usernames and passwords or easy to guess passwords. Our scripts detect and block such scans/attacks but there can be times during the attack when all connections are taken and the server refuses new connections. Your server is safe and such attacks/scans are part of the day-to-day life of servers on the internet. Usually you never notice the effects but in rare cases there can be disruptions.

A temporary work-around is to connect to ssh on port 23. Many of our servers run ssh on port 23 as well as port 22. You can try to connect to port 23 with:

ssh your_username@your_server.com -p 23

or change the port from 22 to 23 in your client.

Hide eregi() deprecated errors

Question:

My script gives errors like:

Deprecated: Function eregi() is deprecated in /home/my_username/www/path/contact/include/fgcontactform.php on line 548

Why is this occuring? How can I fix it?

Answer:

Newer php versions are removing support for the eregi() function. Your script will continue to work but using normal php.ini settings the deprecated errors are shown. You can hide the errors by adding:


error_reporting = E_ALL & ~E_DEPRECATED

to your /home/username/etc/php.ini file

Create the file if it does not exist. If you already have a error_reporting line, modify it hide E_DEPRECATED

If you are on a VPS, edit /etc/php.ini and restart httpd if you are running mod_php.

You should also work to update your script to no longer call the deprecated functions as future versions of php will remove support for the functions completely.

How to disable mod_security on shared hosting via .htaccess

Question: I’m installing a new php cart and get the error :

Your webserver has the mod_security module enabled. As a result, you may see the “403 Forbidden” or “Not Acceptable” error messages after submitting forms that contain “curl”, “perl”, “set”, etc. It is recommended to disable this module or reconfigure it so that these words are not forbidden.*

How can I disable mod_security?

Answer:

To disable mod_security, add the following to a .htaccess file in the base directory for the script you are trying to install.


SecFilterEngine Off
SecFilterScanPOST Off