How to fix '500 internal server error' while running php

My site having 4-5 static pages only. index.html & index.php both are there. index.html is working fine. If I change to index.php, it"s giving 500 Internal Server Error. I don"t know where is my mistake?

Note: If I use .htaccess file with php_flag display_errors 1,

It"s showing Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to lớn handle the request.

Bạn đang xem: How to fix '500 internal server error' while running php

If I use .htaccess tệp tin with empty,

It"s showing Additionally, a 404 Not Found error was encountered while trying to lớn use an ErrorDocument khổng lồ handle the request.

And if I give ../contact-us.php, it"s showing correctly.

Thanks...


php html apabít internal-server-error
Share
Follow
edited Nov 17 "15 at 0:03
*

pnuts
55.1k99 gold badges7676 silver badges123123 bronze badges
asked Jul 17 "13 at 7:10
*

KarShoKarSho
5,5841313 gold badges4141 silver badges7777 bronze badges
6
I think this related to lớn tệp tin permission, can you check other PHP file permission and compare with the one that you renamed... –user1646111 Jul 17 "13 at 7:12
| Show 1
more comment

6 Answers 6


Active sầu Oldest Votes
157
500 Internal Server Error is shown if your php code has fatal errors but error displaying is switched off. You may try this lớn see the error itself instead of 500 error page:

In your php file:

ini_set("display_errors", 1);In .htaccess file:

php_flag display_errors 1
Share
Follow
edited Jul 17 "13 at 7:18

*

Bart Friederichs
31.1k1313 gold badges8888 silver badges172172 bronze badges
answered Jul 17 "13 at 7:14
*

HastHast
8,75455 gold badges4343 silver badges6565 bronze badges
3
Add a comment |
87
A PHPhường file must have permissions phối to lớn 644. Any thư mục containing PHP files & PHP.. access (khổng lồ upload files, for example) must have sầu permissions mix to 755. PHP will run a 500 error when dealing with any tệp tin or folder that has permissions set to 777!


Share
Follow
answered Dec 16 "15 at 3:10
*

David ValenzaDavid Valenza
1,07988 silver badges44 bronze badges
6
| Show 1 more phản hồi
3
I was having this problem because I was trying khổng lồ connect lớn MySquốc lộ but I didn"t have sầu the required package. I figured it out because of
Amadan"s bình luận lớn kiểm tra the error log. In my case, I was having the error: Điện thoại tư vấn lớn undefined function mysql_connect()

If your PHP.. file has any code to connect with a My-SQL db then you might need lớn install php5-mysql first. I was getting this error because I hadn"t installed it. All my tệp tin permissions were good. In Ubuntu, you can install it by the following command:

subởi vì apt-get install php5-mysql


Share
Follow
answered Nov 17 "14 at 19:35
TheRookierLearnerTheRookierLearner
2,90388 gold badges3131 silver badges5050 bronze badges
Add a phản hồi |
3
It was changing the line endings (from Windows CRLF to lớn Unix LF) in the .htaccess file that fixed it for me.

Xem thêm: Cách Sửa Lỗi Browse For Folder, Hỏi Về Cách Khắc Phục Lỗi Cài Office


Share
Follow
answered Nov 11 "15 at 20:50
SaranSaran
3,72933 gold badges3333 silver badges5454 bronze badges
0
Add a bình luận |
2
I know this question is old, however I ran into this problem on Windows 8.1 while trying to use .htaccess files for rewriting. My solution was simple, I forgot khổng lồ modify the following line in httpd.conf

#LoadModule rewrite_module modules/mod_rewrite.soto

LoadModule rewrite_module modules/mod_rewrite.soRestarted the apabịt monitor, now all works well. Just posting this as an answer because someone in the future may run across the same issue with a simple fix.

Good luck!


Share
Follow
answered Mar 8 "14 at 18:15
WinterWinter
1,5351717 silver badges2626 bronze badges
Add a phản hồi |
1
Google guides me here but it didn"t fix mine, this is a very general question và there are various causes, so I post my problem và solution here for reference in case anyone might read this later.

Another possible cause of 500 error is syntax error in header(...) function, lượt thích this one:

header($_SERVER<"SERVER_PROTOCOL"> . "200 OK");Be aware there should be space between server protocol and status code, so it should be:

header($_SERVER<"SERVER_PROTOCOL"> . " 200 OK");So I suggest check your http header điện thoại tư vấn if you have sầu it in your code.


Share
Follow
edited Aug 7 "15 at 15:26
answered Jul 31 "15 at 14:38
LinLin
42055 silver badges1010 bronze badges
Add a phản hồi |

Not the answer you're looking for? Browse other questions tagged php html apache internal-server-error or ask your own question.


The Overflow Blog
Featured on Meta
Linked
9
Getting Internal Server Error while trying lớn access my site
-1
Problems with DESC keyword using PHP to lớn Query MySQL
0
Wordpress Error 500 in Mysql request in Ajax
0
How khổng lồ see the PHP. error which causes HTML page khổng lồ not load?
0
Internal hệ thống error when sending getJSON request from jquery
1
UPDATE và INSERT SQL tables with php mysqli->prepare
0
Sending mails using PHPMailer gives 'This page isn't working error'. (HTTPhường Error 500)
0
500 Internal error when posting data to lớn php
-1
unable lớn update mysql table from php page
0
Need advice on how khổng lồ add data from html size khổng lồ database
See more linked questions
Related
2132
What are valid values for the id attribute in HTML?
0
Wordpress Blog :: 500 Internal Server Error
2201
How bởi you parse & process HTML/XML in PHP?
0
Error handling, 500 internal VPS error
1201
Reference - What does this error mean in PHP?
7
CakePHPhường 500 Internal Server Error
0
error file .htaccess 500 Internal Server Error
0
500 Internal Server Error on all my sub-domain
1
.htaccess - removing .html file extension causes 500 internal error (for what should be 404?)
Hot Network Questions more hot questions
default
Stachồng Overflow
Products
Company
Stachồng Exchange Network
site thiết kế / biệu tượng công ty © 2021 Staông xã Exchange Inc; user contributions licensed under cc by-sa. rev2021.7.27.39848


Staông chồng Overflow works best with JavaScript enabled
*

Your privacy

By clicking “Accept all cookies”, you agree Stachồng Exchange can store cookies on your device & discthua kém information in accordance with our Cookie Policy.