Mattias Nordins
kontrollpanel

version 0.0

Obehöriga äga ej tillträde till denna sida.
ALLA inloggningsförsök loggas


Lösenord:
Hantera besöksloggen
Hantera besöksloggen
Hantera chat loggen
Hantera chat loggen
Hantera fotoalbumet
Hantera fotoalbumet
Hantera filmarkivet
Hantera filmarkivet
Hantera humorarkivet
Hantera humorarkivet
Hantera fel loggen
Hantera fel loggen
Hantera ikonarkivet
Hantera ikonarkivet
Hantera kalendern
Hantera kalendern

Page last updated 11/8/2022 3:53:5       This page has been visited: 23 times. 1 today. 1 yesterday.

                       
This page was published 2022-11-28 by Mattias Nordin.
Updated: 2022-11-28
Show statistics... Not indexed by robot yet.
Keywords: IIS10, PHP, ASP.
source

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

Scenario:        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

  1. Install from USB stick.
  2. Run windows update.
  3. Activate Remote desktop support
  1. Open server manager
  2. Select local server on the left hand side

  1. Activate remote desktop (if you want to continue the setup from another computer).
  1. Set a static IP such as 10.10.10.70 / 255.255.255.0
  2. Turn off the local firewall.
  3. IF evaluation media was used, convert this to real license.



    Guide:
    https://4sysops.com/archives/convert-windows-server-2019-evaluation-to-the-retail-edition/ 

  1. Open a cmd prompt
  2. Run: DISM /online /Get-CurrentEdition
  3. To upgrade from Eval to Standard with key
  1. DISM /Online /Set-Edition:ServerStandard /ProductKey: xxxx-xxxx-xxxx-xxxx /AcceptEula
  1. Reboot

How to install an IIS server (web server).

This will install a basic IIS server. ASP and PHP support is described later.

  1. Open server manager
  2. Manage > Add roles and features > Next > Next
  3. Add server roles
  1. Web server IIS = Checked. Next
  1. Next
  2. Install

How to enable Classic ASP on IIS 10

  1. On IIS 10 this is an additional feature in “Add roles and features”-wizard.
  2. Expand Web server IIS
  3. Expand Web server        
  4. Expand Application development
  1. Check ASP
  1. Install        

Test it:

Create this file and put it in your webroot.

asp.asp

<hr>

<%= 4+4 %>

This file should output:

asp.asp


8

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:

asp.asp

<hr>

<%= 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

  1. Open IIS
  2. Select your site
  3. Go into ASP
  4. Enable “Send errors to Browser” = True

Note!
Send errors to browser = True ONLY send detailed, 500 etc, server errors to
local clients running on the server itself.
http://localhost/page.asp will work but NOT http://mattiasnordin.net/page.asp 


See below how to send errors to external web browsers.

Note!
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

  1. Open Internet Information Services (IIS) Manager
  2. Select the application pool for the site you want to change
  3. Click advanced settings
  4. Second row, change “Enable 32-bit applications” from false to TRUE

Before

After

How to fix “operation must use an updateable query

  1. On the web server, find the xxx.mdb file from the error message.
  2. Select the file, right click and select the security tab.
  3. Click the edit button
  4. Select the “IIS_IUSRS (server name)”-group.
  5. Set “modify” in the Allow column to check.

Before

After

How to enable PHP on IIS 10

If you try to run a php file on IIS

php.php

<?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.

  1. Start server manager
  2. Manage
  3. Add roles and features
  4. Role-based or feature-based installation
  5. Select webserver
  6. 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

  1. Download PHP from windows.php.net
  2. 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.

https://www.iis.net/downloads/community/2018/05/php-manager-150-for-iis-10

  1. Download php manager
  2. Start MSI installation. Close at the end.
  3. Start IIS server
  4. Open your website
  5. Find PHP Manager


  1. Click “register new php version”
  2. Browse to the PHP-cgi.exe file and select it.
  3. 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).

Note!
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.

Scenario:

  • 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.

Question:
How do I enable detailed error responses for 500 server errors to external web browsers?

Alternative 1)

  1. Open IIS manager
  2. Open your site
  3. Open Error pages
  4. Change from “Detailed errors for local…” to “Detailed errors”

Alternative 2)

Manually edit the web.config file that is located in the site web root.

<system.webServer>

   <httpErrors errorMode="Detailed" />

</system.webServer>

Before

After

How to create free HTTPS certificates for IIS 10

This guide is based on this article.

  1. Go to the Github page of win-acme.
  1. Scroll down a little, you’ll see the assets section. Find the zip file with the name win-acme.v2.x.x.x.zip


  1. Extract the application after downloading & save it to the harddrive of the web server.

screenshot of extracted files

  1. 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.

screenshot of message that Windows protected your PC

  1. 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.
  2. 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.

screenshot of the process

  1. You’ll be asked to choose the website you want to generate the certificate for. Choose the test website we created.
  2. You’ll now be asked to enter your email address and then agree with the terms and conditions.

screenshot of the process

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

 https://www.iis.net/downloads/microsoft/url-rewrite