<tfoot id='6F4Ai'></tfoot>
  1. <legend id='6F4Ai'><style id='6F4Ai'><dir id='6F4Ai'><q id='6F4Ai'></q></dir></style></legend>
    • <bdo id='6F4Ai'></bdo><ul id='6F4Ai'></ul>

      <small id='6F4Ai'></small><noframes id='6F4Ai'>

    1. <i id='6F4Ai'><tr id='6F4Ai'><dt id='6F4Ai'><q id='6F4Ai'><span id='6F4Ai'><b id='6F4Ai'><form id='6F4Ai'><ins id='6F4Ai'></ins><ul id='6F4Ai'></ul><sub id='6F4Ai'></sub></form><legend id='6F4Ai'></legend><bdo id='6F4Ai'><pre id='6F4Ai'><center id='6F4Ai'></center></pre></bdo></b><th id='6F4Ai'></th></span></q></dt></tr></i><div id='6F4Ai'><tfoot id='6F4Ai'></tfoot><dl id='6F4Ai'><fieldset id='6F4Ai'></fieldset></dl></div>

      如何配置 nginx 重写规则以使 CakePHP 在 CentOS 上运行?

      How do I configure nginx rewrite rules to get CakePHP working on CentOS?(如何配置 nginx 重写规则以使 CakePHP 在 CentOS 上运行?)

        <tbody id='wzcp8'></tbody>
        <i id='wzcp8'><tr id='wzcp8'><dt id='wzcp8'><q id='wzcp8'><span id='wzcp8'><b id='wzcp8'><form id='wzcp8'><ins id='wzcp8'></ins><ul id='wzcp8'></ul><sub id='wzcp8'></sub></form><legend id='wzcp8'></legend><bdo id='wzcp8'><pre id='wzcp8'><center id='wzcp8'></center></pre></bdo></b><th id='wzcp8'></th></span></q></dt></tr></i><div id='wzcp8'><tfoot id='wzcp8'></tfoot><dl id='wzcp8'><fieldset id='wzcp8'></fieldset></dl></div>
          <bdo id='wzcp8'></bdo><ul id='wzcp8'></ul>
        • <tfoot id='wzcp8'></tfoot>

              <legend id='wzcp8'><style id='wzcp8'><dir id='wzcp8'><q id='wzcp8'></q></dir></style></legend>

              <small id='wzcp8'></small><noframes id='wzcp8'>

              1. 本文介绍了如何配置 nginx 重写规则以使 CakePHP 在 CentOS 上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

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

                Hi somebody please help me out, I’m trying to setup a cakephp environment on a Centos server running Nginx with Fact CGI. I already have a wordpress site running on the server and a phpmyadmin site so I have PHP configured correctly.

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

                My problem is that I cannot get the rewrite rules setup correct in my vhost so that cake renders pages correctly i.e. with styling and so on. I’ve googled as much as possible and the main consensus from the sites like the one listed below is that I need to have the following rewrite rule in place

                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/时有一个符号链接

                problem is these rewrite assume you run cake directly out of the webroot which is not what I want to do. I have a standard setup for each site i.e. one folder per site containing the following folders log, backup, private and public. Public being where nginx is looking for its files to serve but I have cake installed in private with a symlink in public linking back to /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;
                        }
                
                 }
                

                现在就像我说的,我可以看到蛋糕的主要 index.php 并将其连接到我的数据库,但此页面没有样式,所以在我继续之前,我想正确配置它.我做错了什么?

                Now like I said I can see the main index.php of cake and have connected it to my DB but this page is without styling so before I proceed any further I would like to configure it correctly. What am I doing wrong?

                谢谢肖恩

                推荐答案

                乍一看,您的问题可能是您没有将 nginx 指向应用程序的 webroot.部署到 cake 根文件夹真的不是任何 web 服务器下的方式.

                At a glance, your problem might be that you are not pointing nginx to the webroot of your app. Deploying to the root cake folder is really not the way to go under any web-server.

                以下是我用来运行 Cake 应用程序的完整服务器块.实际上,我只有前四行,然后从单独的文件cakephp.inc"中包含其余行.

                The following is a complete server-block I use running Cake apps. In reality I only have the first four lines and then include the rest from a separate file "cakephp.inc".

                关于fastcgi_param SERVER_NAME $host;"行的注释.这是因为我的一些应用程序使用 $_SERVER['SERVER_NAME'] 并且它在 nginx 中的含义与在 Apache 中的含义不同.如果你的服务器定义了多个 server_name(s),nginx 将始终将第一个传递给 php.

                A note on the line "fastcgi_param SERVER_NAME $host;". This is because some of my apps use $_SERVER['SERVER_NAME'] and it does not have the same meaning in nginx as in Apache. If youe server has several server_name(s) defined nginx will always pass the first one to php.

                server { 
                    server_name  cakeapp.example.com;
                    root   /var/www/vhosts/cake/app/webroot;
                    access_log  /var/log/nginx/cakeapp.access.log;
                    error_log   /var/log/nginx/cakeapp.error.log;
                
                    listen       80;
                    rewrite_log on;
                
                    # rewrite rules for cakephp
                    location / {
                        index  index.php index.html;
                
                        # If the file exists as a static file serve it 
                        # directly without running all
                        # the other rewite tests on it
                        if (-f $request_filename) { 
                            break; 
                        }
                        if (!-f $request_filename) {
                            rewrite ^/(.+)$ /index.php?url=$1 last;
                            break;
                        }
                    }
                
                    location ~* favicon.ico$ {
                        expires 6m;
                    }
                    location ~ ^/img/ { 
                        expires 7d; 
                    } 
                
                    location ~ .php$ {
                        fastcgi_pass 127.0.0.1:9000;
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        include /etc/nginx/fastcgi_params;
                        fastcgi_param SERVER_NAME $host;
                    }
                
                    location ~ /.ht {
                        deny  all;
                    }
                }
                

                这篇关于如何配置 nginx 重写规则以使 CakePHP 在 CentOS 上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  • <bdo id='poAqp'></bdo><ul id='poAqp'></ul>
                    <legend id='poAqp'><style id='poAqp'><dir id='poAqp'><q id='poAqp'></q></dir></style></legend>

                      <small id='poAqp'></small><noframes id='poAqp'>

                        <tbody id='poAqp'></tbody>
                      <i id='poAqp'><tr id='poAqp'><dt id='poAqp'><q id='poAqp'><span id='poAqp'><b id='poAqp'><form id='poAqp'><ins id='poAqp'></ins><ul id='poAqp'></ul><sub id='poAqp'></sub></form><legend id='poAqp'></legend><bdo id='poAqp'><pre id='poAqp'><center id='poAqp'></center></pre></bdo></b><th id='poAqp'></th></span></q></dt></tr></i><div id='poAqp'><tfoot id='poAqp'></tfoot><dl id='poAqp'><fieldset id='poAqp'></fieldset></dl></div>

                          <tfoot id='poAqp'></tfoot>