Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

many sites - one /compiled/ dir. Problem?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
sushko
Smarty Rookie


Joined: 14 Feb 2019
Posts: 5

PostPosted: Sat May 30, 2020 12:01 pm    Post subject: many sites - one /compiled/ dir. Problem? Reply with quote

I plan to host many internet shops having on my webserver one set of PHP files, one Smarty installation, one templates folder and multiple mySQL databases - one database per internet shop. When a visitor comes to www.shop1.com internet shop, the one and only PHP engine connects to the "shop1" database and generates web pages from that database; if the visitor comes to the www.shop2.com site, the same PHP engine installation generates web pages from the "shop2" database.

How should I configure Smarty compiler and caching engine in that single engine installation serving multiple websites?

As far as I understand, I should turn caching off and specify an unique ID for the Smarty compiler, e.g. the "shop1" string if the visitor came to www.shop1.com and the "shop2" string in the case of www.shop2.com.

Is that correct? Should I also configure anything else?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat May 30, 2020 3:17 pm    Post subject: Reply with quote

Nothing of what you describe is correct.
Don't run multiple sites within the same PHP pool.
Don't run multiple sites with shared cache.
Don't… basically, don't be that stupid. What you propose is totally insecure and very performance taxing.
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Sat May 30, 2020 5:14 pm    Post subject: Reply with quote

It seems to me that coding a test could designate a distinct compile and cache directory for each store. Much the same as I imagine you are distinguishing the database to use based on the Server Host value.
Back to top
View user's profile Send private message
sushko
Smarty Rookie


Joined: 14 Feb 2019
Posts: 5

PostPosted: Sun May 31, 2020 10:51 am    Post subject: Reply with quote

AnrDaemon wrote:
Nothing of what you describe is correct.
Don't run multiple sites within the same PHP pool.
Don't run multiple sites with shared cache.
Don't… basically, don't be that stupid. What you propose is totally insecure and very performance taxing.


Why? May I please ask you to explain me that?
Back to top
View user's profile Send private message
sushko
Smarty Rookie


Joined: 14 Feb 2019
Posts: 5

PostPosted: Sun May 31, 2020 11:33 am    Post subject: Reply with quote

bsmither wrote:
It seems to me that coding a test could designate a distinct compile and cache directory for each store. Much the same as I imagine you are distinguishing the database to use based on the Server Host value.


I have turned off Smarty caching according to instructions in documentation:

https://www.smarty.net/docsv2/en/caching.tpl
For instance, if you are displaying the front page of your website that does not change its content very often, it might work well to cache this page for an hour or more. On the other hand, if you are displaying a page with a timetable containing new information by the minute, it would not make sense to cache this page.

As for compilation issues, documentation suggests to use compileID alternativelly to handle multiple compiled files folders. Why should I use different folders in this case if I can use one?
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Sun May 31, 2020 2:02 pm    Post subject: Reply with quote

I will have to re-read that bit of the documentation, but I recall there was the understanding that Smarty was being used for one site.

This scenario is for two sites - probably with different dynamic data.

My initial experiments show that the compiled templates might be the same, as it is the cached templates that have the dynamic data in them.

One of my concerns (for the application I use) is how to delete all compiled files for just one store.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Jun 01, 2020 12:13 pm    Post subject: Reply with quote

sushko wrote:
I have turned off Smarty caching according to instructions in documentation:

https://www.smarty.net/docsv2/en/caching.tpl


Why are you reading documentation for obsolete version of the library? And what in it made you think that disabling caching is a good idea in general?
Back to top
View user's profile Send private message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Sat Jun 06, 2020 9:48 am    Post subject: Reply with quote

AnrDaemon wrote:
Nothing of what you describe is correct.
Don't run multiple sites within the same PHP pool.
Don't run multiple sites with shared cache.
Don't… basically, don't be that stupid. What you propose is totally insecure and very performance taxing.


Hi.

Ive got SEPARATE compiled/source directories for each of my subdomains. However ive only got ONE Smarty system/programme

/home/users/web/(PATH)/usr/smarty-3.1.34/libs

Would it be beneficial for me to copy the main Smarty programme into separate directories for each subdomain ?

or is it OK, & just have the templates in the separate directories ?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Jun 06, 2020 2:20 pm    Post subject: Reply with quote

If you run separate template/compile/cache dirs, and separate PHP pool per server, if your Smarty library is only accessible read-only, it may be sufficiently secure.
But I would still use separate application code for each pool.
Back to top
View user's profile Send private message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Sun Jun 07, 2020 12:15 am    Post subject: Reply with quote

AnrDaemon wrote:
If you run separate template/compile/cache dirs, and separate PHP pool per server, if your Smarty library is only accessible read-only, it may be sufficiently secure.
But I would still use separate application code for each pool.


PHP Pool ?

Application code ?

So you ARE recommending the smarty files (libs etc) be copied - into separate directories - One for each subdomain.

(they are hidden from the public - Cannot be accessed directly by URL)
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Jun 07, 2020 12:37 pm    Post subject: Reply with quote

Yes. That way, you always know what's going on in your system, and upgrading or changing one suite won't break all the rest.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP