【发布时间】:2021-02-25 02:36:35
【问题描述】:
我有以下与 microsoft/iis 一起使用的功能,但我想让它与较小的 nanoserver 一起使用。当我用 nanoserver/iis 替换 microsoft/iis 时,这条线失败了。是不是因为exe文件无法在nanoserver中运行?
C:\vc_redist-x64.exe /quiet /install
FROM nanoserver/iis
这行得通:
FROM microsoft/iis
ADD PHP_7.3.26-NTS.zip C:\\php.zip
#unzip
RUN powershell -Command "expand-archive -Path 'c:\php.zip' -DestinationPath 'c:\test'"
#check path for source file php folder name if it changes!
RUN powershell -Command "Copy-item -Force -Recurse -Verbose 'c:\test\PHP_7.3.26-NTS' -Destination 'c:\php'"
ADD vc_redist-x64.exe C:\\vc_redist-x64.exe
ADD php_wincache.dll c:\\PHP\\ext\\php_wincache.dll
ADD php_pdo_sqlsrv_73_nts.dll c:\\PHP\\ext\\php_pdo_sqlsrv_73_nts.dll
ADD php_sqlsrv_73_nts.dll c:\\PHP\\ext\\php_sqlsrv_73_nts.dll
ADD php.ini C:\\php\\php.ini
# Enable required IIS Features
# Install VC Redist 14
# Configure IIS
# Configure system PATH
RUN dism.exe /Online /Enable-Feature /FeatureName:IIS-CGI /All && \
C:\vc_redist-x64.exe /quiet /install && \
del C:\vc_redist-x64.exe && \
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI /+[fullPath='c:\php\php-cgi.exe'] && \
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='c:\php\php-cgi.exe',resourceType='Unspecified'] && \
[fullPath='c:\PHP\php-cgi.exe'].environmentVariables.[name='PHPRC',value='C:\PHP'] && \
setx PATH /M %PATH%;C:\PHP && \
setx PHP /M "C:\PHP"
# Optional: Add a starter page
RUN powershell.exe -Command "'<?php phpinfo(); ?>' | Out-File C:\inetpub\wwwroot\phpinfo.php" -Encoding UTF8
# ADD any application content and perform any configuration below
WORKDIR /inetpub/wwwroot
ADD web.config C:\\inetpub\\wwwroot\\web.config
【问题讨论】:
-
github.com/dotnet/runtime/issues/40131 你最好使用Server Core,或者使用线程中提到的解决方法。
-
您也可以使用 PowerShell 脚本来复制二进制文件。social.technet.microsoft.com/Forums/en-US/…
-
由于体积小,我想使用 nanoserver。我尝试将 VCRUNTIME140.dll 直接复制到 nanoserver。当我在命令行上运行 php 时,它没有错误地退出。
标签: php windows iis dockerfile nano-server