IIS10 web server with classic ASP + PHP
The purpose of this document is to describe how to install an IIS10 web server on a windows 2022 server + how to enable both classic ASP and PHP. This document is publicly shared but intended for my own use / Mattias.
How to install Windows 2022 server 2
How to install an IIS server (web server). 3
How to enable Classic ASP on IIS 10 3
How to enable Client side debugging 5
Classic ASP ACCESS database connection error 6
How to enable 32 bit application support in IIS 10 6
How to fix “operation must use an updateable query 7
How to enable PHP on IIS 10 8
Use PHP manager addon to help set paths 9
How to enable detailed server side error logging on external web browsers. 11
How to create free HTTPS certificates for IIS 10 13
How to redirect HTTP request to HTTPS 16
How to install Windows 2022 server
- Install from USB stick.
- Run windows update.
- Activate Remote desktop support
- Open server manager
- Select local server on the left hand side
- Activate remote desktop (if you want to continue the setup from another computer).
- Set a static IP such as 10.10.10.70 / 255.255.255.0
- Turn off the local firewall.
- IF evaluation media was used, convert this to real license.
- Open a cmd prompt
- Run: DISM /online /Get-CurrentEdition
- To upgrade from Eval to Standard with key
- DISM /Online /Set-Edition:ServerStandard /ProductKey: xxxx-xxxx-xxxx-xxxx /AcceptEula
How to install an IIS server (web server).
This will install a basic IIS server. ASP and PHP support is described later.
- Open server manager
- Manage > Add roles and features > Next > Next
- Add server roles
- Web server IIS = Checked. Next
How to enable Classic ASP on IIS 10
- On IIS 10 this is an additional feature in “Add roles and features”-wizard.
- Expand Web server IIS
- Expand Web server
- Expand Application development
- Check ASP
Create this file and put it in your webroot.
<%= 4+4 %>
This file should output:
IF you get this error:
- IF you get this error message. Try changing the default document order in the IIS > Site > Default Document settings . That will generate a web.config file in the site root. This file is required for ASP to run.
- Make the file accessible to IIS_IUSRS group. Just right click web.config and click properties, under security tab, add IIS_IUSRS.
Note that the application pool is using this group and NOT the IIS user account.
Try breaking the code to see how the server reacts:
Run the file:
<%= 4+4x %>
This may now return:
This is not very helpful. In a development/debugging environment you want to see something like this:
How to enable Client side debugging
- Open IIS
- Select your site
- Go into ASP
- Enable “Send errors to Browser” = True
To send detailed errors to the server event viewer, open ASP on the server root in IIS. Expand the Compilation/Debugging properties and change “Log errors to NT log” from false to TRUE.
Classic ASP ACCESS database connection error
If you are trying to open an older Microsoft Access database using ASP you might get the error below. Default IIS10 does not support 32 bit applications and that might be the reason.
ADODB.Connection error '800a0e7a'
Provider cannot be found. It may not be properly installed.
/web08/_inc_global.asp, line 19
How to enable 32 bit application support in IIS 10
- Open Internet Information Services (IIS) Manager
- Select the application pool for the site you want to change
- Click advanced settings
- Second row, change “Enable 32-bit applications” from false to TRUE
How to fix “operation must use an updateable query
- On the web server, find the xxx.mdb file from the error message.
- Select the file, right click and select the security tab.
- Click the edit button
- Select the “IIS_IUSRS (server name)”-group.
- Set “modify” in the Allow column to check.
How to enable PHP on IIS 10
If you try to run a php file on IIS
<?php echo 1+1 ?>
You will probably get an error like this one:
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
You need to enable PHP support on IIS.
- Start server manager
- Add roles and features
- Role-based or feature-based installation
- Select webserver
- Browse to CGI and make sure that checkbox is checked.
IF you miss to install CGI (includes FastCGI) as above PHP will warn you:
Download PHP executables
- Download PHP from windows.php.net
- Copy the PHP folder to a place on your webserver. Does not need to be inside the webroot.
Use PHP manager addon to help set paths
PHP manager is used to set the correct paths to PHP.exe.
- Download php manager
- Start MSI installation. Close at the end.
- Start IIS server
- Open your website
- Find PHP Manager
- Click “register new php version”
- Browse to the PHP-cgi.exe file and select it.
- If you select the test link you may get the following error message:
HTTP Error 500.0 - Internal Server Error
V:\php-8.1.12\php-cgi.exe - The FastCGI process exited unexpectedly
This error may appear on a newly installed server where the Visual Studio distributable is missing.
OR from https://windows.php.net/
How to enable detailed server side error logging on external web browsers.
If you get server 500 errors it can be any server side issue. Older IIS servers sent the error to the web browser but in IIS10 you have to change some settings for that to happen (leave this disabled for enhanced security).
If you are running a production server you want to avoid sending anything else then a 500 error to the client.
If you still want temporary debugging you can use the event viewer in windows.
- You have enabled “Send errors to browser = True” on the IIS server.
- You run an ASP file, from an web browser outside of the local web server, that include an error and it still return “Server error - 500”, and not the debugging message you would expect.
What you expect is the following:
One thing to note here is that the “Send errors to browser” - setting default only applies to local (localhost) requests. All external calls will still return the standard 500 error.
How do I enable detailed error responses for 500 server errors to external web browsers?
- Open IIS manager
- Open your site
- Open Error pages
- Change from “Detailed errors for local…” to “Detailed errors”
Manually edit the web.config file that is located in the site web root.
<httpErrors errorMode="Detailed" />
How to create free HTTPS certificates for IIS 10
This guide is based on this article.
- Go to the Github page of win-acme.
- Scroll down a little, you’ll see the assets section. Find the zip file with the name win-acme.v2.x.x.x.zip
- Extract the application after downloading & save it to the harddrive of the web server.
- Generating the certificates, finally!
Find wacs.exe from the folder you downloaded and run it. As it is an application downloaded from the internet, you might get a warning pop-up from Windows Defender. But it is completely safe to run this application as it is open source. Go ahead and click on Run Anyway, under More info.
- In the application, you’ll be given a couple of options and then asked to choose one of them. Press the N key to choose the Create a new certificate option.
- Then you’ll be asked to select the kind of certificate you want to create. Press 1 as we want to choose the Single binding of an IIS site.
- You’ll be asked to choose the website you want to generate the certificate for. Choose the test website we created.
- You’ll now be asked to enter your email address and then agree with the terms and conditions.
You have successfully generated an SSL certificate for your website. Not just this, the application will also renew the certificate whenever it’s due.
How to redirect HTTP request to HTTPS