简体   繁体   English

在Google Cloud中的centos上运行的Code Igniter上的内部服务器错误500

[英]Internal Server Error 500 on Code Igniter running on centos in Google Cloud

I'm running a CI based web application that runs fine on its old server but I'm migrating it to a centos 7/cwp instance on google cloud. 我正在运行一个基于CI的Web应用程序,该应用程序可以在其旧服务器上正常运行,但是我正在将其迁移到Google云上的centos 7 / cwp实例。

After i set it up how i normally setup CI, im getting HTTP 500 and Internal Server Errors. 设置好之后,我通常如何设置CI,即收到HTTP 500和内部服务器错误。

I'm suspecting its got to do with the .htacess but i cant figure out whats wrong. 我怀疑它与.htacess有关,但我不知道出了什么问题。 Any help is appreciated! 任何帮助表示赞赏!

Its running CWP on centos 7 on a google cloud instance. 它在Google云实例上的centos 7上运行的CWP。 Things i have done: 我所做的事情:

  1. enabled mod_rewrite 启用mod_rewrite
  2. installed php-mysqli 安装了php-mysqli
  3. edited php.ini for mysql and mysqli extensions 编辑了用于mysql和mysqli扩展的php.ini
  4. made a new .htaccess 做了一个新的.htaccess
  5. can't seem to see any error in the apache logs 在apache日志中似乎看不到任何错误

Below is my current .htaccess file from the old server: 以下是旧服务器上我当前的.htaccess文件:

# 301 Redirect URLs.
Redirect 301 /www.example.com/example/about-us https://www.example.com/home/pages/about-us

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

//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 . index.php
RewriteCond %{HTTPS} off
//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://%{HTTP_HOST}%{REQUEST_URI}

</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

<Files 403.shtml>
order allow,deny
allow from all
</Files>

RewriteCond %{HTTP_HOST} ^\*\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.\*\.example\.com$
//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\:\/\/www\.example\.com" [R=301,L]

RewriteCond %{HTTP_HOST} ^example.com$
//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\:\/\/www\.example\.com\/" [R=301,L]

When i used the above .htaccess (with // the old cpanel modrewrites, i get internal server error message), when i delete the .htaccess or replace the .htaccess with other or standard CI .htaccess, i just get HTTP 500 error. 当我使用上述.htaccess(与//旧的cpanel modrewrites一起使用时,我会收到内部服务器错误消息),当我删除.htaccess或将.htaccess替换为其他或标准CI .htaccess时,我只会得到HTTP 500错误。

with // the old cpanel modrewrites, i get internal server error message 与//旧的cpanel modrewrites,我收到内部服务器错误消息

You can't use // to comment out config lines in .htaccess - that certainly explains your immediate 500 error. 您不能使用//注释掉.htaccess配置行-这肯定可以解释您的即时500错误。 You need to use # , as shown on the first line of your config file. 您需要使用# ,如配置文件第一行所示。

 //RewriteRule . index.php 

You shouldn't be commenting out this line - without this CI will not be able to route your URLs. 您不应该对此行进行注释-如果没有此配置项,将无法路由您的URL。

when i delete the .htaccess or replace the .htaccess with other or standard CI .htaccess, i just get HTTP 500 error. 当我删除.htaccess或将其替换为其他或标准CI .htaccess时,我只会收到HTTP 500错误。

That is quite possibly a different question, so we would need to see the precise .htaccess file you are using. 那可能是一个不同的问题,因此我们需要查看您正在使用的精确的.htaccess文件。

Btw, "internal server error" and "HTTP 500 error" are the same thing - you seem to be implying they are different? 顺便说一句,“内部服务器错误”和“ HTTP 500错误”是同一回事-您似乎暗示它们是不同的?

As noted in comments, you should check your server's error log for the specifics of this error. 如注释中所述,您应检查服务器的错误日志以获取此错误的详细信息。

 RewriteCond %{HTTP_HOST} ^\\*\\.example\\.com$ [OR] RewriteCond %{HTTP_HOST} ^www\\.\\*\\.example\\.com$ //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\\:\\/\\/www\\.example\\.com" [R=301,L] 

What is this supposed to be doing? 这应该在做什么? (It doesn't do anything in its current state.) (它在当前状态下不做任何事情。)

 RewriteCond %{HTTP_HOST} ^example.com$ //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\\:\\/\\/www\\.example\\.com\\/" [R=301,L] 

This only canonicalises requests for the document root. 这仅规范了对文档根目录的请求。 It won't do anything for any other URLs. 它不会对任何其他URL做任何事情。 However, it's also in the wrong place in the config file and probably isn't doing anything anyway. 但是,它也位于配置文件中的错误位置,并且可能仍未执行任何操作。 It needs to go at the top of the file, before the CI front-controller. 它需要放在文件的顶部,在CI前控制器之前。

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

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