简体   繁体   English

在 Apache 服务器中的 Codeigniter 上获取 503 服务不可用

[英]Getting 503 Service Unavailable on Codeigniter in Apache Server

I am working with Codeigniter 3 on an Apache server (XAMPP) and I have a problem on my live server (CentOS).我正在 Apache 服务器 (XAMPP) 上使用 Codeigniter 3,我的实时服务器 (CentOS) 出现问题。 When I try to load a new view, no problem occurs.当我尝试加载新视图时,没有出现问题。 But when I try to load a new view multiple times (like 5 times) before the old view finishes loading, the server crashes and gives me a 503 error.但是,当我在旧视图完成加载之前尝试多次(如 5 次)加载新视图时,服务器崩溃并给我一个 503 错误。

We discovered this error when a user tried to use the navigation menu and seeing that the page was slow to load, because the database is slow, he quickly tried to load a new page.当用户尝试使用导航菜单并看到页面加载缓慢时,我们发现了这个错误,因为数据库很慢,他很快尝试加载新页面。

This error occurs in all views, no matter how simple or complex they are.此错误发生在所有视图中,无论它们多么简单或复杂。

Here is an example of a view that generate the error.这是生成错误的视图示例。

<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Example_controller extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('example_model');
        $this->load->helper('form');
        $this->load->library('form_validation');
        $this->load->library('session');
        $this->load->helper('url');
    }

    public function index()
    {
        $data['information'] = $this->example_model->get_data();

        $this->load->view('header');
        $this->load->view('body', $data);
        $this->load->view('footer');
    }
}

In this example, the database function is a very simple Select query.在这个例子中,数据库 function 是一个非常简单的 Select 查询。 I'm using Oracle SQL database.我正在使用 Oracle SQL 数据库。

I also tried to change the .htaccess file to allow more time to timeout server but that didn't work.我还尝试更改 .htaccess 文件以允许更多时间使服务器超时,但这没有用。

This is my current .htaccess file:这是我当前的 .htaccess 文件:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

I have been looking for an answer for a long time, I will be very grateful for any help you can give me.我一直在寻找答案很长时间,我将非常感谢您能给我的任何帮助。 Thanks in advance.提前致谢。

I think you can't set the 503 HTTP Status using the redirect() function that CI provides.我认为您无法使用 CI 提供的 redirect() function 设置 503 HTTP 状态。 But you can set the 301 code (temporal redirection), which means that the search engine will know that your page is temporally redirected and it will not index the maintenance page.但是你可以设置301代码(临时重定向),这意味着搜索引擎会知道你的页面是临时重定向的,它不会索引维护页面。

More info here 更多信息在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM