Fixing Silverlight install error : date.timezone set and valid

Silverlight date.timezone Error screenshot

Question:

I get the an error when installing Silverlight regarding date.timezone. How can I fix this?

Answer:

With newer versions of php (PHP 5.3.0 and above), the date.timezone must be explicitly set. You can fix this by going into your etc/php.ini directory (create if does not exist) and add the line for date.timezone. An example is:

date.timezone = 'America/New_York'

Be certain to only use timezone’s listed at:

http://www.php.net/manual/en/timezones.php

Timezones like ‘US/Eastern’ no longer work.

It can be very frustrating because php will not complain if you use ‘US/Eastern’ and phpinfo() will show the value as set but Silverlight will not work with those settings. ‘US/Eastern’ and others are only included in php for backwards compatibility.

browser tries to download php

Browser tries to download php pages screenshot

Question:

Sometimes my browser tries to download or save php files from my website. What causes this? How can it fix it?

Answer:

This can happen for a variety of reasons. However we frequently see it when a page is timing out. If you are connecting to a remote database make sure that the database is up and that dns is resolving correctly for it.

Which php global contains the user IP Address?

Question:

Which php global contains the IP address of the user/client calling the script?

Answer:

$_SERVER['REMOTE_ADDR'];

Note that this does not take into account any proxy which might be in use. There are numerous issues to take into account if you wan to to be absolutely sure of the remote IP. This example is for the simplest cases.

$user_ip = $_SERVER['REMOTE_ADDR'];

echo "

your IP is $user_ipn";

IMAP php extension versus IMAP email

Question:

I’m confused about the difference between the php IMAP extension and and IMAP server.

Answer:

The php version on your server has the php extension for accessing IMAP mail servers. However, this extension only allows php to connect to an IMAP server. It does not actually provide an IMAP server. By default most accounts are not configured for IMAP mail service. We can upgrade you to a mail server that does (no extra charge) – contact support to have the IMAP mail server upgrade performed.

If you simply want to connect to other IMAP mail servers, you do not need to do anything. If you want to connect to your own mail via imap/webmail you’ll need to upgrade to an IMAP mail server with us. As a side-note, part of the IMAP conversion process also gives you access to a pre-installed version of roundcube (you are still welcome to do your own roundcube install if you prefer).

How to fix “Missing Dependency: php-api” when installing mcrypt module

Question:

I get the error “Missing Dependency: php-api” when trying to use yum to install php’s mcrypt module. How do I fix this?

Answer:

You likely installed/upgraded php using non-centos sources (usually the remi rpms). Try this:


yum -y --enablerepo=remi install php-mcrypt

(notice the added –enablerepo=remi)

What is happening in this case is that your php rpm is from remi but when you install php-mcrypt it is trying to use the default centos repositories. You need to tell it to also get php-mcrypt from the remi repository.

Upgrade php on centos (VPS)

Question: How do I upgrade php to the latest version on my VPS running centos?

Answer:

From the shell, run:

wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
wget ftp://ftp.muug.mb.ca/mirror/fedora/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh epel-release-5-4.noarch.rpm remi-release-5.rpm
yum -y --enablerepo=remi update php mysql
/sbin/service httpd restart

You also may want to edit /etc/php.ini and change :

short_open_tag = Off

to

short_open_tag = On

without this change php code will only work when using the full:

 

<?php

 

open tag.

 

Increase php timeouts with .htaccess

If you are running mod_php you may experience problems with big uploads and imports (or other long running processes).

You can adjust php’s default timeouts using a .htaccess file.

Create a file called .htaccess and put the code:

# increase php time-out limits
php_value max_execution_time 1000
php_value max_input_time 1000

inside it. Put the .htaccess file into the top-most directory of your site. If you already have a .htaccess
file, add the code above to the end of it.

This should solve you problem in most cases.

If it does not, try to increase the times (1000). If the problem persists, open a support ticket and include the URL, click path and any needed usernames and passwords. We will duplicate the problem and attempt to adjust your php execution times to make your script work.

Note: if you are running php as a cgi, you’ll need to adjust your /etc/php.ini file. Adding directives to .htaccess files has no effect on installs using php-cgi.

Running a different php version for only part of my website

Update: for newer accounts use :

php-script

instead of

custom-php

You can also set the php version on a per-directory basis (for testing, development, etc.). To run a different php version on part of your site, perform the following.

Create a .htaccess file :

.htaccess

(the leading dot is required)

inside the top level directory for which you want to change the php version.

Inside the file put the lines:

AddHandler custom-php .php .pcgi .phtml .inc .phtml~ .php~ .inc~ .html~
Action custom-php /cgi-sys/php5.6

some users may need the following instead:

Action php-script /cgi-sys/php7
AddHandler php-script .php .maml .html .css .mss .pcgi .phtml .inc .phtml~ .php~ .inc~ .html~

Replace php5.6 with which ever version you want to run
You can also add other file extensions to the list in the first line.

Depending upon the server and current php verison, you can choose from among:

/cgi-sys/php8.1
/cgi-sys/php7
/cgi-sys/php7.4
/cgi-sys/php5.6

etc.

In general, many php<major-version>.<minor-version> will work. The possible versions may vary. Contact support if a version you need is missing.

Historical Notes:

The following no longer is allowed. This is kept for historical reference:

To run a part of your site as mod_php, add this line to a .htaccess in the directory you want to run as mod_php :


AddHandler application/x-httpd-php .php3 .phtml .php .php4 .php~ .php3~ .php4~ .phtml~ .inc .inc~

.htaccess versus php.ini for php options

Question:

What is the difference between php.ini and .htaccess for php options? When should I use php.ini and when should I use .htaccess?

Answer:

You should use .htaccess only when you are running php via mod_php. This is a setting in your control panel “php” section.

php options inside .htaccess files have no effect when running as a cgi.

You can change your php versions from cgi to mod_php inside your control panel in the php section.

When php is run as mod_php, php is built into the webserver and the webserver can understand the php directives inside .htaccess

When php is running as a cgi, the webserver does not understand the php directives inside a .htaccess file. Instead you must create the directy “etc” and put a php.ini file inside it. When your php parser starts it will read these the directives inside php.ini and process them.