Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-10-13 23:42:12

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Simplifying symlinks paths on site skeleton (on multi-site)

Since Textpattern added multi-site capabilities, I’ve been using it both on my local development environment (to ease the need of replicating Textpattern core files on each new project) and when deploying websites to stage & production.
My personal experience & findings tell me that there is some —maybe unnecessary— complexity on how symlinks on this kind of setup “ties” all the parts together, and that we could get ridden of that complexity, by simplifying the paths of this symlinks.
In my experience, this also brings the benefit of being able to “detach” or “unnest” the site folder, and keep it separated from the Textpattern core folder, thus, making it easier to do stuff like versioning your work or upgrading one site to a newer Textpattern version (while keeping other websites pinned to a particular version).

These are the changes that have to be done.

1. Files to be edited:

/sites/site1/admin/setup/index.php

- define("txpath", realpath(dirname(__FILE__).'/../../../../textpattern'));
+ define("txpath", realpath(dirname(__FILE__).'/../../textpattern'));

/sites/site1/public/index.php

- define("txpath", realpath(dirname(__FILE__).'/../../../textpattern'));
+ define("txpath", realpath(dirname(__FILE__).'/../textpattern'));

The change on /sites/site1/public/index.php isn’t really necessary, but we do it to be consistent.
———
2. Symlink to be created

On /sites/site1/

textpattern -> ../../textpattern

(that would be: ln -nfs ../../textpattern textpattern while standing at /sites/site1/ folder.)

This symlink is the one that “ties” a particular site (site1) to the /textpattern/ core folder.

Optional: this would be the only symlink that the user would have to recreate/reconfigure in case she wants to “detach” the site (/site1/) and move it somewhere outside of /textpattern-x.y.z/ folder.
———
3. Symlinks to be changed

3.1. On /sites/site1/admin/:

- jquery.js -> ../../../textpattern/jquery.js
+ jquery.js -> ../textpattern/jquery.js

(while standing at /sites/site1/admin/, this is the command: ln -nsf ../textpattern/jquery.js jquery.js)

- textpattern.js -> ../../../textpattern/textpattern.js
+ textpattern.js -> ../textpattern/textpattern.js

(while standing at /sites/site1/admin/, this is the command: ln -nsf ../textpattern/textpattern.js textpattern.js)

- textpattern.css -> ../../../textpattern/textpattern.css
+ textpattern.css -> ../textpattern/textpattern.css

(while standing at /sites/site1/admin/, this is the command: ln -nsf ../textpattern/textpattern.js textpattern.js)

- theme -> ../../../textpattern/theme
+ theme -> ../textpattern/theme

(while standing at /sites/site1/admin/, this is the command: ln -nsf ../textpattern/theme theme)

- txp_img -> ../../../textpattern/txp_img
+ txp_img -> ../textpattern/txp_img

(while standing at /sites/site1/admin/, this is the command: ln -nsf ../textpattern/txp_img txp_img)

3.2. On /sites/site1/public/:

- theme -> ../../../textpattern/theme
+ theme -> ../textpattern/theme

(while standing at /sites/site1/public/, this is the command: ln -nsf ../textpattern/theme theme) (I think this symlink could even be removed, but I’d have to test).

———
4. Create /sites/site1/private/config.php

On that file, txpath points to the textpattern symlink we created on step 2, not to the folder where the real /textpattern/ core folder is located.
Example:

$txpcfg['txpath'] = '/home/development/textpattern-4.5.2/sites/site1/textpattern';.

In case the user opted to “detach” the /site1/ folder from /textpattern-4.5.2/sites/, then, that would be also something like.

$txpcfg['txpath'] = '/home/development/site1/textpattern';.
———
5. Copy and edit .htaccess:

Copy it from /textpattern-x.y.z/.htaccess to sites/site1/public/.htaccess.

5.1. Add this line to .htaccess:

Redirect 301 /textpattern /admin

(just before the <IfModule mod_rewrite.c> will be OK).
This will help with plugins that have the /textpattern/ hard-coded somewhere.

——

That’s all. I consider these changes remove some of the complexity on understanding/following how the multi-site functionality works, and open up a few possibilities, as mentioned above.

I’ll appreciate if other users, and specially, some of our core devs (ideally, artagesw, the mind behind the multi-site installs), find the time to give follow the instructions I posted, and hopefully, give some feedback.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#2 2012-10-13 23:52:05

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Simplifying symlinks paths on site skeleton (on multi-site)

Also, I’ve successfully tried this setup even on cheap hostings that let the user put stuff outside (usually, one level up) of the document root folder.
I particularly mention this, because artagesw commented that the nested directories was a requirement on cheap web hosts.

I have never fully grasped what artagesw wanted to mean, because, if the user is only able to put folders/files at the document root level (and below), how would he use the multi-site functionality, if he can’t set up a different document root for each website? And, viceversa, if the user is able to (re)configure document roots (DocumentRoot) for each website, then he will be able to store stuff outside (ie: above, in the filesystem tree) the document root.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB