_www takeover?

Discussion in 'Web Design and Development' started by macuser0101, Dec 9, 2009.

  1. macuser0101 macrumors newbie

    Dec 9, 2009
    I wrote a simple web page in PHP that runs some bash commands to process some files when they are uploaded.

    I configured my apache httpd.conf to point to a different directory than WebServer, and I am NOT using the ~userhome/Sites dir either.

    I am using another folder inside of Documents.

    I created the files and scripts using the same id that is used when I login to my machine.

    When I view my web page from another machine using the path I set in Apache, I have no problems using the page and the scripts I wrote run and execute successfully.
    However, my output and page that I accessed suddenly becomes owned by _www.

    What's the story? Should I change perms on output through scripts or can I somehow configure my mac to NOT give _www ownership.

    Additionally,if someone can answer the following: I am confused as to why there is a WebServer dir and also a Sites dir on one machine. I have read a bit about it, but still confused about this point as well.
  2. Darth.Titan macrumors 68030


    Oct 31, 2007
    Austin, TX
    By default PHP scripts are run as whatever user apache is running as. Therefore any files created by PHP inherit the same ownership. The user apache runs as can be changed in your apache config file though. I don't recommend doing that if your server is accessible via the internet. That would be putting your files at risk.

    The separate Sites and WebServer directories enable mutiple users to have their own sites, as well as a "master site" located in the WebServer directory. For example:

    http://mac-pro.local would ordinarily go to the WebServer directory

    http://mac-pro.local/~user2 would go to the individual users' Sites directory.

    This is all configurable of course.
  3. macuser0101 thread starter macrumors newbie

    Dec 9, 2009

    Thanks Darth.Titan
    So my problem is also that once those files are run by apache or loaded, the perm changes from my id to _www and then I don't have the ability to edit them, only read permission is set. Should I be creating files in the directories you mention instead of the directory I customized? There must be a way that I can access _www files - ACL change to my id?
  4. Darth.Titan macrumors 68030


    Oct 31, 2007
    Austin, TX
    Use sudo to change the ownership of the files. No matter where the script saves the files, they'll always be owned by _www.
    sudo chown username:username filename.txt
    Replace username (in both places) to your username.

Share This Page