PHP is an open source server-side scripting language widely used in web development. It adds functionality to your website, like performing calculations, reading and writing files, dealing with database, collecting user information etc.
Unfortunately, the PHP script may go wrong at times, influencing the work of your Magento commerce shop. Here are the PHP essentials concerning specific options and directives for ensuring best functionality to your website:
It is better to use the latest PHP version for your Magento store to work well. Outdated PHP version will hinder the store functionality or can stop it altogether.
You might have faced an error like this:
Fatal error: Allowed memory size of 33554432 bytes exhausted.
It means, that no more files or requests can be executed. There is nothing you can do about it except for setting the higher memory limit.
According to Magento system requirements, it should be at the very least 256Mb, but 512Mb is more preferable, as this platform is rather resource consuming.
Depending to the server’s security policy this value can be changed in different ways:
- ask your host to increase the global memory_limit in the server’s php.ini configuration file.
- edit .htaccess file:
php_value memory_limit 256M
- edit index.php:
add ini_set ('memory_limit', '256M');
Setting very high memory limit, on the other hand, is dangerous: if a PHP code starts consuming a lot of memory, you can get a resource shortage.
Enabling this option can pose a security threat. In a nutshell, it disables injecting the script with variables (Environment, GET, POST, Cookie, Server) that come from different sources.
You can turn off register_globals in your .htaccess file by adding this line:
php_flag register_globals off
Note. This feature has been deprecated in PHP5.3.0 and removed in PHP 5.4.0.
This directive tells what is the maximum size of an uploaded file. If the limit is too low, you won’t be able to upload a bigger file to your server.
To avoid a situation like this, set the preferred value in your.htaccess, setting the numeric value according to your needs:
php_value upload_max_filesize 40M
In PHP, safe mode is a security precaution to prevent hackers from executing commands at the level of your operating system. However, when safe_mode is on, some basic functions required by web scripts would not work properly. Ultimately, for VPS or dedicated hostings, you can keep safe_mode off.
As to shared hostings, you should weigh all pros and cons and decide whether you need advanced security or could go without. Anyway, if you opt for safe mode, remember to disable it when the system is not functioning properly and see how it works out.
To disable/enable PHP safe mode on a server, edit the php.ini file and modify the following line:
safe_mode = Off to safe_mode = On
For more convenience, use Shopping Cart Diagnostics to test your Magento PHP configuration and server environment plus get the optimal solutions to ensure top performance to your store.
This automated service can execute Magento overall error check and detect any flaws in the website work.
Register an account to avoid functionality breaches and make your business thrive!
For more info, check out http://www.shopping-cart-diagnostics.com/supported-carts/magento/.