AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[cakephp](server)

Martin Hope
Andreas Witte
Asked: 2016-09-03 01:21:19 +0800 CST

在 nginx 中生成 .css 文件

  • 0

我在 apache 上开发,现在我需要在 ngix 上部署,我遇到了一些困难。因为在我的项目中禁用了内联样式(使用 cakephp)并且在数据库中定义了一些颜色,所以我让 RsrcController 生成带有颜色的 css 到模板中。

仅当我不使用文件扩展名 .css 时调用此函数才有效,而仅使用带有控制器和函数的斜线 Url。

如果我附加以 .css 结尾的文件,则 nginx 将在 webroot 文件夹中搜索并返回 404。

这是配置的相关部分:

        location / {
            try_files $uri $uri/ /index.php?$args;
        }


        #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
           try_files $uri =404;
           include /etc/nginx/fastcgi_params;
           fastcgi_pass    127.0.0.1:9000;
           fastcgi_index   index.php;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

我试图找到一个添加另一个位置规则的解决方案,如下所示:

location ~ rsrc/css_vars/~.css {
    ... [->second part of my question]
}

我不想将所有 .css 文件传递​​给 php。只是那些我希望是动态生成的。无论如何,我的更改似乎不起作用。

第二部分:

Cakephp 的工作方式如下:http : //url.com/controller/function/var1/var2/varx 我的控制器是 rsrc。我的函数是 css_vars。比有一些变量(用户......),最后我需要“.css”。

我想将 URl 重写为相同但没有文件扩展名“.css”。有没有办法解决正则表达式?

nginx css cakephp mvc
  • 2 个回答
  • 324 Views
Martin Hope
luchomolina
Asked: 2012-07-17 16:07:00 +0800 CST

需要帮助将此 htaccess 重写规则转换为 Nginx

  • 0

嗨 - 我已经为此苦苦挣扎了好几天。这看起来很简单,但我就是做不到。

我有一个用 CakePHP 开发的站点。有一个响应脚本/css/profiles/g/whatever.css(“whatever”是什么,它实际上是传递给操作的参数),它回显生成的 CSS 并将其保存到/css/profiles/whatever.css.

我在 Apache 中有一个规则,它接受请求/css/profiles/whatever.css,如果不存在,则在/css/profiles/g/whatever.css不重定向的情况下重写请求,因此客户端永远不会注意到它是由脚本响应的,并且文件不存在。

这是我在 Apache 中的内容:

# Profile CSS rules
RewriteCond %{REQUEST_URI} ^/css/profiles/
RewriteCond %{REQUEST_URI} !/css/profiles/g/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^css/profiles/(.*)$ /css/profiles/g/$1 [L]

# CakePHP's default rules
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]

现在我正在将站点移动到带有 Nginx 的服务器,到目前为止我已经得到了这个:

# Profile CSS rules
location ~ ^/css/profiles/(?!g/)(.*)$ {
    if (!-f $request_filename) {
      rewrite ^/css/profiles/(.*)$ /css/profiles/g/$1 last;
      break;
    }

 }

# CakePHP's default rules
location / {

    try_files $uri $uri/ /index.php?$uri&$args; }

条件似乎有效,因为如果我去/css/profiles/whatever.css打印出 PHP 的$_SERVER变量,它会给我

[QUERY_STRING] => /css/profiles/g/whatever.css&

注意&. 这意味着它到达了try_files部分并将添加$uri到查询字符串中,并且它具有正确的$uri.

但...

[REQUEST_URI] => /css/profiles/whatever.css

这就是故障。它似乎并没有真正改变$request_uriCakePHP 需要控制哪个控制器参加什么。

任何帮助将不胜感激。

谢谢。

apache-2.2 .htaccess nginx cakephp
  • 1 个回答
  • 586 Views
Martin Hope
dole doug
Asked: 2010-03-23 00:32:29 +0800 CST

Godaddy 上的 .htaccess 时间

  • 2

我正在尝试在 godaddy linux 帐户上运行 cakephp 应用程序。问题是我收到错误 500。我在 cakephp 讨论组上读到我必须编辑 .htaccess 文件。

1) 我要等多久才能看到结果?
2)服务器错误日志中可能会提供有关此错误的更多信息。这些服务器在哪里登录 godaddy linux 托管帐户?

godaddy 500-error cakephp
  • 2 个回答
  • 2551 Views
Martin Hope
828
Asked: 2010-01-31 09:31:43 +0800 CST

从 (gs) 迁移到 Media Temple (dv) - 777 权限问题

  • 1

我刚刚将我的网站(基于 CakePHP 构建)从 Media Temple 的 (gs) 服务器迁移到 (dv)。我收到 /tmp/cache 文件夹不可写的错误。将权限更改为 777 可修复此错误 - 但它似乎不安全(这是真的吗?)。在 (gs) 上,我不必授予“所有人”的写入权限。所以看起来网络服务器既不是用户也不属于该组。

为什么服务器无法写入缓存文件,我怎样才能使 Web 服务器可以写入 tmp 文件夹而不将权限设置为 777?

apache-2.2 permissions cakephp mediatemple
  • 1 个回答
  • 818 Views
Martin Hope
Steven Smethurst
Asked: 2010-01-25 17:29:58 +0800 CST

Cakephp,App的文件夹不在webroot中,为什么?

  • 1

为什么将 CakePHP 文件存储在 webroot 之外?

例如,这是我一直被告知这样做的方式。

/home/username
  /app
  /cake
  /public_html
      index.php

我知道这是因为安全,但为什么呢?它不像用户可以查看 /app/ 文件夹中的文件。htaccess 阻止了正确的?

