View previous topic :: View next topic |
Author |
Message |
sushko Smarty Rookie
Joined: 14 Feb 2019 Posts: 5
|
Posted: Sat May 30, 2020 12:01 pm Post subject: many sites - one /compiled/ dir. Problem? |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat May 30, 2020 3:17 pm Post subject: |
|
|
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 |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Sat May 30, 2020 5:14 pm Post subject: |
|
|
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 |
|
sushko Smarty Rookie
Joined: 14 Feb 2019 Posts: 5
|
Posted: Sun May 31, 2020 10:51 am Post subject: |
|
|
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 |
|
sushko Smarty Rookie
Joined: 14 Feb 2019 Posts: 5
|
Posted: Sun May 31, 2020 11:33 am Post subject: |
|
|
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 |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Sun May 31, 2020 2:02 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Jun 01, 2020 12:13 pm Post subject: |
|
|
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 |
|
gordonisnz Smarty Regular
Joined: 05 Sep 2009 Posts: 70
|
Posted: Sat Jun 06, 2020 9:48 am Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Jun 06, 2020 2:20 pm Post subject: |
|
|
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 |
|
gordonisnz Smarty Regular
Joined: 05 Sep 2009 Posts: 70
|
Posted: Sun Jun 07, 2020 12:15 am Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun Jun 07, 2020 12:37 pm Post subject: |
|
|
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 |
|
|