Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

I see this character in Firebug "."

The character in question "&#65279" is the Unicode Character 'ZERO WIDTH NO-BREAK SPACE' (U+FEFF). It may be that you copied it into your code via a copy/paste without realizing it. The fact that it's not visible makes it hard to tell if you're using an editor that displays actual unicode characters.

Just use notepad ++ with encoding UTF-8 without BOM.
Permalink 2 comments
This is PHP file to print date time

<?php
 print date('D, d M Y H:i:s T');
?>
Browser to: http://localhost/date.php ---------------------------------------------------------------------------------- you see that page is cached after 3 calls, if you setup cache rules in web.config CACHING INTRICACIES Even if you enable Output Caching, IIS does not immediately cache a request. It must be requested a few times before IIS considers a request to be "cache worthy". Cache worthiness can be configured via the ServerRuntime section described in this MSDN article. http://msdn.microsoft.com/en-us/library/ms690574 By default, when you create a cache rule a page is cached when it is requested 2 times within a 10 second time period. You can change these default values by first making a change to your applicationHost.config file and then updating your web.config file. Your applicationHost.config file is typically in the c:\Windows\System32\inetsrv\config directory and is most easily opened with Notepad from a command prompt with administrator privileges. In that file, find the following entry (a child of the element):
. Change Deny to Allow and save the file.
<sectionGroup name="system.webServer">
    <section name="serverRuntime" overrideModeDefault="Allow" />
 </sectionGroup>
---------------------------------------------------------------------------------- Then in web.config Refrence <configuration> <system.webServer> <serverRuntime frequentHitThreshold="3" frequentHitTimePeriod="00:00:20" /> <caching> <profiles> <add extension=".php" policy="DontCache" kernelCachePolicy="CacheForTimePeriod" duration="00:05:30" /> </profiles> </caching> </system.webServer> </configuration>
and finally to view the files in cache following command should be run netsh http show cachestate Refrence
Permalink 0 comments
To increase fastCGI PHP_FCGI_MAX_REQUESTS,

On the server level, double-click FastCGI Settings.
Select the FastCGI application that you want to configure. In the Actions pane, click Edit....

In the Edit FastCGI Application dialog box, set the InstanceMaxRequests to 10000. Next to the EnvironmentVariables setting, click the Browse (...) button.




In the EnvironmentVariables Collection Editor dialog box, add the PHP_FCGI_MAX_REQUESTS environment variable and set its value to 10000.


Note: If you do not configure these settings, the following default settings will be used: instanceMaxRequests = 200, PHP_FCGI_MAX_REQUESTS = 500 (on most PHP builds).

Permalink 0 comments

Open IIS Manager, and then move to the server level.

Double-click Handler Mappings.

In the Actions pane, click Add Module Mapping.

In the Add Module Mapping dialog box, specify the configuration settings as follows:

Request path: *.php

Module: FastCgiModule

Executable: C:\[Path to your PHP installation]\php-cgi.exe

Name: PHPviaFastCGI

Click OK.

In the dialog box that asks you to confirm that you want to create a FastCGI application for the executable, click Yes.

To verify that the handler mapping works correctly, create a Phpinfo.php file in the C:\inetpub\wwwroot folder that contains the following:



Open a Web browser, and then navigate to http://localhost/phpinfo.php. If everything was set up correctly, you will see the standard PHP information page.

+
+

PS: if you get "Error Code 0c8007010b" it because of application pool which is different in Plesk

another solution:

Granted Read & execute, List folder contents for Everyone on folder

C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5

and now php is up and running for every Application Pool. The main problem with plesk was, only sites running with Application Pool Identity of a user which is member of psacln.
Permalink 2 comments
First you have to enable CGI

WINDOWS SERVER 2008

Go to Server Manager -> Roles -> Add Role Services. On the Select Role Services page, select the CGI check box. This enables both the CGI and FastCGI services.

Windows Visa/7

Go to Control Panel -> Programs and Features -> Turn Windows features on or off. In the Windows Features dialog box, select the CGI check box. This enables both the CGI and FastCGI services.


Then from Web Platform installer install "PHP Manager for IIS"
Permalink 0 comments
key_buffer_size – Very important if you use MyISAM tables. Set up to 30-40% of available memory if you use MyISAM tables exclusively. Right size depends on amount of indexes, data size and workload – remember MyISAM uses OS cache to cache the data so you need to leave memory for it as well, and data can be much larger than indexes in many cases. Check however if all of key_buffer is used over time – it is not rare to see key_buffer being set to 4G while combined size of .MYI files is just 1GB. This would be just a waste. If you use few MyISAM tables you’ll want to keep it lower but still at least 16-32Mb so it is large enough to accommodate indexes for temporary tables which are created on disk.

