mlocati / powershell-phpmanager

A PowerShell module to install/update PHP, PHP extensions and Composer on Windows

Home Page:https://www.powershellgallery.com/packages/PhpManager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to install PHP 7.2 on nanoserver

cedric-anne opened this issue · comments

Hi,

First, thanks for developping this nice module.

I am trying to install PHP 7.2 on nanoserver (build 10.0.14393.2551), but it tells me "The Visual C++ 2017 Redistributable seems to be missing: you have to install it manually".

I first tried copying only the vcruntime140.dll file into the C:\Windows\System32 directory, but it does not work. The I tried copying all dlls that have the same creation date as vcruntime140.dll for both System32 and SysWOW64 directory, but it does not help.

I also installed Apache 2.4.37, which requires VC15 and it works. PHP installation works if I ask for 7.1 version.

Here is my DockerFile, if you want to test.

FROM microsoft/nanoserver:10.0.14393.2551

# Visual Studio 2017 / VC15, required for Apache and PHP.
COPY ./files/vcruntime140.dll.15 /Windows/System32/vcruntime140.dll

RUN powershell -Command \
    #
    # Install PHP Manager powershell module.
    Install-PackageProvider -Name "NuGet" -RequiredVersion "2.8.5.201" -Force; \
    Install-Module -Name "PhpManager" -Force; \
    #
    # Install PHP 7.2.
    Install-Php -Version "7.2" -Architecture "x64" -ThreadSafe $true -Path "C:\PHP" -TimeZone "UTC" -AddToPath "System"; \
    #
    # Install PHP extensions.
    Enable-PhpExtension "openssl" "C:\PHP"; \
    #
    # Install Apache 2.4.
    Invoke-WebRequest -Uri "https://home.apache.org/~steffenal/VC15/binaries/httpd-2.4.37-win64-VC15.zip" -OutFile "$ENV:Temp\httpd.zip"; \
    Expand-Archive "$ENV:Temp\httpd.zip" -DestinationPath "$ENV:Temp"; \
    Copy-Item "$ENV:Temp\Apache24" -Destination "C:\Apache24" -Recurse; \
    #
    # Install Composer.
    Install-Composer -Path "C:\Composer" -Scope "System"; \
    #
    # Clean temporary files.
    Remove-Item -Path "$ENV:Temp/*" -Recurse;

COPY ./files/httpd-custom.conf /Apache24/conf/httpd-custom.conf

CMD C:\Apache24\bin\httpd.exe -f "C:\Apache24\conf\httpd-custom.conf"

and my custom httpd-custom.conf file:

# Base configuration
Include conf/httpd.conf

# PHP Configuration (mod PHP)
LoadModule php7_module "C:\PHP\php7apache2_4.dll"
PHPIniDir "C:/PHP"
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

Regards

PHP 7.2 requires the VC 2017 redistributable, but I also haven't found a way to install it on nanoserver.

Hi,

The only thing I can tell is that my Apache installation, that requires the VC 2017 (VC15) is working well. I just copied the vcruntime140.dll (the version from VC 2017) from my Windows 10 computer and it works.

I do not know how to check which dll PHP requires. Maybe it requires a tier dependency.

Regards