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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