Weston C
Weston C

Reputation: 3632

User/permissions issues and PHP single-file installers

Since hearing about __HALT_COMPILER in PHP, I've been doing some experimentation with a single-file PHP installers (scripts containing a compressed archive of a filetree for a webapp).

It seems to be easy enough to generate a script that contains both the archive and the logic for unpacking it and taking care of configuration. But permissions/user related issues seem to be a bit more thorny. It's highly likely (except in suexec/CGI cases) the PHP process is running as whatever user the webserver runs as, and so it likely doesn't have permissions to write in whatever directory it's running in. I suppose this issue can be skirted if the user knows how to temporarily change the permissions of the directory targeted for the install, but part of the idea behind single-file installs is to simplify what the user has to do, so I don't like this much. More important, though, once the install is done, it seems to me the files and subdirectories are going to be owned by the webserver user, and they'll therefore be unmanageable by the user (except via more web scripts).

I've thought a little bit about trying to use su or sudo to fix this. However, I'm not sure how to navigate the password prompt that's going to follow an issued su/sudo command. It's my understanding sudo also may be limited to a subset of users.

Is there a good way to create PHP installer scripts which write files that have user-tinkering-friendly ownership and permissions?

Upvotes: 1

Views: 145

Answers (1)

Charles
Charles

Reputation: 51411

Is there a good way to create PHP installer scripts which write files that have user-tinkering-friendly ownership and permissions?

I've only ever seen this pulled off successfully using one method, and it's horrible/funny: FTP. The FTP extension is usually enabled, and when it isn't, you have a variety of other options. FTP usually operates as the correct user, making file ownership and permissions a breeze. Many commercial (and OSS) consumer-grade PHP packages use FTP trickery to make things a bit more smooth.

Though as mentioned by others, if you're targeting geeks, people with their own machines (dedicated or virtualized) or anything other than the consumer-grade market, a PEAR or PEAR2 distro would please people, and if you're targeting 5.3 only, a phar distro is completely suitable.

Upvotes: 1

Related Questions