This tutorial guides you on how to install or configure PHP-FastCGI on Windows in XAMPP for PHP performance.
PHP-FastCGI on Windows in XAMPP for PHP Performance
I was trying to improve the PHP performance with FastCGI on XAMPP for Windows. Running PHP with fcgid will give you the following benefits.
- The fcgid boosts the performance, both in CPU and memory consumption
- It also creates separate windows tasks to run the PHP processes separately.
The following are the steps that you need to follow to install or configure PHP-FastCGI on Windows in XAMPP.
Note, when you browse through the URL: http://localhost/dashboard/phpinfo.php after installing XAMPP you will notice that the Server API currently configured by default is Apache 2.0 Handler. We are going to replace this with PHP-FCGID module.
Therefore, first you need to download latest version of FastCGI ASF module from the following link
I had downloaded Win64 version of mod_fcgid ie., mod_fcgid-2.3.10-win64-VS16.zip
mod_fcgid FastCGI ASF module [mod_fcgid] mod_fcgid-2.3.10-win64-VS16.zip info 16 Jun '19 45K [mod_fcgid] mod_fcgid-2.3.10-win32-VS16.zip 41K
Install FastCGI in XAMPP on Windows
1: First, stop the Apache service via XAMPP control panel.
2: Then, copy mod_fcgid.so that was extracted from the above zip file to your apache/modules folder
3: Next, create a new configuration file httpd-fcgid.conf in the following path.
Then copy and paste the following configuration for mod_fcgid.
# Configuration for mod_fcgid FcgidInitialEnv PHPRC "C:/xampp/php" FcgidInitialEnv PATH "C:/xampp/php;C:/Windows/System32;C:/Windows;C:/Windows/System32/Wbem;" FcgidInitialEnv SystemRoot "C:/Windows" FcgidInitialEnv SystemDrive "C:" FcgidInitialEnv TEMP "C:/Windows/Temp" FcgidInitialEnv TMP "C:/Windows/Temp" FcgidInitialEnv windir "C:/Windows" FcgidIOTimeout 64 FcgidConnectTimeout 16 FcgidMaxRequestsPerProcess 1000 FcgidMaxProcesses 50 #FcgidMaxProcessesPerClass 25 FcgidMaxRequestLen 8131072 # Location php.ini: FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000 <Files ~ "\.php$>" AddHandler fcgid-script .php FcgidWrapper "C:/xampp/php/php-cgi.exe" .php </Files>
4: Then add the following lines to your httpd.conf file.
LoadModule fcgid_module modules/mod_fcgid.so #FCGID Module Include "conf/extra/httpd-fcgid.conf"
5: Next, comment out the following sections in httpd-xamp.conf file in the following path C:\xampp\apache\conf\extra\httpd-xampp.conf, so that all your PHP files will be served via mod_fcgid.
#<FilesMatch "\.php$"> # SetHandler application/x-httpd-php #</FilesMatch> #<FilesMatch "\.phps$"> # SetHandler application/x-httpd-php-source #</FilesMatch>
6: Finally, start your apache services and test your web pages.
Verify the installation of PHP-FastCGI
To verify whether FastCGI is enabled in XAMPP, you need to browse the following URL http://localhost/dashboard/phpinfo.php and check whether the value of Server API is CGI/FastCGI as shown in the following picture.
I also tried modifying the setting value for FcgidMaxProcesses as 2 in the http-fcgid.conf file just to verify whether this setting is applied on the apache server. Therefore, it sets maximum number of PHP processing slots as 2. It means that this setting sets a ceiling limit over the top of all users for the maximum number (ie., 2) of FastCGI PHP processes as shown below.
That’s it. The only problem I see is after stopping apache server from the XAMPP control panel, the FastCGI PHP processes that have been started have to be manually killed via “End Task” option in the Windows Task Manager.
Hope the tutorial on PHP-FastCGI on Windows in XAMPP for PHP Performance helped 🙂
- PHP FPM – Check if Installed and Running
- With UAC please avoid installing XAMPP to C:\Program Files warning ?
- Default .htaccess file for WordPress website ?
- How to Check XAMPP version on Windows ?
- Create components inside a specific folder with Angular 9 CLI ?
- Best way to delete components in Angular 9 with CLI
- Get index of ngFor element using index as value in attribute
- Set default value in the dropdown list in Angular 9
- Dynamic and conditional CSS classes with ngClass : Angular
- Best way to delete components in Angular 9 with CLI ?
- HTML Property Binding in Angular : Data Binding
- Quickly create div classes in Visual Studio Code editor
- Global Angular CLI version is greater than your local version
- Create custom events and fire in Angular 9 with EventEmitter – Example
- Bind selected element from drop down to an object in Angular 9
- How to stop generation of .spec.ts test files using Angular CLI ?