innodb_buffer_pool_size This is very important variable to tune if you’re using Innodb tables. Innodb tables are much more sensitive to buffer size compared to MyISAM. MyISAM may work kind of OK with default key_buffer_size even with large data set but it will crawl with default innodb_buffer_pool_size. Also Innodb buffer pool caches both data and index pages so you do not need to leave space for OS cache so values up to 70-80% of memory often make sense for Innodb only installations. Same rules as for key_buffer apply – if you have small data set and it is not going to grow dramatically do not oversize innodb_buffer_pool_size you might find better use for memory available.
innodb_additional_mem_pool_size This one does not really affect performance too much, at least on OS with decent memory allocators. Still you might want to have it 20MB (sometimes larger) so you can see how much memory Innodb allocates for misc needs.
innodb_log_file_size Very important for write intensive workloads especially for large data sets. Larger sizes offer better performance but increase recovery times so be careful. I normally use values 64M-512M depending on server size.
innodb_log_buffer_size Default for this one is kind of OK for many workloads with medium write load and shorter transactions. If you have update activity spikes however or work with blobs a lot you might want to increase it. Do not set it too high however as it would be waste of memory – it is flushed every 1 sec anyway so you do not need space for more than 1 sec worth of updates. 8MB-16MB are typically enough. Smaller installations should use smaller values.
innodb_flush_log_at_trx_commit Crying about Innodb being 100 times slower than MyISAM ? You probably forgot to adjust this value. Default value of 1 will mean each update transaction commit (or each statement outside of transaction) will need to flush log to the disk which is rather expensive, especially if you do not have Battery backed up cache. Many applications, especially those moved from MyISAM tables are OK with value 2 which means do not flush log to the disk but only flush it to OS cache. The log is still flushed to the disk each second so you normally would not loose more than 1-2 sec worth of updates. Value 0 is a bit faster but is a bit less secure as you can lose transactions even in case MySQL Server crashes. Value 2 only cause data loss with full OS crash.
table_cache – Opening tables can be expensive. For example MyISAM tables mark MYI header to mark table as currently in use. You do not want this to happen so frequently and it is typically best to size your cache so it is large enough to keep most of your tables open. It uses some OS resources and some memory but for modern hardware it is typically not the problem. 1024 is good value for applications with couple hundreds tables (remember each connection needs its own entry) if you have many connections or many tables increase it larger. I’ve seen values over 100.000 used.
thread_cache Thread creation/destructions can be expensive, which happen at each connect/disconnect. I normally set this value to at least 16. If application has large jumps in amount of concurrent connections and I see fast growth of
Threads_Created variable I boost it higher. The goal is not to have threads created in normal operation.
query_cache_size If your application is read intensive and you do not have application level caches this can be great help. Do not set it too large as it may slow things down as its maintenance may get expensive. Values from 32M to 512M normally make sense. Check it however after a while and see if it is well used. For certain workloads cache hit ratio is lower than would justify having it enabled.
Note: as you can see all of these are global variables. These variables depend on hardware and mix of storage engines, while per session variables are typically workload specific. If you have simple queries there is no reason to increase sort_buffer_size even if you have 64GB of memory to waste. Furthermore doing so may decrease performance.
I normally leave per session variable tuning to second step after I can analyze workload.
Permalink 0 comments
1.download and unzip PHP 5 to a directory, c:\php-5.2.6-Win32
http://www.php.net/get/php-5.2.9-2-Win32.zip/from/a/mirror

2. download PECL 5.2.5 Win32 binaries.
http://museum.php.net/php5/pecl-5.2.5-Win32.zip

3.rename php.ini-dist to php.ini in c:\php-5.2.6-Win32

4.Uncomment or add the line (remove semi-colon at the beginning) in php.ini:
;extension=php_java.dll

5.copy php5servlet.dll from PECL 5.2.5 to c:\php-5.2.6-Win32

6.copy php_java.dll from PECL 5.2.5 to c:\php-5.2.6-Win32\ext

7.create a directory named "php" (or what ever u like) in tomcat\webapps directory

8.copy phpsrvlt.jar from PECL 5.2.5 to tomcat\webapps\php\WEB-INF\lib

9.unjar or unzip phpsrvlt.jar
for unzip use winrar or winzip
for unjar use : jar xfv phpsrvlt.jar

10.change both net\php\reflect.properties and net\php\servlet.properties to library=php5servlet

11.Recreate the jar file
-> jar cvf php5srvlt.jar net/php/*.*
PS: if the jar file doesnt run you have to add the Path to system variables
for me I added C:\Program Files\Java\jdk1.6.0\bin; to System variables/Path

12.creat web.xml in tomcat\webapps\forphp\WEB-INF with this content:


<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">

<servlet>

<servlet-name>php</servlet-name>

<servlet-class>net.php.servlet</servlet-class>

</servlet>

<servlet>

<servlet-name>php-formatter</servlet-name>

<servlet-class>net.php.formatter</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>php</servlet-name>

<url-pattern>*.php</url-pattern>

</servlet-mapping>

<servlet-mapping>

<servlet-name>php-formatter</servlet-name>

<url-pattern>*.phps</url-pattern>

</servlet-mapping>

</web-app>


13.Add PHP path( c:\php-5.2.6-Win32) to your System or User Path in Windows enironment (Hint: Right-click and select Properties from My Computer

14. create test.php for testing under tomcat\webapps\php like

15.Restart tomcat

16.browse http://localhost:8080/php/test.php
Permalink 19 comments