1

I'm trying to implement the simple-linkedinphp library (it's found at http://code.google.com/p/simple-linkedinphp/)

It runs fine on localhost, but when I upload it to the server I get a 500 Internal Server Error. Here's what the error log says:

[12-Feb-2012 20:35:09] PHP Parse error: syntax error, unexpected T_STRING in /home1/bangaban/public_html/LIAPIwrappertest/linkedin_3.1.1.class.php on line 1

This doesn't help because line 1 is just the opening <?php tag and then some comments.

The library requires PHP 5+ and the cURL extension on the server and phpinfo() shows that to be installed. I don't think there are any syntax errors in the script because it works fine on localhost and it's a library that's been used by many people.

I googled and found some resources that talk about 500 errors being caused by write access; this question talks about that a bit, but it's a different error message, so I'm not sure how it would apply to this case.

It seems like it's something on the server side, perhaps something in the php.ini file? Or maybe the .htaccess file? I've never had this problem before with libraries or php scripts once I've got them to work on localhost, so this is really strange to me.

EDIT/UPDATE:

I changed the file permissions from 644 to 755, but that didn't do anything.

I changed demo.php to load a test file instead of linkedin_3.1.1.class.php and that worked fine, so it's definitely not parsing just SOME files. Then I decided to try some of the earlier versions of the same library. Version 3.1.0 parses and runs without error. Version 3.2.0 does not parse, although the parse error is different from version 3.1.1. That's strange because the download count is 752 for v3.2.0, so how could it not work for me if it worked for hundreds of other people?

Anyways, I'm going to work with v3.1.0 for now and see if anyone can solve the mystery of why all the versions after v3.0.0 get parse errors. I've logged an issue with my hosting provider, as well as on the project page.

Community
  • 1
  • 1
edpeciulis
  • 145
  • 1
  • 3
  • 9
  • have you tried running the script on that server at the command line? PHP's error messages/line numbers CAN lie to you in some cases. – Marc B Feb 13 '12 at 04:49
  • Worst problem one could have :P Could be anything from syntax error (like missing a semi colon) to using short tags when you are no supposed to. Since it works locally, highly unlikely its some sort of syntax error. Make sure your php config is the same on your localhost and server. In my case it was using short tags without enabling it. – Vinoth Gopi Feb 13 '12 at 05:07
  • @MarcB I'm using a shared hosting provider, so I don't think there's a way get command line access to PHP over there. – edpeciulis Feb 13 '12 at 15:58
  • @VinothGopi There aren't any unusual differences in the settings between the two php.ini files. All my other php scripts run fine. As of now, I'm testing another library which works on the remote server, although it's not as elegant as the simple-linkedinphp library. – edpeciulis Feb 13 '12 at 16:00

1 Answers1

2

HTTP Error 500 Internal server for php pages and solution

Generally, to solve this problem you need to take help of log files located at following location:

=> /var/log/message
=> /var/log/httpd/error_logs (/var/log/lighttpd/error_log or /var/log/httpd/error_log)

This error only occurs because of web server software. However after looking through logs you may not find many details. This problem may be caused by:

  1. A malformed php cgi script
  2. An invalid directive in an .htaccess or other config file
  3. Limitation imposed by file system and server software (for example php log file size set to 10Mb) 4.Missing php.ini (or cannot read php.ini file)

In most case it is an invalid .htaccess directive. However recently I came across a web server w/o /etc/php.ini file. A long time ago I setup this server )Apache chrooted jail). So you need to maintain two files one outside jail and another inside jail:

=> /etc/php.ini
=> /chroot/etc/php.ini <-- this file was missing

Many scripts open this file on fly to get correct configuration directives. If this file not found you get error 500. It took some time to figure out this problem. Finally strace helped me out to debug this problem.

thecodedeveloper.com
  • 3,220
  • 5
  • 36
  • 67
  • I ended up switching to another library, but these are useful troubleshooting tips. I would also add that when looking at log files, it's useful to use grep -v to filter out what you don't want and grep to show only the lines containing a string to match. – edpeciulis Nov 20 '12 at 16:23