For ASP.NET hosting (Windows hosting).

PHP 8.1 is the latest version of the PHP scripting language, which is required to run a PHP-based website such as WordPress. IONOS ASP.NET hosting packages already support PHP 8.1 - but the ASP.NET hosting platform is still set to use PHP 7.4 by default. We'll show you how to change this setting to PHP 8.1. After that, your PHP scripts and your PHP-based websites will automatically run with PHP 8.1.

To  configure your web space to PHP 8.1, make the following changes to the web.config configuration file:

  • Download the web.config file from the root directory of your web space to your computer. You can either use the Webfiles file manager from IONOS or your FTP access to do this.

    If there is no web.config file on your web space, create a new one for this purpose. How to do this is described below in the section Creating a web.config file.
  • First, create a backup copy of the web.config file on your computer.
  • Open the web.config file on your computer with a simple text editor like Notepad.
  • Look for a section in the text that begins with the line <system.webServer>and ends with the line </system.webServer>.

    <system.webServer>
    ...
    ...
    </system.webServer>

  • Add the following lines at the end of the section, before the </system.webServer> line:

    <handlers>
       <remove name="PHP7" />
       <add name="PHP8" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\Services\PHP8\php-cgi.exe" resourceType="File" />
    </handlers>

  • Save the changes.
  • Upload the edited web.config back to your web space.

PHP 8.1 is now active immediately. Reload your website in the browser and check if everything works as usual. To disable PHP 8.1 again if needed, remove the corresponding lines from your web.config file again.

Note

Changes to the web.config configuration file automatically affect all subdirectories. If you have several PHP websites and want to activate PHP 8.1 for one website only for the time being, upload the edited web.config to the directory of your website

Create web.config file

If there is no web.config file on your web space, simply create one:.

  • On your computer, open a simple text editor such as Notepad.
  • Copy the sample code below and paste it into the text editor.
  • Save the file under the name web.config.
  • Upload the finished web.config to your web space.

Example of a web.config file

The following code serves as an example for a minimal web.config file. It already contains the instructions for switching to PHP 8.1. You can use this as a copy template for creating your web.config file.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <defaultDocument enabled="true">
      <files>
        <clear />
        <add value="index.aspx" />
        <add value="index.asp" />
        <add value="index.htm" />
        <add value="index.html" />
        <add value="home.aspx" />
        <add value="home.asp" />
        <add value="home.htm" />
        <add value="home.html" />
        <add value="default.aspx" />
        <add value="default.asp" />
        <add value="default.htm" />
        <add value="default.html" />
      </files>
    </defaultDocument>
        <handlers>
            <remove name="PHP7" />
            <add name="PHP8" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\Services\PHP8\php-cgi.exe" resourceType="File" />
        </handlers>
  </system.webServer>
</configuration>