Tag: suphp

Swapping between php versions when using suPHP and CLI with custombuild

by admin on Sep.07, 2009, under DirectAdmin

If you have both suPHP and CLI installed on your system, but don’t feel like renaming all of your file.php to file.php4 (for example), there is another means to chose between php versions, without requiring to touch your php files.
To force php files to use CLI (on the assumption your default php version uses suPHP) create an .htaccess file in your public_html directory, with the following:

<FilesMatch "\.php$">
AddHandler application/x-httpd-php .php
</FilesMatch>

To force php files to use suPHP (on the assumption your default php version uses CLI) use the following:

<FilesMatch "\.php$">
AddHandler x-httpd-php5 .php
</FilesMatch>

This last one is on the assumption that php 5 is suPHP and CLI is php4. If php4 was suPHP, then you’d use x-httpd-php4 to force .php files to use suPHP with php 4.

Leave a Comment :, , , , more...

Setup a per-user php.ini to allow open_basedir with suPhp

by admin on Sep.07, 2009, under DirectAdmin

new way:
If you wish to use per-user php.ini files in:
/home/username/php.ini
then you can use this guide to add the code:

SetEnv PHP_INI_SCAN_DIR /usr/local/directadmin/data/users/|USER|/php/

to the VirtualHost entires for that domain and it’s subdomains. This will tell suPhp to look in that path for a php.ini (which you’ll need to ensure is there).
Note for complete usage of this setting, a how-to has been created here, which should be consulted with first: http://www.directadmin.com:80/forum/showpost.php?p=156958&postcount=25
If you only want to set a custom php.ini for individual users, and not all users, then you can use this guide to insert just the one line of code into the VirtualHost entires for that domain.
Related:
http://www.php.net/ini.sections
Improved php.ini handling in 5.3.0


old way:
In order to setup a php.ini for each user with suPhp (installed by custombuild), edit:
/etc/httpd/conf/extra/httpd-suphp.conf
Find this line:

suPHP_ConfigPath /usr/local/etc/php5/cgi/

and comment it out by changing it to

#suPHP_ConfigPath /usr/local/etc/php5/cgi/

(just add a # in front of it).
Doing this will let suPhp be more flexible in using a different php.ini file. By default, it will still fall back to the /usr/local/etc/php5/cgi/php.ini if nothing else is set, but by not setting it, it allows us to change it (suPhp only accepts the first call of that command).
The next step is to tell apache where to find the php.ini that you want.
Go to:
Admin Level -> Custom httpd configuration -> domain.com
Insert the following 1 line into the top textarea:

suPHP_ConfigPath |HOME|/

exactly as written, then hit save. You can do this for as many single domains as you wish.
Note that you can also make this a global change by adding that line to the virtualhost templates using this guide:
help.directadmin.com/item.php?id=2.
Restart apache when you’re done.
Don’t forget to actually add a php.ini file into /home/username/php.ini and save it with root as the owner if you don’t want the user changing it at all. In that php.ini file, you can specify a custom open_basedir path, thus preventing the user from wandering about the system. Automating a new php.ini can be done with the user_create_post.sh script.

Leave a Comment :, , , , , more...

How to modify the open_basedir setting for one domain.

by admin on Sep.07, 2009, under DirectAdmin

To change the open_basedir value when using php in CLI mode (not suPhp), you can do so by going to:
Admin Level -> Custom httpd configuration -> domain.com
In the top text area, insert this one line:

|?OPEN_BASEDIR_PATH=`HOME`/:/tmp:/usr/local/lib/php/|

which is the default value in the templates. Edit the paths in that line to meet your needs.

Leave a Comment :, , , more...

Allow php scripts to work under ~username when using suPhp (custombuild)

by admin on Sep.07, 2009, under DirectAdmin

By default, suPhp is compiled in "paranoid" mode. This means that the settings in the user httpd.conf files:

suPHP_UserGroup username username

will require all php files to be owned by username or suPhp will throw a "500 Internal Server Error".
This does not apply to domains, when used normally, because each domain has it’s own VirtualHost with the suPHP_UserGroup inside it using the correct settings.
The ~username (UserDir) method will fail in paranoid mode, because there is not a virtualhost for each ~username path, and no suPHP_UserGroup settings for each user, hence you get the 500 error.
The solution to this is to compile suPhp in "owner" mode instead of "paranoid" mode.
To do that, run these commands.

cd /usr/local/directadmin/custombuild
mkdir -p custom/suphp
cp -fp configure/suphp/configure.suphp custom/suphp/configure.suphp
perl -pi -e ’s/paranoid/owner/’ custom/suphp/configure.suphp
./build clean
./build suphp
cd /usr/local/directadmin/data/templates/custom
cp -f ../virtual_host* .
perl -pi -e ’s/suPHP_UserGroup/#suPHP_UserGroup/’ virtual_host*.conf
perl -pi -e ’s/suPHP_UserGroup/#suPHP_UserGroup/’ /etc/httpd/conf/httpd.conf
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue

Which will change all references of suPHP_UserGroup to #suPHP_UserGroup, basically, just commenting them out.

Leave a Comment :, , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Kontak

Budhi Indah A 31
Cimindi Cimahi 40514
West Java
Indonesia

Phone/SMS :
Info/Bantuan : 62-8158-6270622
Billing/konfirmasi : 62-8888-763551

Self Advertise


My site is worth $7548.2.
How much is yours worth?