0

I have a very simple PHP script on a remote Apache web server. On my PC, it functions perfectly fine with php web server running but nothing appears to be executing in the web server and there appears to be no errors. I have a good suspicion that this is a configuration issue. Please advise!

httpd.conf contains the following lines

LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php
AddType application/x-httpd-php .php

Apache is (I believe) properly installed. Running apachectl -V shows me info, as expected:

Server version: Apache/2.2.15 (Unix)
Server built: XXX X XXXX XX:XX:XX
...

And PHP appears to also be properly installed. Running php -v shows me version info, as expected:

PHP 5.3.3 (cli) (build: XXX X XXXX XX:XX:XX)
...

I have tried the steps given by the answer to this question. As far as I know, the above configurations should a have worked. I may be wrong, but I don't have reason to suspect that there is anything wrong with the Javascript (making requests) or the PHP script because they work on my PC. Is there something I've missed in the configuration? If I've failed to provide enough details, please let me know.

Thanks in advance!

EDIT 1

PHP script:

<?php
    error_reporting(E_ALL);
    ini_set('display_errors', 1);

    $xml = file_get_contents("php://input");
    $xmlDoc = simplexml_load_string($xml);
    $xmlDoc -> asXml("someData.xml");
?>
Community
  • 1
  • 1
Sandy
  • 51
  • 1
  • 7
  • PHP for the command line appears to be properly installed, not for the web server. Does a page with just `phpinfo();` in it execute properly on the remote server? – Jay Blanchard Jun 15 '15 at 15:44
  • please check your configuration according to http://php.net/manual/en/install.php and http://php.net/manual/en/install.windows.apache2.php – Rajnikant Sharma Jun 15 '15 at 15:48
  • you need to verify that php is enabled in your webserver, e.g. mod_php has been loaded. just seeing php at the command line means very little... – Marc B Jun 15 '15 at 15:50
  • @JayBlanchard Doing what you suggested gives me a page with the PHP version and other details. This suggests that PHP is properly installed? – Sandy Jun 15 '15 at 15:59
  • Yes it does suggest that. Your next step would be watching the JavaScript requests in the browser's console to see what is happening with them. – Jay Blanchard Jun 15 '15 at 15:59
  • @JayBlanchard btw, thanks for your help! I am using Chrome with its built in dev tools. Console view is not logging any errors and the Network view shows that the POST request was successful, 200 OK. – Sandy Jun 15 '15 at 16:04
  • Awesome @Sandy! Glad you got things working. – Jay Blanchard Jun 15 '15 at 16:05
  • @JayBlanchard actually it's too early to celebrate, lol. While everything *appears* to be working. The script still doesn't seem to be executing :( Perhaps there is a problem with my Javascript code or PHP script -you think? – Sandy Jun 15 '15 at 16:08
  • I'd look for errors in the console for the JavaScript. If there are none I would try to run the PHP by itself. Add error reporting to the top of your file(s) right after your opening ` – Jay Blanchard Jun 15 '15 at 16:09
  • @JayBlanchard After adding error reporting as you've suggested, I still don't see any errors in the console. Let me know if you need to see additional details (such as code)! And again, thanks for helping me out with this :) – Sandy Jun 15 '15 at 16:23
  • You're quite welcome. Can you share the PHP script here that is not working? – Jay Blanchard Jun 15 '15 at 16:29
  • @JayBlanchard see edit :) – Sandy Jun 15 '15 at 16:31
  • You may need to add som XML error handling - http://php.net/manual/en/simplexml.examples-errors.php – Jay Blanchard Jun 15 '15 at 16:56
  • 1
    @JayBlanchard Made adjustments based off of your suggestions to enable error reporting and found the problem: permission denied `$xmlDoc -> asXml("someData.xml");`. So the solution for this was to just give apache permission to write to the XML file. I'd like to give you credit for helping me get to the solution. The best way to do this is if you could post an answer. :) thanks! – Sandy Jun 15 '15 at 20:08
  • Alrighty! I'm glad you were able to find the issue. I've posted an answer. – Jay Blanchard Jun 15 '15 at 20:12

1 Answers1

2

I'd look for errors in the console for the JavaScript.

If there are none I would try to run the PHP by itself. Add error reporting to the top of your PHP file(s) right after your opening

If that doesn't reveal anything add some XML error handling as outlined here - http://php.net/manual/en/simplexml.examples-errors.php

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
  • These steps helped me determine the real error. In this case, it was a permission denied problem. The solution was simple -give apache write permission to **someData.xml** – Sandy Jun 15 '15 at 20:29