我有点问题。
我制作了两个虚拟主机" web-backend.local"和" oplossingen.web-backend.local"。
但我总是有一个" 500内部服务器错误"
我做错了什么?
主机文件:
private string _last;
private string GetNonRepeatedMovie()
{
string selected = "";
do
{
selected = movie[r.Next(0, movie.Length)].ToUpper();
}
while (selected == this._last);
this._last = selected;
return selected;
}
的httpd-vhosts.conf:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
# MAMP VirtualHost Mappings
127.0.0.1 web-backend.local
127.0.0.1 oplossingen.web-backend.local
答案 0 :(得分:1)
尽管已报告MAMP 500 Server Error
,但通常与MAMP无关。
500个内部服务器错误表明您的php页面崩溃了。解决方案是在潜在的崩溃页面中添加以下错误报告php代码:
// display php error
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
如果您使用jQuery.Ajax,那么恐怕上面action.php
中的代码将不起作用,还有另一种方法,其后是
index.html
或index.php
<div id="show-error" style="position: fixed; z-index: 10000; height: 20vh; width: 100vw; background:#f08080; border-radius:20px; opacity: 0.8; display: flex; font-size: 2rem; justify-content: center; align-items: center; display: none;"></div>
try{
// main
echo json_encode(['status' => 1, 'msg' => 'succeed']);
}catch(Exception $e){
echo json_encode(['status' => 0, 'msg' => $e->getMessage()]);
}
$.ajax({
url: '../php/action.php',
method: 'POST',
data: array('some data'),
}).done(function(result){
var output = JSON.parse(result);
if(output.status == 0){
$('#show-error').show();
$('#show-error').html(output.msg);
exit();
}else{
// no error occurred
}
});
答案 1 :(得分:0)
尝试查看您的apache日志和您的php日志。
答案 2 :(得分:-1)
从每个虚拟主机的httpd-vhosts.conf文件中删除以下行:
<Directory "/Users/yawuarsernadelgado/Documents/web-backend/cursus">
AllowOverride All
Require all granted
Options +Indexes
IndexOptions NameWidth=*
</Directory>
为我工作:D