laravel和Apache mod_status

时间:2018-07-08 22:10:06

标签: php laravel apache laravel-5.2

我已在服务器上启用Apache mod_status:

OS: centos 6
Server version: Apache/2.2.15 (Unix)
php version 7.1

我收到 example.com/server-status 的404错误页面,因为我不知道如何使用laravel(5.2)路由api或任何其他方式来维护此路由?
我在httpd.conf中的配置:

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1 ::1
    Allow from .example.com
    Allow from xxx.xxx.xxx.xxx #my ip address
</Location>

和.htaccess中的

RewriteCond %{REQUEST_URI} !=/server-status

2 个答案:

答案 0 :(得分:0)

尝试将其放置在virtualhost标签内

      var xhr = new XMLHttpRequest();
    xhr.open("POST", '../blogs/wp-content/themes/Divi/KISSmetrics/KM.php', true);

//Send the proper header information along with the request
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

xhr.onreadystatechange = function() {//Call a function when the state changes.
    if(this.readyState == XMLHttpRequest.DONE && this.status == 200) {
        //console.log('kissmetrics');
    }
}
xhr.send("properties="+JSON.stringify(properties)+"&kmAttr="+JSON.stringify(kmAttr)); 
PHP Code:(KM.php)
<?php
header("Content-Type: application/json; charset=UTF-8");
// Include dependencies classes for easy include
require_once( dirname(__FILE__).'/Client.php' );
require_once( dirname(__FILE__).'/ClientException.php' );
require_once( dirname(__FILE__).'/Transport/Transport.php' );
require_once( dirname(__FILE__).'/Transport/TransportException.php' );
require_once( dirname(__FILE__).'/Transport/Sockets.php' );
require_once( dirname(__FILE__).'/Transport/Delayed.php' );
require_once( dirname(__FILE__).'/Transport/Mock.php' );

$km = new KISSmetrics\Client('apiKey', KISSmetrics\Transport\Sockets::initDefault());

$recordEventProperties=json_decode($_POST["properties"],true);
$recordKMAttr=json_decode($_POST["kmAttr"],true);

 /*$km->identify($recordKMAttr["identity"])   // Identify user (always)
  ->record($recordKMAttr["eventname"],$recordEventProperties);     
 */// Record an event with properties
 $km->identify('bob@example.com')->set(array('gender' => 'male')); // Set a property
    var_dump($km);
 $km->submit();

?>

答案 1 :(得分:0)

我在对服务器信息和服务器状态的.htaccess上使用以下代码:

RewriteRule ^(server-info|server-status) - [L]

确保首先使服务器信息和服务器状态正常运行。 他们,阅读有关权限问题的日志(主要是由于规则的顺序)。

我的系统:

  • Laravel 6
  • Apache 2.4.1
  • FreeBSD 12.1