Nopeampi PHP + opCache

Since some customers have found that our servers have been slower in some cases compared to some other providers and according to customer’s feedback and wishes, we took the decision to change the mod_php to php-fcgi (PHPFastCGI). We have also implemented Zend’i opcode cache module.

1. Mikä on muuttunut?
2. Possible problems and solutions:
– Disabloi/Enabloi ZEND opCache
– AddType application/x-httpd-phpXX .extension (html|htm|js|…)
– No input file detected / PATH_INFO
– website Error 500 / .htaccess problem
3. For more information about FastCGI and opCache

1. Mikä on muuttunut?

PHP 5.3 and PHP 5.5 have now by FastCGI and Opcache module.
NB! As Opcache is operational by default, website code is added to the cache memory, speeding up the loading of pages wirh FastCGI. As opCache is active by default, the Web page code changes will appear in browser with delay (currently up to 5 minutes). (Down below is described solutions to temporarily deactivate or remove opCache)

PHP 5.3 ja PHP 5.5 sisältävät nyt FastCGI ja Opcache moduulin.
HUOM! Koska Opcache toimii oletuksena, sivuston koodi lisätään välimuistiin, se nopeuttaa sivujen latausta. Koska opCache on oletuksena käytössä, sivun koodin muutokset näkyvät selaimessa viiveellä (nykyisin jopa 5 minuuttia). (Alhaalla kuvataan ratkaisuja, miten väliaikaisesti disabloida opCache)

Enää ei ole enää mahdollista käyttää suoraan $ _SERVER [’PATH_INFO ”] (koodia käyttäessä seuraa virheilmoitus – mahdollinen ratkaisu on esitetty alla) ja  mukautetuja tiedoston laajennuksia ei voida lisätä suoraan .htaccess tiedostoon” AddType application / x-httpd-php mitä fileextension ”(ratkaisu alapuolella).

2. Mahdolliset ongelmat ja ratkaisut

– Disabloi/Enabloi/invalidate ZEND opCache
Since a lot of developers use our services, you can set the refresh opCache 0, where after each change of page, code is checked and if necessary refreshed in cahce. This can be done by adding following command to .htaccess:

php_value opcache.revalidate_freq 0

(Automatic update is at the moment by default 300 seconds!)

opCache can be denied by following command in .htaccess:

php_flag opcache.enable 0

In PHP script can deny or empty:

//To reset/update cache:

//To remove certain file under opcache (will not be cached)

– AddType application/x-httpd-phpXX .whateverfilextension (html|htm|js|…)
”AddType application / x-httpd-phpXX .whateverfilextension” can no longer to change via the .htaccess. However, this can be done directly on the server by Radicenter Support! If it happens that you have to used your own custom file extension .XXX and you have a website that does not work, please send a message to Radicenter customer support, which includes:

-Which domain does not work
-Which user account (rXXXXXXX/npXXXXXX)
-PHP version should be used (5.3/5.5/X.X)
-Which file extension (html/htm/ssd/dev/…)

We can make changes as requested.

Alternatively, you can also try one of our client’s proposed solution:

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)\.css$ $1.php [NC,L]

#If you want to change in the sub-domains to take effect, then add in there as well:
RewriteOptions InheritDown

It would also be possible to use several different files in that case:

<Files ~ "\.(xxx|yyy|nnn)$">
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ $1.php [NC,L]

– No input file detected / PATH_INFO
We have found 2 possible problems:

1. .htaccess has out-dated code for mod_rewrite:
RewriteRule ^(.*)$ index.php/$1 [L]
Remove from code  ”/$1” – and site will work again:
RewriteRule ^(.*)$ index.php [L]
(Or replace in the code ”/$1”:
RewriteRule ^(.*)$ index.php?$1 [L])
(As a rule, there is no need to send the variables to the newer scripts, they are able to identify it)

2. PHP content management uses obsolete functionality that uses / requires exclusive $ _SERVER [’PATH_INFO’] variable.
The solution would be to add to your index.php or config.php file (the file that is included to all scripts) following code:

//Radicenter fix for FCGI servers.
if(!isset($_SERVER['PATH_INFO']) && isset($_SERVER["QUERY_STRING"]))

//NB! $_SERVER["QUERY_STRING"] asemel võib osadel juhtudel kasutada ka $_SERVER["REQUEST_URI"]

-website ERROR 500 / .htaccess problem
We have also seen a couple of the websites, where has been outdated .htaccess code, where mod_php did not give an error message but with FastCGI opCachega error appeared.If previous fixes  have not been useful, please check your domain error log – it can be found in DirectAdminni -> ”Site Summary / Statistics / Logs” -> click ”Web Error Log” line of the ”Full Error Log” or ”100 lines” link.You can then see more accurate error message, which causes the non-display of the page. According to this, you can either comment out the line yourself, or if that does not work, send a message to Radicenter helpdesk.

3. For more information about FastCGI and opCache

More information about FastCGI:
More information about Zend opCache:

Comments are currently closed.