Visits: 9356
In Windows there are always multiple ways to install stuff like CGI
I will follow the installation steps of the PHP 8 Non Thread Safe version on a Windows Server 2019 Standard Evaluation (Desktop Experience) operating system what needs IIS and CGI to be installed. Install first the IIS (Internet Information Services) by opening Server Manager where we have Manage, Tools, View and Help menus. At Manage we click on Add Roles and Features and for IIS installation on Server Roles select Web Server (IIS), then Add Features and Next after selecting. At Role Services, expand Application Development and select CGI (Common Gateway Interface). We still have a final Next and then Install.
Php is built with C++ and needs the visual studio runtime installed.
You can get started with an Email Cloud Server that is wonderful combination of MS Windows Server and Open Source Software. It is available through AWS Marketplace as Hmailserver on Windows Server with Roundcube Webmail so that you can check email anywhere and from any device.
Now Download and install Microsoft Visual C++ Redistributable Package by going to the latest supported Visual C++ downloads and download the latest version of the Microsoft Visual C++ 2015-2019 Redistributable (x64) – 14.22.278.21 (x64: vc_redist.x64.exe) and install it;
Download the latest php non thread safe 64 from https://windows.php.net/download/ , extract it to a dir like c:\php8
In server manager choose
web Server (IIS)
I had installed the web server first without Adding CGI feature, thaen I couldn’t find the option to add the feature to IIS. After a day off my brains worked better, You need to press the little arrow in the add server roles for Web Server IIS, then Web Server, then application Development, under there , is CGI
Now finally, I I have the CGI option and FastCGI in the Add Handler mappings in the IIS Manager.
TO add php as fastcgi add a new handler and fill it out.
Request path: *.php
Module: FastCGIModule
Executable: C:\php8\php-cgi.exe
Name: PHP with FastCGI
Now edit the fast cgi settings from the service manager, they miraculously should have appeared.
Click on the fastci php-cgi.exe that you previously added, now add
The Edit FastCGI Application was opened and at FastCGI Properties under General\Environment Variables (Collection) click on the three dots … next to the work “Collection”
Now Add these values as follows:
Under Members click Add and for the Name Properties we change Name: PHP_MAX_REQUESTS and VALUE: 5000 then click OK to save the changes;
OK to exit from Edit FastCGI Application and come back to the FastCGI Settings and we can close Internet Information Services (ISS) Manager;
Now open a Powershell Window as Admin
To restart IIS open the Comand Prompt or PowerShell and type iisreset
C:\Users\Administrator>iisreset
Now go into the php dir and check if php is working on your server as a language. Run the following:
PS C:\php8> .\php.exe -info
You should see a ton of settings instead of an error.
You should also verify that PHP works with IIS. Create the following file, but delete when your finished as giving server information can invite attackers, if they see that your old version of php is vulnerable.
create a file called info.php and insert into it the following
the C:\inetpub\wwwroot directory and create info.php
Just this line of code in the file:
<?php phpinfo(); ?>
after you save it open http://localhost/info.php
The next project will be to do this totally in a script from ansible.