Re: Smarty & Safe Mode ?
| From: | Sheldon Jones - Admin | Date: | Wed, 19 Dec 2001 18:42:42 +0000 |
| Subject: | Re: Smarty & Safe Mode ? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2341@lists.php.net to get a copy of this message | ||
I've been using smarty on a safemode server for about 8 months now. I'm
using the CGI version of php combined with cgiwrap so that the php
scripts run as the user not the web server.
I use an include path like this one to grab smarth, pear and any other
needed files.
ini_set(include_path, './:../pear:../smarty:../common:../include');
/home/user_bob/pear
/home/user_bob/smarty
/home/user_bob/include
/home/user_bob/public_html/example.php
I copy all of pear into the pear directory so the script can access it.
In safemode php doesn't have access to the directory where pear is
installed by default.
I also make a smarty directory where i untar and install smarty.
To get cgiwrap running you will need to patch it so the php scripts will
work. You can get the patch here: http://www.klaban.torun.pl/patches/cgiwrap/
Once you have it patched you'll need to:
#########################################
CGIWRAP..
#########################################
Step 1:
Apply patches found at here: http://www.klaban.torun.pl/patches/cgiwrap/
Step 2:
./configure --with-httpd-user=nobody
--with-install-dir=/usr/local/cgiwrap-php --with-install-group=wheel
--with-cgi-dir=public_html
--with-php=/usr/local/php4-cgi/bin/php --without-fixed-path-translated
This allows you to run php only under public_html.
Step 3:
make
Step 4:
mkdir /usr/local/cgiwrap-php
Step 5:
make install
#########################################
PHP CGI setup.
#########################################
Step 1:
get and untar php
Step 2:
./configure --prefix=/usr/local/php410-cgi
--exec-prefix=/usr/local/php410-cgi
--with-config-file-path=/usr/local/php410-cgi
--enable-force-cgi-redirect --enable-discard-path --enable-versioning
--enable-track-vars --enable-trans-sid --enable-safe-mode
Step 3
make
Step 4
make install
Step 5
We compiled php to install everyting under /usr/local/php410-cgi and
we pointed our cgiwrap script to /usr/local/php4-cgi. So we need a
link like this (ln -s /usr/local/php410-cgi /usr/local/php4-cgi) so
cgiwrap can find the php binary. Using this method you can try many
different versions of php by only changing the symlink. Or if you
really wont you could recompile and install cgiwrap everytime. :(
#########################################
Apache setup
#########################################
Step 1
Setup a script alias for /php-bin/ and the directory access in your
httpd.conf for apache.
ScriptAlias /php-bin/ "/usr/local/cgiwrap-php/"
<Directory "/usr/local/cgiwrap-php">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Step 2
Make a <VirtualHost *> entry in your httpd.conf for each vhost you want
safemode php script support.
<VirtualHost *>
AddHandler cgiwrap-php .php
Action cgiwrap-php /php-bin/php-cgiwrap/user_bob
ServerAdmin webmaster@bobs_domain.com
DocumentRoot /usr/home/user_bob/public_html
ServerName bobs_domain.com
ServerAlias www.bobs_domain.com
</VirtualHost>
The AddHandler sets the .php extention to be called using php-cgiwrap
as the user "user_bob". Make sure the Action is different for each
vhost so that the usernames match.
--------------------------------------------------------------------
I hope this helps someone. If you have any question please let me know.
I know that these directions are not 100% complete and I may have forgot
something.
My system is FreeBSD 4.4-Stable running php-4.1.0 on apache 1.3.22.
--Sheldon
On Wed, Dec 19, 2001 at 11:55:18AM +0100, Bertrand DUNOGIER wrote:
> Hello (again),
>
> is smarty supposed to work correctly on a safemode server ?
>
> I get this error:
>
> Warning: SAFE MODE Restriction in effect. The script whose uid is 18304 is not allowed to
> access ./data/templates_c/c5/c54132d33595d1a7a6e99071970b7e60 owned by uid 33 in
> /home/user/b/d/u/bdunogier/www/includes/smarty/Smarty.class.php on line 1385
>
> Warning: Smarty error: problem creating directory
> "./data/templates_c/c5/c54132d33595d1a7a6e99071970b7e60" in
> /home/user/b/d/u/bdunogier/www/includes/smarty/Smarty.class.php on line 1516
>
> (and my templates_c directory is 777 chmoded)
>
> --
> Best regards,
> Bertrand mailto:bdunogier@wanadoo.fr
>
>
> ---
> You are currently subscribed to smarty as: sheldon@hobbydump.com
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
--Sheldon
------------------------------------------------------
Sheldon Jones
Systems Administrator
Lobo Internet Services, Ltd.
mailto:sheldon@hobbydump.com
Does Microsoft mean "small and limp"?
What's with the 'Intel Inside' warning label anyway?
------------------------------------------------------