【问题标题】:Cpanel setting up cakephp 2.6.3Cpanel 设置 cakephp 2.6.3
【发布时间】:2021-02-13 12:34:45
【问题描述】:

我的任务是将在 aws 上运行的旧项目迁移到基于 vps 的 cpanel,我做了以下工作:

  • 设置为 cpanel 以接受(仅)php 5.6 及其扩展,还设置导出的数据库及其所需文件的凭据。
  • 项目的路径直接在public_html/文件夹中设置
  • .htaccess 文件配置如下:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^$ app/webroot/ [L]
</IfModule>

我从 cakephp 安装文档中获取并添加了一些 - Link

然而,原始项目 htaccess 有点不同:

<IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} example\.com [NC]
    RewriteCond %{SERVER_PORT} 80
    
    php_value max_input_vars 100000

    RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
    
    
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule (.*) app/webroot/$1 [L]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^$ app/webroot/ [L]

</IfModule>

& 删除 htaccess 或在两个项目中根本不使用它会产生相同的错误

Warning (2): scandir(../View/Ipac): failed to open dir: No such file or directory [APP/Config/routes.php, line 32]
Warning (2): scandir() [function.scandir]: (errno 2): No such file or directory [APP/Config/routes.php, line 32]
Warning (2): Invalid argument supplied for foreach() [APP/Config/routes.php, line 32]

我尝试在新迁移中使用相同的 htaccess 以及所有其他对我来说“似乎”没问题的规则,但它显示了内部服务器错误。现在我被困在这里了

Internal Server Error 服务器遇到内部错误或 配置错误,无法完成您的请求。请 通过 webmaster@example.com 联系服务器管理员通知 他们发生此错误的时间以及您执行的操作 就在这个错误之前。

服务器错误日志中可能会提供有关此错误的更多信息。

此外,在尝试使用 ErrorDocument 处理请求时遇到 500 Internal Server Error 错误。有谁知道我该如何解决这个问题。任何帮助表示赞赏。

【问题讨论】:

  • 您能否详细说明“项目的路径直接在public_html/ 文件夹上设置”是什么意思?显示一下您在那里设置的文件夹结构?

标签: .htaccess cakephp cakephp-2.6


【解决方案1】:

好的,事实证明,在我对此失去理智 2 天后,问题是由于 app/webroot 中的 htaccess 设置不正确(我错过了),而且它的索引文件的文件权限为 775 ,其中cpanel不允许公开查看,设置正确启动项目完美。

【讨论】:

    猜你喜欢
    • 2018-02-20
    • 2011-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    • 2020-05-20
    • 2016-12-26
    相关资源
    最近更新 更多