How to install or update PHP

In this article

Important:
Updating your PHP will require you to temporarily stop IIS (Internet Information Services) on your server.

This means that XUNO (and any other websites hosted on the same server) will be unavailable for a period of time while you complete the update. Please make sure that you backup your PHP folder before you begin by following the steps below.

If you are not upgrading PHP from a previous version you can skip parts 1 and 2.

Part 1: Finding what version of PHP you have installed

  1. First make sure you are fully up to date with your Windows updates. After any updates are installed you should restart the server.
  2. Ensure you are up-to-date with XUNO's minimum server and browser requirements, particularly using a 64bit operating system. Minimum requirements may be accessed from here.
  3. On your XUNO server, open a new command line window.
  4. Type 'php -v' and press Enter.
  5. You will see text which will look similar to this:

    PHP 5.6.7 (cli) (built: Mar 19 2015 15:10:37)
    Copyright (c) 1997-2015 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    	
  6. If your PHP version is not 7.2 then you will need to continue with the instructions below to upgrade your version of PHP.

  

Part 2: Backing up your PHP installation

  1. On your XUNO server, open IIS and click on the Stop button to disable your IIS.
  2. Open your windows explorer and navigate to the location of your PHP installation. By default this is in C:\Program Files (x86)\PHP.
  3. Copy your entire PHP folder to create a backup of it in the same location. For example, if your PHP folder is "C:\Program Files (x86)\PHP", then copy the entire PHP folder and copy to "C:\Program Files (x86)\PHP Backup".

  

Part 3: Downloading & installing PHP 7.2

  1. First make sure you are fully up to date with your Windows updates. After any updates are installed you should restart the server.
  2. Ensure you are up-to-date with XUNO's minimum server and browser requirements, particularly using a 64bit operating system. Minimum requirements may be accessed from here.
  3. On your XUNO server, open IIS and click Web Platform Components under Features View > Management.  You may need to first download and install the feature via Get New Web Platform Components located in the Actions panel on the right side of the window. This will run the Web Platform Installer.
  4. In the search bar, located in the top-right corner of the installer, type PHP and click enter.
  5. Find the PHP 7.2 option from the list of search results and click Add. This item will read something like PHP 7.2.7 (x64).

    Note: Do not select the IIS Express version of PHP.

  6. Click Install.
  7. In the next window, click I Accept to accept the prerequisites.

    Note: The installation of some prerequisites may fail. Some of these prerequisites are required in order to run PHP and other prerequisites are supporting features. The following steps will tell you if PHP has been installed correctly.

  8. Close the installer.
  9. Download the latest ssl libraries. 
    1. This may be done by downloading the cacert.pem file from https://curl.haxx.se/docs/caextract.html.
  10. Download loaders.
    1. Download the appropriate Windows loadings.zip file from https://www.sourceguardian.com/loaders.html.
    2. Unzip the file.
  11. Copy downloaded files into the PHP folder.
    1. Go to the PHP folder via Windows Explorer (C:\Program Files\PHP\v7.2).
    2. Copy the cacert.pem file from step 1a into this folder.
    3. Open the ext folder.
    4. Copy the file ixed7.2win from step 2b into the ext folder. If you are not using PHP 7.2, copy the appropriate file.
  12. Navigate to the PHP 7.2 installation directory. This is usually found in C:\Program Files\PHP\v7.2.
  13. Open up the php.ini file in NotePad.
  14. Find the Extensions section and remove the semi-colon at the beginning of each of these lines. If any of the below are not in the file, simply type at the bottom of the ExtensionList:
     
    extension=php_mysqli.dll
    extension=php_mbstring.dll
    extension=php_gd2.dll
    extension=php_gettext.dll
    extension=php_curl.dll
    extension=php_exif.dll
    extension=php_xmlrpc.dll
    extension=php_openssl.dll
    extension=php_soap.dll
    extension=php_pdo_mysql.dll
    extension=php_pdo_sqlite.dll
    extension=php_imap.dll
    extension=php_tidy.dll
    extension=php_ldap.dll
    extension=php_fileinfo.dll
    extension=ixed.7.2.win
    	

    Additional Extensions

    If you are currently using a First Class Timetable or Human Edge Attendance with XUNO, you will need to install the Microsoft Driver for PHP for SQL Server. You can download the PHP 7.2 driver from here. Remember to also install the Microsoft ODBC driver that correlates to the package you are downloading. You will be able to find the ODBC driver here.

    For additional optimisation, you might want to consider enabling php_wincache.dll and php_opcache.dll. You can read more about them here.

  15. Scroll to the bottom of the file. Then copy and paste the following lines at the end of the php.ini file. Replace <insert SMTP server address> and <insert school email address> with your SMTP and email details (for example: smtp.edumail.vic.gov.au and sthmelbcol.vic.edu.au).

    [XUNO]
    display_errors = Off
    error_reporting = E_CORE_ERROR & E_ERROR & E_PARSE
    post_max_size = 512M
    file_uploads = On
    upload_max_filesize = 512M
    upload_tmp_dir = "C:\Windows\Temp"
    date.timezone = Australia/Melbourne
    SMTP = <insert SMTP server address>
    sendmail_from = <insert school email address>
    extension_dir = "ext"
    log_errors = On
    fastcgi.impersonate = 1
    error_log = C:\Windows\Temp\php_errors.log
    cgi.force_redirect = 0
    cgi.fix_pathinfo = 1
    fastcgi.logging = 0
    max_execution_time = 600
    memory_limit = 512M
    max_input_vars = 10000
    mysqli.allow_local_infile = On
    	
  16. Check that curl.cainfo does not exist anywhere in the file, or is commented out (; at the start of the row)
  17. If it does not exist anywhere, add the following to the bottom of the php.ini file: curl.cainfo=C:\Program Files\PHP\v7.2\cacert.pem
  18. If your PHP folder is not in C:\Program Files, update the location in step 17.
  19. Save the changes to your php.ini file.

Enable opcache and wincache

Information is available at https://www.php.net/manual/en/install.windows.recommended.php. The php.ini settings in that article should be copied to the local php.ini (2 sets of 3 lines each). The wincache dll links are a bit old. Use the dlls in https://windows.php.net/downloads/pecl/releases/wincache/. Version 2.0.0.8 for PHP 7.2 x64 is probably the most likely version for most schools.

Part 4: Validating your PHP installation

  1. On your XUNO server, open a new command line window.
  2. Type 'php -v' and press Enter.
  3. A successful PHP installation will return text which will look similar to this:

    PHP 7.2.20 (cli) (built: Mar 19 2017 15:10:37)  
    Copyright (c) 1997-2015 The PHP Group  
    Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    	
  4. Open IIS and click on the Start button to start IIS.

Part 5: A little help with validating your PHP installation

If you are getting the following error when typing 'php -v' into command prompt:

'php' is not recognized as an internal or external command,
operable program or batch file.

Then you will need to run through a few steps:

  1. Press Windows Key + Pause.
  2. On the left pane, click Advanced system settings.
  3. Click Environment Variables.
  4. Down the bottom in System variables, choose to edit Path .
  5. Make sure the full PHP path appears, if it does not you will need to add it by clicking New, and then Browse.
  6. If it does not appear, you may need to update and/or restart the server.