Jump to content

Grabeorama

Members
  • Posts

    134
  • Joined

  • Last visited

Posts posted by Grabeorama

  1. Ok problem solved. I think the system was getting confused with file versions used by PHP, as I had 2 different PHP interpreters installed, one from Lampp and one I installed before Lampp. So by uninstalling PHP and adding the Lampp PHP interpreter to the PATH, things started to work correctly again! Thanks for the help, really appreciate it!

  2. Well I have redirected the output to stderr (as mentioned in the OP) and got the following error (only for localhost):

    php: /opt/lampp/lib/libxml2.so.2: version `LIBXML2_2.9.0' not found (required by php)php: /opt/lampp/lib/libcrypto.so.1.0.0: no version information available (required by php)php: /opt/lampp/lib/libssl.so.1.0.0: no version information available (required by php)

    But I can't make heads nor tails of it! EDIT:Is it possible that I have multiple versions of the files mentioned in the errors and that PHP is confused as to which to use?

  3. How could I print the user of the other file if the shell_exec() isn't running the other file? I've just tried it there, getting this from the command line: php index.php

    Index: user
    Hello: user
    sudo -u nobody php index.php
    Index: nobody
    Hello: nobody
    but from localhost I only get:
    Index: nobody
    as it's not executing the hello file. The same problem for trying to output their working directories. Is there another way I can check?
  4. Hey thanks for the reply, I created two files: index.php:

    $user = posix_getpwuid(posix_geteuid())['name']; print "Executing as {$user}<br />\n";print shell_exec("php hello.php");

    and hello.php

    print "Hello<br />\n";

    Running the index.php from command line works fine, outputting "Executing as <user><br />Hello", as expected

    php index.php

    Running the same file from localhost/index.php outputs "Executing as Nobody" as expected, but does not output the shell_exec() command. (Presumably because it's running as Nobody) But then when I run the following command:

    sudo -u nobody php index.php

    I get the same output as through localhost, but it does show the output of the shell_exec().Any ideas as to why?

  5. I've been Googling this problem all day now and have nothing to show for it. I'm attempting to run a php script, from a php script using exec. I'm doing this to allow the second php script to run in the background, as it may/may not run for quite some time. This is my code for doing that:

    exec("php myScript.php > out.txt 2> err.txt &");

    With this code I get two new files (as expected) out.txt and err.txt.out.txt is empty, and err.txt contains:

     php: /opt/lampp/lib/libxml2.so.2: version `LIBXML2_2.9.0' not found (required by php)php: /opt/lampp/lib/libcrypto.so.1.0.0: no version information available (required by php)php: /opt/lampp/lib/libssl.so.1.0.0: no version information available (required by php)

    I can run the command "php callingScript.php" (the script containing the exec call) from the command line manually, and it works fine. I thought the problem might be related to permissions for the 'nobody' user run by Apache, but when running the command:

    sudo -u nobody php callingScript.php

    It works. I've also tried running it with the direct path to php:

    /usr/bin/php callingScript.php

    Any ideas as to what's going on ie. why I can run it manually but not via localhost using exec()? And thanks for reading.

  6. it sounds like it might be worth making a Config file that defines the ROOT path for each environment. Using a build tool like Ant or Maven can help automate this process, or you can just change it per environment as deploy.
    Thanks, this is how I used to do it, but it became annoying when moving the project from place to place and having to reconfigure the config file each time. There's no dynamic way of doing it is there?
  7. My project usually has an 'init.php' file in it's root directory which every file includes. This file defines 2 constants: ROOT and PATH:(pseudocode)PATH = dirname( __FILE__)ROOT = substr( PATH, strlen( $_SERVER[ 'DOCUMENT_ROOT'])) this allows me to easily relocate the project to another directory without having to change any code. However, the problem arises when the server has sub domains in it's public_html/htdocs folder.when ROOT should equal '/my/project/', it might equal '/subdomain/my/project/' So my question is:Is there a way of getting the directory my init.php file is in, relative to the DOCUMENT_ROOT which takes into account subdomains?ORIs there a way of having $_SERVER['PHP_SELF'] for included files?

×
×
  • Create New...