如果用户能够在我的网络服务器上获取恶意脚本,那么 /app/ 文件夹是在 /public_html/ 中还是在 webroot 之外都没有关系,他们仍然会更改 /app/ 文件夹下的文件,对吧?

那么为什么要打扰呢?

apache-2.2 .htaccess cakephp
  • 1 个回答
  • 1400 Views
Martin Hope
olive
Asked: 2010-01-23 10:28:05 +0800 CST

CakePHP 在使用 nginx 的子目录中(重写规则?)

  • 1

我设法让它工作了一段时间,但是在回到我开始的 cakephp 项目时,似乎我最近对 ​​nginx 所做的任何更改(或者可能是最近的更新)都违反了我的重写规则。

目前我有:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.php index.html index.htm;
        }

        location /basic_cake/ {
            index  index.php;

            if (-f $request_filename) {
              break;
            }
            if (!-f $request_filename) {
              rewrite ^/basic_cake/(.+)$ /basic_cake/index.php?url=$1 last;
              break;
            }
        }

        location /cake_test/ {
            index  index.php;

            if (-f $request_filename) {
              break;
            }
            if (!-f $request_filename) {
              rewrite ^/cake_test/(.+)$ /cake_test/index.php?url=$1 last;
              break;
            }
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

    }

    server {
        listen       8081;
        server_name  localhost;

        root /srv/http/html/xsp;

        location / {
            index  index.html index.htm index.aspx default.aspx;
        }

        location ~ \.(aspx|asmx|ashx|asax|ascx|soap|rem|axd|cs|config|dll)$ {
            fastcgi_pass   127.0.0.1:9001;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

    }

}

我遇到的问题是 CSS 和图像不会从 webroot 加载。相反,如果我访问http://localhost/basic_cake/css/cake.generic.css,我会得到一个页面,告诉我:

CakePHP:快速开发的 php 框架 Missing Controller

错误:找不到 CssController。

错误:在以下文件中创建类 CssController:app/controllers/css_controller.php

注意:如果要自定义这个错误信息,创建app/views/errors/missing_controller.ctp CakePHP:快速开发php框架

有人对如何解决这个问题有任何想法吗?

rewrite nginx cakephp
  • 2 个回答
  • 4972 Views
Martin Hope
seanl
Asked: 2009-06-27 01:15:44 +0800 CST

cakephp & nginx 配置/重写规则

  • 3

嗨,有人请帮帮我,我也在 stackoverflow 上问过这个问题,但没有得到太多回应,并且正在争论它是编程还是服务器相关。

我正在尝试在使用 Fact CGI 运行 Nginx 的 Centos 服务器上设置 cakephp 环境。我已经在服务器上运行了一个 wordpress 站点和一个 phpmyadmin 站点,所以我正确配置了 PHP。

我的问题是我无法在我的虚拟主机中正确设置重写规则,以便蛋糕正确呈现页面,即样式等。我已经尽可能多地在谷歌上搜索,下面列出的网站的主要共识是我需要制定以下重写规则

location / {
  root /var/www/sites/somedomain.com/current;
  index index.php index.html;

  # If the file exists as a static file serve it 
  # directly without running all
  # the other rewrite tests on it
  if (-f $request_filename) { 
    break; 
  }
  if (!-f $request_filename) {
    rewrite ^/(.+)$ /index.php?url=$1 last;
    break;
  }
}

http://blog.getintheloop.eu/2008/4/17/nginx-engine-x-rewrite-rules-for-cakephp

问题是这些重写假设你直接从 webroot 中运行 cake,这不是我想要做的。我对每个站点都有一个标准设置,即每个站点一个文件夹,其中包含以下文件夹日志、备份、私人和公共。公共场所 nginx 正在寻找其要服务的文件,但我私下安装了蛋糕,并在公共链接回 /private/cake/ 的符号链接

这是我的虚拟主机

server {
    listen 80;
    server_name app.domain.com;

    access_log /home/public_html/app.domain.com/log/access.log;
    error_log /home/public_html/app.domain.com/log/error.log;

    #configure Cake app to run in a sub-directory
    #Cake install is not in root, but elsewhere and configured
    #in APP/webroot/index.php**

    location /home/public_html/app.domain.com/private/cake {
        index index.php;

        if (!-e $request_filename) {
            rewrite ^/(.+)$ /home/public_html/app.domain.com/private/cake/$1 last;
            break;
        }

    }

    location /home/public_html/app.domain.com/private/cake/ {
        index index.php;

        if (!-e $request_filename) {
            rewrite ^/(.+)$ /home/public_html/app.domain.com/public/index.php?url=$1 last;
            break;
        }

    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME /home/public_html/app.domain.com/private/cake$fastcgi_script_name;
        include        /etc/nginx/fastcgi_params;
    }

}

现在就像我说的那样,我可以看到 cake 的主要 index.php 并将其连接到我的数据库,但是这个页面没有样式,所以在我继续之前,我想正确配置它。我究竟做错了什么………。

谢谢海尔

centos php nginx cakephp
  • 3 个回答
  • 9777 Views
Martin Hope
Tom Wright
Asked: 2009-06-11 04:24:38 +0800 CST

按文件名删除所有文件(Linux 单行)

  • 2

CakePHP 有一个约定,将名为“empty”的文件放在空目录中。我敢肯定他们是有原因的,但这真的让我很烦恼。(是的,强迫症,我知道……)

我想要一个单行 linux shell 命令,它将删除每个后代目录中名为“empty”的每个文件。(我想能够为更一般的用途指定通配符也会很有用。)

有任何想法吗?

linux scripting cakephp
  • 4 个回答
  • 1848 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve