.servername

apps

#1

I am using a PHP template system and have installed them above the root (for more security). Unfortunately, I get errors unless the server name is included in the path that points to the templates. For example in the php file:
template_dir = ‘/home/.servername/username/templates’;

Is there a reason for this? I understand we should not include the server name (as it might change from time to time) but the templates won’t work unless I include it, otherwise I get a “failed to open stream: Operation not permitted” etc.

Can anyone help?

Thanks,
Hope


#2

I didn’t realize I wasn’t logged in. Anyway, has anyone else run across this problem? I’d really appreciate any input.

Hope


#3

/home/username/websitefolder(by default/ yourdomain.com/templates

The .servername does change so you really don’t want to include that.

It should work fine. Just double check everything. If it doesn’t work I’m baffled.

happylittlethings.com
Promo Code: WJD50 - $50.00 off any new DreamHost plan


#4

Thanks wjd. However the template directory is above the website folder and the path without the .servername does not seem to work. Can anyone else help?


#5

would specifing $HOME/templates/ work? maybe I’m being stupid and this doesn’t apply, but what the heak.

It does seem odd that it wouldn’t work with out the .server in there.

-Matttail


#6

When you say “template system”, what’re we talking about here?

[quote]For example in the php file:
template_dir = ‘/home/.servername/username/templates’;[/quote]
Odd. I’ve never heard of PHP being unable to resolve symbolic links.
Using a regular everyday PHP “include” statement(s), it should simply be: $template_dir = '/home/username/templates';…and then something like:

include $template_dir."somescript.php";It may or may not be worth mentioning that if this is just plain-old PHP, variable names need that “$”.
If that’s not the case, some other things to check would be:

  1. permissions on the “templates” directory, which should be 755 (lists as drwxr-xr-x).
  2. permissions on the scripts in that directory, which should all be 644 (lists as -rw-r–r--)

If none of that works, then the only thing I can think of to try is a relative path, ie:$template_dir = '../templates'.After that, it probably means there’s some restriction (“open_base_dir”…?) in the system (DH’s) php.ini or similar equivalent in the server’s httpd.conf file, both of which are issues for DH tech support --OR-- you’ll just have to move your templates directory in under the sitename directory (in which case you’ll definitely want to set permissions as listed above).

All in all, it may be bad practice to put the non-symlinked directory in there, but if it makes every thing work, small price to pay in terms of having rarely having to change it (…duct tape isn’t a pretty fix either, but it does a damn good job sometimes). I would imagine (hope) DH staff would notify you before swapping your account onto a different machine anyways, which means you’ll be able to schedule the change in a timely fashion.


#7

Smarty templates. http://smarty.php.net/

[quote]Odd. I’ve never heard of PHP being unable to resolve symbolic links.
Using a regular everyday PHP “include” statement(s), it should simply be:
$template_dir = ‘/home/username/templates’;[/quote]
I omitted the first part. The entire line would be something like:
$smarty->template_dir = ‘/home/.servername/username/dir/templates’;

[quote]If none of that works, then the only thing I can think of to try is a relative path, ie:
$template_dir = ‘…/templates’.[/quote]
I would probably only use that if forced to put the templates under the site folder.

I agree - it is the open_base_dir restriction. But I am curious as to why I am able to specify the .servername and not have any problems. If there is a restriction, I’d think it would apply whether I’ve used the server name or not.

I’ve sent support an email but there are over 500 support emails ahead of mine. I don’t expect a quick answer but I do have a site to build. I guess I’ll be doing a lot of search and replace if they won’t permit a folder above the site folder. I just find it strange because I’ve used a folder above the root on a different host with no problem and many people have done it according to other forums so it doesn’t seem that unusual.

Hope


#8

[quote]would specifing $HOME/templates/ work? maybe I’m being stupid and this doesn’t apply, but what the heak.

It does seem odd that it wouldn’t work with out the .server in there.[/quote]
Thanks mattail but I don’t think that will work either. I am very curious as to why it works with the .servername but not without. You’d think it would be one way or the other regardless if the server name was specified but I have no idea how those things work. I guess the mystery will be solved when support gets to my email.

Hope


#9

sorry I wasn’t of more help. I’d be curious to know what support says about it though. Best of luck…

-Matttail