View previous topic :: View next topic |
Author |
Message |
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Thu Jun 18, 2009 4:21 pm Post subject: One copy of Smarty for all websites in the server |
|
|
Did you ever think of one installation of Smarty to be used in all of your websites? This is possible if you have one dedicated/shared linux server. For those who do not have access to SSH (we will need this), you can ask your hosting provider help you with this article.
Concept and procedure:
Install a fresh version of Smarty somewhere in your Linux server. I hate Windows, and do not want to write any support tricks here.
For security reasons, it is better that these files are owned by root user, and shared in READ ONLY mode for other users.
Create a softlink to your public_html or htdocs folder to access the Smarty there! Hoorraayy. Thats all.
Examples:
Say, you put Smarty in: /var/general/smarty/lib on the server.
Your www.website1.com is located at /var/vhosts/website1.com/public_html
Then, do:
Code: | cd /var/vhosts/website1.com/public_html
ln -s /var/general/smarty/lib smarty |
Now, use Smarty as you do it normally. Looks simple!
Smarty consumes around 385 kb of total size.
But to copy same file for each website, after learning from this tutorial may not be good
Reuse as much as possible. |
|
Back to top |
|
fornve Smarty Rookie
Joined: 25 Apr 2008 Posts: 29 Location: Sheffield, UK
|
Posted: Sat Jul 04, 2009 7:49 am Post subject: |
|
|
1. Download and unpack smarty.
2. sudo mkdir /usr/share/php/smarty
3. sudo mv {unpacked_smarty}/libs/* /usr/share/php/smarty
4. Add /usr/share/php/smarty to php.ini include_path
5. Restart apache. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Jul 04, 2009 4:54 pm Post subject: |
|
|
You don't even need a symlink, use the full path to the shared lib, or add the shared path to the php_include path like fornve mentioned. |
|
Back to top |
|
philoertel Smarty Rookie
Joined: 25 Jun 2009 Posts: 14 Location: Chicago, IL
|
Posted: Mon Jul 06, 2009 5:07 am Post subject: |
|
|
I do a lot of work for clients, developing on my home machine where I have full control but deploying to a strange environment. For me, that means staying away from php.ini :( I like the symlink route because subversion doesn't follow links but zip does. That way I avoid duplicating libraries in my repository and on my development box, but my deployed project has all its dependent libraries right there under one subtree. Feels like a dopey solution though. It doesn't handle heterogeneous development environments well (other developers in my shop use win and mac, so they won't use /usr/share/php), and it doesn't take advantage of existing libraries on client environments (more of a concern with bigger libraries like Zend Framework). It's cool to hear how you all deal with those same issues. _________________ Phil Oertel
Application Developer
http://www.soliantconsulting.com |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Jul 07, 2009 1:52 am Post subject: |
|
|
If I were deploying to strange environments, I would probably just bundle the Smarty libs with each deployment to keep things stable. There is a tradeoff no matter what you end up doing. |
|
Back to top |
|
reffer101 Smarty n00b
Joined: 12 Nov 2009 Posts: 1
|
Posted: Tue Nov 17, 2009 2:06 pm Post subject: |
|
|
Hmmm Thanks now I can tell that to my Programmer, i tihink he already know how to do this but it was me who was unable to make him understand what i want.
BTW Thanks for the info... _________________ Nike Watches | Adidas Watches |
|
Back to top |
|
Alexcsp Smarty n00b
Joined: 17 Feb 2008 Posts: 3 Location: Scotland
|
Posted: Fri Apr 16, 2010 9:52 am Post subject: One instance of Smarty on a server |
|
|
Thanks for these tips.
can I also have seperate template folders for each website on the server?
how would you do you do that? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Apr 16, 2010 1:56 pm Post subject: Re: One instance of Smarty on a server |
|
|
Alexcsp wrote: | Thanks for these tips.
can I also have seperate template folders for each website on the server?
how would you do you do that? |
See the extended setup in the install docs.
http://www.smarty.net/manual/en/installing.smarty.extended.php |
|
Back to top |
|
Alexcsp Smarty n00b
Joined: 17 Feb 2008 Posts: 3 Location: Scotland
|
Posted: Sun Apr 18, 2010 3:32 pm Post subject: One Smarty, multiple sites |
|
|
Thanks.
you know, I had already read that, but it did not sink in, that I could use one copy of the smarty class for multiple sites, using different template folders for each site.
Up till now, I've been copying the complete set of files to each site folder.
This will save me loads of disk space.
Thank you
Alex
|
|
Back to top |
|
kingyes Smarty n00b
Joined: 13 Jan 2011 Posts: 3
|
Posted: Thu Jan 13, 2011 8:12 pm Post subject: |
|
|
from this docs: http://www.smarty.net/quick_install
Code: | <?php
// put full path to Smarty.class.php
require('/usr/local/lib/php/Smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->setTemplateDir('/web/www.example.com/smarty/templates');
$smarty->setCompileDir('/web/www.example.com/smarty/templates_c');
$smarty->setCacheDir('/web/www.example.com/smarty/cache');
$smarty->setConfigDir('/web/www.example.com/smarty/configs');
$smarty->assign('name', 'Ned');
$smarty->display('index.tpl');
?> |
I thinks this is the best way for that.. |
|
Back to top |
|
|