[Turn] iis php project deployment

 


 

 

 

 

 

Today, along with learning how to deploy php projects under the IIS, the operation is very simple, the record about the steps!

1. Start iis server

  

Finally, click OK to complete

2. Open the iis

 

Click to go to

3. Create website

Add into the website.

Add precautions shown in Figure!

Start, browse, restart, stop the site shown in this figure.

It should be noted that as long as it is necessary to modify the configuration of the restart at the site

4.php settings

  ① add a default document

  

Write index.php on line

② handler mapping

  

Select "Add Module Mapping"

Explanation

  Request path:. * Php * know you know why regular

  Module: This must be the time to start IIS, you must check "CGI", can not find the time or else choose FastCgiModule

So far php project is already deployed on iis well [in the project root directory will generate the web.config file]. But for those who need to use such yii2 landscaping pseudo-static url routing .... then, also requires the following operations:

1. Install urlrewrite

  Baidu URLREWRITE download and install.

2. Use URL rewriting

  After successful installation URLREWRITE, start again after closing iis. Then url rewrite entries will appear on the page. Click on it to

 

 

After the url rewrite done, you will have to write the configuration in the web.config file

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="index.php" />
            </files>
        </defaultDocument>
        <handlers>
            <add name="php" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="E:\phpstudy\php\php-7.0.12-nts\php-cgi.exe" resourceType="File" />
        </handlers>
        <rewrite>
            <rules>
                <rule name="wechat">
                    <match url="^\/wechat\/(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/wechat/index.php/{R:1}" />
                </rule>
                 <rule name="已导入的规则 1">
                     <match url="^(.*)$" ignoreCase="false" />
                     <conditions logicalGrouping="MatchAll">
                         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                     </conditions>
                     <action type="Rewrite" url="index.php/{R:1}" />
                 </rule>
            </rules>
        </rewrite>
    </system.webServer>


</configuration>

大家注意了 。我上面的配置有两个重点。

第一  解决了  “关于IIS上Yii2的url路由美化问题”

第二 解决了 “在IIS环境下,yii2web项目如果web目录下有多个应用的话,如何url路由美化的问题”。经过测试,如果我只配置(这个规则是导入web目录下的.htaaccess文件):

                 <rule name="已导入的规则 1">
                     <match url="^(.*)$" ignoreCase="false" />
                     <conditions logicalGrouping="MatchAll">
                         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                     </conditions>
                     <action type="Rewrite" url="index.php/{R:1}" />
                 </rule>

但是问题来了,我web下还有一个wechat目录,用于微网站的使用。在我的测试中,发现我们项目上使用的已经美化的url路径直接报错“404”,后面经过我们的调整,然后就把配置改成:

        <rewrite>
            <rules>
                <rule name="wechat">
                    <match url="^\/wechat\/(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/wechat/index.php/{R:1}" />
                </rule>
                 <rule name="已导入的规则 1">
                     <match url="^(.*)$" ignoreCase="false" />
                     <conditions logicalGrouping="MatchAll">
                         <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                     </conditions>
                     <action type="Rewrite" url="index.php/{R:1}" />
                 </rule>
            </rules>
        </rewrite>

如果把这两个规则换个位置的话,结果会发现微网站的美化地址又是404

我这里解释下原因:规则应该是从上往下配置,选择最优配置。

 

最后总结下:本文说明如何在IIS环境下配置php项目以及在iis优化yii2的url路由问题

 

/********************************************************2019年-06-02**********************************************************************************************************************************************************************/

哇,已经有两万的阅读了,看来iis还是很厉害的了。今天帮朋友处理window iis 管理php网站,又记住了几个常用的配置。于是乎,就上来更新下博客,便于后期操作。

1.文章上面的“处理程序映射”都是针对某个网站的配置的,其实更通用的方式是在

配置。同时我们可以配置多个php版本。

2.程序映射还可以使用脚本映射,对于脚本映射需要下载 php版本对应的isapi扩展,例如:php5isapi.dll,但是这个操作我个人不推荐使用,好像只有早期的版本可以支持。我在这里说明,是因为有可能会遇到有些老项目人家部署php时,是这么干的,就像今天我帮朋友处理一样,那上面有个项目就是这样干的

3.处理程序映射的时候,有个请求限制,可以将设置改为文件和文件夹

4.还可以下载phpmanager,用于管理php的配置

/********************************************************2019年-06-11*********************************************************************************************************************************************************************/

  今天更新一下phpManager的使用说明,

  问题:当安装一个php版本之后,我们试着添加一份php.ini[修改php.ini.production or php.ini.development],然后重启iis,然后运行项目【譬如:phpmyadmin】,这时你会发现,缺少扩展,可是你配置文件已经开启了扩展,那么问题出在哪呢?

  解答:

      1、其实windows 默认安装的话, Loaded Configuration File 即读取php.ini配置文件的路径。使用IIS,那就是一定要把 PHP.INI 放在 Windows 的系統路径下 (C:/WINDOWS 或 C:/WINNT) 。所以你修改你php所在目录下的配置文件是没有起到作用的,必须将文件复制到对应目录下 (参考:https://blog.csdn.net/letian003/article/details/5995856)。

      2、那么这个时候phpManager就派上用场了,我们可以在https://www.iis.net/downloads/community/2010/09/php-manager-for-iis-7 官网去下载对应iis版本的phpManager 

      3、下载完成,重启iis会发现phpManager在里面了,双击PHP Manager后,点击“Register new PHP Version”,然后选择好php目录中的php-cgi.exe,然后php.ini就会为适合IIS7.5的配置默认给你生成好了

 

 

 

  


---------------------
作者:yangboom
来源:CNBLOGS
原文:https://www.cnblogs.com/YangJieCheng/p/8119505.html
版权声明:本文为作者原创文章,转载请附上博文链接!

Guess you like

Origin www.cnblogs.com/admans/p/11109393.html