Skip to main content
Version: 7.0

Windows Server

danger

Please note:

  • This instruction assumes the following:
    • Physical location of Passwork — C:\inetpub\wwwroot\passwork
    • Passwork website name — Passwork Web Site
  • Before updating, if Passwork is installed in a cloud/virtual environment, create a snapshot of the OS virtual state to restore functionality in case of incorrect update

Obtaining current version of Passwork

Create a temporary directory to obtain Passwork:

mkdir "$env:SystemDrive\inetpub\new_version"

If server with Passwork is located in air-gapped network

You need to go to the Passwork Customer Portal, copy the certificate number and use the browser address bar to get version 7 of Passwork —
https://portal.passwork.pro/api/download?apikey=api_key

Go to the Passwork Customer Portal and copy the API key to obtain the current version:

Obtaining API key on the client portal

Create a variable API_KEY with the certificate number:

$API_KEY = "your_api_key"

Obtain Passwork version 7 using the request:

try {
(New-Object System.Net.WebClient).DownloadFile(
"https://portal.passwork.pro/api/download?apikey=$API_KEY",
"$env:SystemDrive\inetpub\new_version\passwork.zip"
)
Write-Output "Passwork archive successfully obtained"
} catch {
Write-Output "Error obtaining Passwork: $_"
}

Clear the variable API_KEY with the certificate number:

Remove-Variable API_KEY

Updating to actual version

Get the current Passwork version into a variable:

$version = Get-Content "$env:SystemDrive\inetpub\wwwroot\passwork\version"

Copy Passwork configuration files to the temporary directory:

Copy-Item -Path "$env:SystemDrive\inetpub\wwwroot\passwork\init\config.env" -Destination "$env:SystemDrive\inetpub\new_version\" -Recurse -Force
Copy-Item -Path "$env:SystemDrive\inetpub\wwwroot\passwork\init\encryption_key" -Destination "$env:SystemDrive\inetpub\new_version\" -Recurse -Force
Copy-Item -Path "$env:SystemDrive\inetpub\wwwroot\passwork\.env" -Destination "$env:SystemDrive\inetpub\new_version\" -Recurse -Force

Create an archive of the current Passwork version to allow rollback to the previous version:

Compress-Archive -Path "$env:SystemDrive\inetpub\wwwroot\passwork\*" -DestinationPath "$env:SystemDrive\inetpub\wwwroot\passwork-$version.zip" -Force

Delete all contents from the Passwork directory:

Remove-Item -Path "$env:SystemDrive\inetpub\wwwroot\passwork\*" -Recurse -Force

Extract the updated Passwork version to the physical location:

Expand-Archive -Path "$env:SystemDrive\inetpub\new_version\passwork.zip" -DestinationPath "$env:SystemDrive\inetpub\wwwroot\passwork\"

Move the copied Passwork configuration files to the new version:

Copy-Item -Path "$env:SystemDrive\inetpub\new_version\config.env" -Destination "$env:SystemDrive\inetpub\wwwroot\passwork\init\" -Recurse -Force
Copy-Item -Path "$env:SystemDrive\inetpub\new_version\encryption_key" -Destination "$env:SystemDrive\inetpub\wwwroot\passwork\init\" -Recurse -Force
Remove-Item -Path "$env:SystemDrive\inetpub\wwwroot\passwork\.env" -Recurse -Force
Copy-Item -Path "$env:SystemDrive\inetpub\new_version\.env" -Destination "$env:SystemDrive\inetpub\wwwroot\passwork\" -Recurse -Force

Delete the temporary directory update_passwork:

Remove-Item -Path "$env:SystemDrive\inetpub\new_version" -Recurse -Force

Set permissions for the physical location of Passwork:

Invoke-Expression "icacls '$env:SystemDrive\inetpub\wwwroot' /grant 'IIS_IUSRS:(OI)(CI)`M'"
Invoke-Expression "icacls '$env:SystemDrive\inetpub\wwwroot' /grant 'Users:(OI)(CI)`M'"
Invoke-Expression "icacls '$env:SystemDrive\inetpub\wwwroot' /grant 'IUSR:(OI)(CI)`M'"

Download the rewrite rules web.config and place it in the new Passwork version — C:\inetpub\wwwroot\passwork\public\web.config

web.config

Registering PHP and enabling extensions

Import IIS modules and register the PHP version:

Import-Module IISAdministration
Add-PsSnapin PHPManagerSnapin

New-PHPVersion -ScriptProcessor "$env:ProgramFiles\php8.3\php-cgi.exe" -SiteName "Passwork Web Site" -VirtualPath "/"

Enable PHP extensions for the Passwork website:

$extensions = @(
"php_curl.dll",
"php_gd.dll",
"php_gettext.dll",
"php_intl.dll",
"php_ldap.dll",
"php_mbstring.dll",
"php_mongodb.dll",
"php_mysqli.dll",
"php_openssl.dll",
"php_pdo_pgsql.dll",
"php_pdo_sqlite.dll",
"php_pgsql.dll",
"php_soap.dll",
"php_zip.dll",
"php_fileinfo.dll"
)

foreach ($extension in $extensions) {
Write-Host "PHP extension enabled: $extension"
Set-PHPExtension -Name $extension -Status Enabled -SiteName "Passwork Web Site" -VirtualPath "/"
}

Enable additional PHP methods for the Passwork website:

$phpVersion=(Get-PHPConfiguration -SiteName "Passwork Web Site" -VirtualPath "/").Version
Set-WebConfigurationProperty -PSPath "IIS:\Sites\Passwork Web Site" -Filter "system.webServer/handlers/add[@name='php-$phpVersion']" -Name "verb" -Value "GET,HEAD,POST,PUT,DELETE,PATCH"

Go to the root location of Passwork and update the Passwork version in the database:

cd "$env:SystemDrive\inetpub\wwwroot\passwork"
php -d "memory_limit=-1" .\bin\console cache:clear
php -d "memory_limit=-1" .\bin\console cache:warmup
php -d "memory_limit=-1" .\bin\console app:update