我有一个托管网站,我在配置Joomla时遇到了麻烦(在IIS7 + win server 2008上运行Joomla + php + mySQL)。我在本地机器上运行了类似的配置(IIS7 + vista x64上的Joomla + php + mySQL),所以我至少能够按照各种教程中的说明来设置如何设置它。

托管网站的这种症状是我无法打开Joomla中的任何SEO设置(甚至不是第一个设置,<!>“搜索引擎友好URL <!>”;)。我得到404(文件未找到)或URL显示正确重写但它始终显示主页的内容。我的家用机器上有类似的问题,原来是因为我没有使用FastCGI来托管php,所以我决定在托管网站上进行调查。

无论如何,我注意到在托管网站上托管joomla的目录的web.config文件中有以下行:

<add name="Plesk_Handler_3522909676" path="*.php" verb="*" modules="IsapiModule" scriptProcessor="c:\program files (x86)\parallels\plesk\additional\pleskphp5\php5isapi.dll" resourceType="Either" />

根据以往的经验,我知道php在fastCGI下运行时有一些问题。我注意到根文件夹中的web.config使用了以下行:

<add name="Plesk_Handler_0286090609" path="*.php" verb="*" modules="CgiModule" scriptProcessor="c:\program files (x86)\parallels\plesk\additional\pleskphp5\php-cgi.exe" resourceType="Either" /> 

我将它复制到joomla目录中的web.config中,并得到了不同的行为......但仍然无法正常工作。如果我在运行phpInfo()的joomla目录中加载.php文件,则在Server API下它会显示CGI / FastCGI。是否正在使用FastCGI 肯定确认?为什么Web配置中的处理程序指向modules = <!>“; CgiModule <!>”;而不是modules = <!> quot; FastCgiModule <!> quot; (我甚至不确定是否存在,但我发现提到CgiModule是可疑的。)

这是一个托管网站,据我所知,我无法访问ApplicationHost.config文件......

有帮助吗?

解决方案

这是一个简单的测试:

  1. 使用
  2. 创建phpinfo.php文件

     <?php phpinfo(); ?> 
    

    内;

    1. 请求 http://yoursite.com/phpinfo.php/foobar?富=栏

    2. 检查phpinfo的输出并查找_SERVER [<!> quot; REQUEST_URI <!> quot;]。

    3. 如果缺少此变量,则使用CGI。如果变量存在并正确设置为/phpinfo.php/foobar?foo=bar,则使用ISAPI或FastCGI。查看Server API输出顶部附近;它应该设置为ISAPI(这意味着使用ISAPI)或CGI / FastCGI(这意味着正在使用FastCGI,因为我们已经排除了CGI)。

其他提示

您可以使用(在centos上)apachectl -M,您将显示启用了哪些模块:

apachectl -M:

file_cache_module(共享) mem_cache_module(共享) version_module(共享) fastcgi_module(共享)

不幸的是,检查\_SERVER["REQUEST_URI"]对我不起作用。使用 CGI FastCGI ,它始终显示/phpinfo.php/foobar?foo=bar

既没有看到Server API = CGI/FastCGI被设置 - 也只是告诉你php的编译版本支持哪些接口,而不是正在使用的接口。但是,我发现了另一种可以更可靠地工作的方法。

plonk一个名为 phpinfo.php 的文件,其中包含以下文字:<? php phpinfo(); ?>

检查变量\_ENV["REDIRECT_HANDLER"]
如果将其设置为php5-fastcgi(或其他类似fastcgi-ish),请求最有可能通过 FastCGI 。如果设置为application/x-httpd-php(或我假设不是上述内容),则使用 CGI

然而,一种可靠的方法是通过运行一点测试。你需要ab(Apache Bench)工具。
有和没有CGI,从另一台机器运行:

ab -c 100 -n 1000 http://yourdomain.com/path/phpinfo.php

检查Time taken for tests:行。至少在我的盒子上,通过1.3Mbps的ADSL连接访问我的VPS,FastCGI完全最大化了它,而CGI只能填充其中的一半。

希望这有帮助。

php_sapi_name()或PHP_SAPI都可以。

http://php.net/manual/en/function .PHP-SAPI-name.php

<?php
    if (php_sapi_name() != 'cgi-fcgi'){
        echo 'I knew fastcgi wasn\'t working.';
    }else{
        echo 'Holy crap, something worked for once.';
    }

Joomla创建了一个带有重写规则的.htaccess文件,以启用搜索引擎友好的URL。如果您正在使用Apache,则需要设置<!>“; AllowOverride FileInfo <!>”;对于包含joomla安装的目录。如果您使用的是IIS,则需要一个模块,例如IISModRewrite。以下是对此的说明:[ http://www.micronovae.com/ModRewrite/物品/ SEFJoomla.html]

你应该看到从

引用它
<?php
phpinfo();
?>

服务器API = CGI / FastCGI

确保在fastcgi未运行时,事情最初设置为脚本完全失败的位置。然后你会知道,当它工作时,fastcgi守护进程就是原因。

这对我有用。

/**
 * return phpinfo() results as an array
 *
 * @credit http://php.net/manual/en/function.phpinfo.php#106862
 * @param void
 * @return array
 */
function phpinfo_array(){
    ob_start();
    phpinfo();
    $info_arr = array();
    $info_lines = explode("\n", strip_tags(ob_get_clean(), '<tr><td><h2>'));
    $cat = 'general';
    foreach($info_lines as $line){
        preg_match('/<h2>(.*)<\/h2>/', $line, $title) ? $cat = preg_replace('/\s+/', '_', strtolower(trim($title[1]))) : null;
        if(preg_match('/<tr><td[^>]+>([^<]*)<\/td><td[^>]+>([^<]*)<\/td><\/tr>/', $line, $val)){
            $subcat = preg_replace('/\s+/', '_', strtolower(trim($val[1])));
            $info_arr[$cat][$subcat] = $val[2];
        } elseif(preg_match('/<tr><td[^>]+>([^<]*)<\/td><td[^>]+>([^<]*)<\/td><td[^>]+>([^<]*)<\/td><\/tr>/', $line, $val)){
            $subcat = preg_replace('/\s+/', '_', strtolower(trim($val[1])));
            $info_arr[$cat][$subcat] = array('local' => $val[2], 'master' => $val[3]);
        }
    }
    return $info_arr;
}


// output proper response code
$phpinfo = phpinfo_array();
$configure = (@isset($phpinfo['general']['configure_command'])) ?: null;

// properly account for FastCGI
if ($configure && preg_match('/--enable-fastcgi/', $configure)){
    // fastcgi response
    header('Status: 403 Access is forbidden');
} else {
    // http response
    header('HTTP/1.0 403 Access is forbidden');
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top