Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
How to run PHP as your own user, without safe mode, on the PAYH platform
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- How to run PHP as your own user, without safe mode...
How to run PHP as your own user, without safe mode, on the PAYH platform
28-12-2008 2:26 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Done a bit more digging around on PAYH after Christmas and found that it is possible to run PHP scripts as your own user rather than Apache. There is a version of PHP 5.2.1 running as CGI. To use the CGI version rather than the Apache-module version, you will have to:
1. Add a shebang line (see below) to your script, as you would with Perl.
2. Replace the script's .php extension with a .cgi extension.
3. Load your script into the cgi-bin folder rather than the httpdocs folder.
4. Make it executable (755).
Here is a phpinfo script with the necessary shebang line. If you run this script, note the database-related swings and roundabouts.
This doesn't really help with the Joomla/Gallery/etc. problems. It would take an awful lot of editing to convert things like Joomla or Gallery to work with this setup.
IMHO, Plusnet should do the right thing for their customers and keep the ccgi platform running until they update PAYH to Plesk 9.
Nevertheless, for scripters, the method above will allow PHP scripts to be run as your user (e.g. to create files owned by you rather than www-data) and without the safe-mode restrictions. If you decide to use this method to run shell scripts, it would be safest to use a password-protected method such as
suitably modified, and make your script non-executable when you've finished with it.
Gabe
1. Add a shebang line (see below) to your script, as you would with Perl.
2. Replace the script's .php extension with a .cgi extension.
3. Load your script into the cgi-bin folder rather than the httpdocs folder.
4. Make it executable (755).
Here is a phpinfo script with the necessary shebang line. If you run this script, note the database-related swings and roundabouts.
#!/opt/php52/bin/php5-cgi
<?php
phpinfo();
?>
This doesn't really help with the Joomla/Gallery/etc. problems. It would take an awful lot of editing to convert things like Joomla or Gallery to work with this setup.
IMHO, Plusnet should do the right thing for their customers and keep the ccgi platform running until they update PAYH to Plesk 9.
Nevertheless, for scripters, the method above will allow PHP scripts to be run as your user (e.g. to create files owned by you rather than www-data) and without the safe-mode restrictions. If you decide to use this method to run shell scripts, it would be safest to use a password-protected method such as
http://phpshell.sourceforge.net/
suitably modified, and make your script non-executable when you've finished with it.
Gabe
Message 1 of 2
(1,024 Views)
1 REPLY 1
Re: How to run PHP as your own user, without safe mode, on the PAYH platform
15-01-2009 3:30 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
By the way, before I got all cookied out, I'd meant to add that the command-line version of PHP can also be run without safe mode on PAYH, for instance, by using the -n option. This might be useful when setting a PHP script as a cron task:
If the script has to run from its own directory, then it should start:
Gabe
/usr/bin/php5 -n httpdocs/yourfolder/yourscript.php
If the script has to run from its own directory, then it should start:
chdir(dirname($_SERVER['argv'][0]));
Gabe
Message 2 of 2
(233 Views)
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- How to run PHP as your own user, without safe mode...