Permission denied when running scripts from php

Discussion in 'Server Operation' started by marra87, Nov 15, 2006.

  1. marra87

    marra87 New Member


    I have some problems.
    I'm kind of n00b, so hope you can help!

    I have a Fedora server with Apache and PHP.
    But I get a permission denied when I'm running a script from the webbrowser.
    Here is my PHP code:

    function execute($command) { 
        $command .= ' 2>&1'; 
        $handle = popen($command, 'r'); 
        $log = ''; 
        while (!feof($handle)) { 
            $line = fread($handle, 1024); 
            $log .= $line; 
        return $log; 
    echo execute("wakeonlan 00:04:61:6B:A4:71");
    Output: socket : Permission denied at /usr/bin/wakeonlan line 78.

    What permissions do I have to set? Thanks
  2. falko

    falko Super Moderator ISPConfig Developer

    What's the output of
    ls -l /usr/bin/wakeonlan
  3. marra87

    marra87 New Member

    [[email protected] ~]# ls -l /usr/bin/wakeonlan
    -r-xr-xr-x 1 root root 5318 okt 27 01:41 /usr/bin/wakeonlan
  4. falko

    falko Super Moderator ISPConfig Developer

    What happens if you run
    chmod 777 /usr/bin/wakeonlan
  5. cougar19

    cougar19 New Member


    I am having a similar problem. I've created a script that reads a template file then creates and posts the template into a new file using fopen but it returns with "fopen(/usr/web/bsu/test.php): failed to open stream: Permission denied in /usr/web/bsu/admin/includes/functions/content.php on line 134"

    I've double checked the /usr/web/bsu directory and it's permissions are set to 777.
    Are there any other permissions that need to be set for this kind of action?
  6. mudder-board

    mudder-board New Member

    Hope this is of some use, if you want to change permissions for the entire folder and its contents, you would do this
    chmod 777 /directory name -R
    otherwise just do
    chmod 777 /directory/file.php
    Your permissions may differ, 777 was only for an example
  7. falko

    falko Super Moderator ISPConfig Developer

    Also make sure you disabled PHP Safe Mode.
  8. cougar19

    cougar19 New Member

    The folder and files are already 777 and PHP safe mode is disabled.
    I've even gone so far as to try chown on the directory to apache to see if the PHP group needed permission but still didn't work
  9. cougar19

    cougar19 New Member

    Finally got it. For those with a similar problem. Check SELinux enforcing parameters.

    Line 6: SELINUX=enforcing
    Line 6: SELINUX=disabled

Share This Page