dongxun2089 2012-08-21 09:15
浏览 70
已采纳

通过脚本修改Windows Azure Web角色上的php.ini

I have used a Startup script on a Web role to install PHP by using Windows Plattform Installer. Everything is ok, PHP is installed and the application works, however when I uppload large files the application generates error. I fixed it by editing the php.ini file manually and chnaged upload_max_filesize. My question is, How do I can modify php.ini file automatically (not manually) by adding som script to be executed AFTER php has been installed. I wrote "AFTER" because this script must wait until my startup script is executed completelly and php has been installed. Thanks for your help appreciate all advices.

UPdated: Following is my install-php.bat file which is located in bin folder of my web role. I am not familiar with powershell. How can I translate it to powershell script?

ECHO "Starting PHP Installation" >> log.txt

md "%~dp0appdata"
cd "%~dp0appdata"
cd..

reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d "%~dp0appdata" /f

"..\MyWebpicmdline\WebPICmdLine" /Products:PHP53 /AcceptEula >>log.txt 2>>err.txt

reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d %%USERPROFILE%%\AppData\Local /f

ECHO "Completed PHP Installation" >> log.txt
  • 写回答

1条回答 默认 最新

  • duansang8388 2012-08-21 09:41
    关注

    So I'm assuming you have a startup task with the following:

    WebPICmdLine.exe /Products: PHP
    

    You'll need to write some script that will update your php.ini file and run it after installing PHP. A possible solution would be to do this with PowerShell:

    WebPICmdLine.exe /Products: PHP
    powershell -command "Set-ExecutionPolicy Unrestricted"
    powershell .\UpdatePhpIni.ps1
    

    Find a script that allows you to update ini files (like Edit Ini File), add it to your UpdatePhpIni.ps1 file and add the required code to modify the execution time.

    Note that I'm not a PHP expert, but if I remember correctly you should configure this in the FastCGI settings of IIS (I think these have priority over php.ini).

    Update: Here is what your script should look like with the FastCGI configuration.

    ECHO "Starting PHP Installation" >> log.txt
    
    md "%~dp0appdata"
    cd "%~dp0appdata"
    cd..
    
    reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d "%~dp0appdata" /f
    
    "..\MyWebpicmdline\WebPICmdLine" /Products:PHP53 /AcceptEula >>log.txt 2>>err.txt
    
    ECHO Updating activity timeout.
    %windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi "/[fullPath='%ProgramFiles(x86)%\PHP\v5.3\php-cgi.exe'].activityTimeout:800"
    
    reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d %%USERPROFILE%%\AppData\Local /f
    
    ECHO "Completed PHP Installation" >> log.txt
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?