ubuntu - 在 Nginx : 上运行 Siremis web

标签 ubuntu nginx kamailio

我正在尝试在运行 Nginx 的 Ubuntu 14.04 上部署 Siremis 4.1 ( http://siremis.asipto.com/2014/03/25/siremis-v4-1-0-released/ )。网上关于在 Nginx 上运行 Siremis 的信息很少。我已经正确安装了所有东西(我认为),但是我在 Nginx 配置方面遇到了问题,无法正确提供页面。

我几乎可以肯定问题出在 URL 重写中。我可以去这个页面没问题:

域/siremis/index.php/user/login

但是之后我通过这个 URL 得到 Page Not Found:

DOMAIN/siremis/system/general_default

这让我想起了 WordPress 的永久链接,由于他们出色的文档,我能够解决很少的问题:http://codex.wordpress.org/Nginx

但是,Siremis 是另一回事。我不确定 Siremis 是否不支持使用 Nginx,因为它在执行重定向或什么时需要 Apache。只是想知道是否有人有任何建议。显然,我是 Nginx 的新手。或者,如果有人知道如何在 Siremis 中关闭重定向,那也很好!我不需要“漂亮”的网址。

这是我的服务器配置:

server {
        listen 80;
        listen [::]:80;

        charset utf-8;
        access_log /var/log/nginx/siremis.access.log;
        error_log /var/log/nginx/siremis.error.log;

        root /usr/share/nginx/html/siremis-4.1.0;
        index index.php;

        server_name sip1.<<DOMAIN>>;

        location /siremis
        #location ~^/siremis(.+)$
        {
                try_files $uri $uri/ /siremis/index.php?$1;
        }

        location ~ .*\.(php|php5)?$
        {
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html
        {
                root /usr/share/nginx/html;
        }
}

最佳答案

下面的 nginx 配置应该让你工作;问题是与 siremis tarball 一起打包的框架会返回一个 uri,该 uri 最终会像/siremis/siremis/system/general_settings 一样返回……找不到。

下面的配置将错误重定向到正确的 uri;问题是,使用此配置,您的错误仍将被记录;您可以忽略它们或关闭指令 log_not_found;

您可能遇到的另一个问题是某些基于 mozilla 的浏览器。他们对内容类型的 header 非常严格,因此您应该在必要的位置使用包含的文件 contHandlers.conf 设置 header ,否则您可能会在加载 css、js、gifs favicon ....etc 时遇到错误...您需要nginx-extra 或 nginx-full 包或使用 more_set_headers 模块编译它

在可用站点中,您的站点配置是:

server {
        listen 80;

        listen [::]:80;

        charset utf-8;
        access_log /var/log/nginx/siremis.access.log;
        error_log /var/log/nginx/siremis.error.log;

        root /usr/share/nginx/html/siremis-4.1.0;
        index index.php;

        server_name sip1.<<DOMAIN>>;

    include /etc/nginx/mime.types;

        error_page 404 = @router;
    location @router {
        if ( $uri ~* (^/siremis)(.*)$ ){
        set $val1 $1 ;
        set $val2 $2;
        rewrite .*  $val1/index.php$val2 redirect;
        }
# remove or create this file if you want to make your own error pages
    rewrite .*  /siremis/errTest.html last;    
    internal ;
    }

# this block will redirect you to siremis root 
    location =/ {
    rewrite .*  /siremis redirect;    
    }

    location /siremis {
    include /etc/nginx/inc/contHandlers.conf;
    }


# remove the install block after you installed
    location /siremis/install {
    include /etc/nginx/inc/contHandlers.conf;

    }


    location ~^(.+\.php)(.*)$ {
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    include /etc/nginx/fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME $request_filename;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    }


    location = /favicon.ico {
      log_not_found off;
     access_log off;
        try_files /siremis/favicon.ico =200;  
    }

}


#the include /etc/nginx/inc/contHandlers.conf;(this can probably be simplified..some params are commented

    if ($uri ~* (?=\.(gif|jpg|jpeg|png))) {
    more_set_headers  'Cache-Control:private, must-revalidate, max-age=144000s'; 
    break;
    }

    if ($uri ~* (?=\.css)){
    more_set_headers  'Content-Type:text/css' 'Cache-Control: private, must-revalidate, max-age=144000s';
    #more_set_headers 'Expires: 7200s';
    break;

}

    if ($uri ~* (?=\.js)){
    more_set_headers  'Content-Type:text/javascript' 'Cache-Control: private, must-revalidate, max-age=144000s'; 
    #expires 72000s;
    break;

    }

    if ($uri ~* (?=\.gif)) {
    more_set_headers  'Content-Type:image/gif' 'Cache-Control: private, must-revalidate, max-age=144000s';
    break; 
    }

    if ($uri ~* (?=\.(jpg|jpeg))) {
    more_set_headers 'Content-Type:image/jpeg' 'Cache-Control: private, must-revalidate, max-age=144000s';
    break; 
}

    if ($uri ~* (?=\.png)) {
    more_set_headers 'Content-Type:image/png' 'Cache-Control: private, must-revalidate, max-age=144000s';
    break; 
}

关于ubuntu - 在 Nginx : 上运行 Siremis web,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23599774/

相关文章:

c - 在 linux 中通过 C 访问 excel 表

c# - 在 Ubuntu 中读取 pfx 证书以创建 X509

Nginx 将无法启动(地址已被使用)

在 Kamailio 上安装 MySQL

mysql - Kamailio安装

python - 使用 sudo 在 Python 3.6 中导入错误?

linux - CentOS/Nginx 服务器无法运行,正在托管 Node 应用程序

caching - 具有可变参数顺序的 Nginx 缓存

sip - 如何在kamailio中配置测试用户?

linux - 'keystone user-list' 时出错