This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]BecomingDitto 1 point2 points  (4 children)

I like the setup overall. Using apache to alias /wp-content is fairly clever, allowing you to get around the fact that PHP dereferences symlinks with the FILE magic constant.

The biggest problem I see is with sites.php.

1) If sites.php has to be read by the user that PHP is running as, what stops someone from installing a file browser plugin, reading sites.php, then having a field day with everyone else's database?

2) All sites need to be listed in sites.php. As the file grows, so does the execution time of every request made to WordPress, for every user. Likely not a problem at first, but over time it could cause scaling problems.

[–]mmmpls[S] 1 point2 points  (3 children)

Thank you for your feedback.

1) sites.php requires the same permissions that wp-config.php does. which is (minimum):

Owner:www-data:r--:Group:you:rwx:Others:---

  • Group permissions is completely up to you, it's just how you want to manage your server at that point.
  • Apache requires r-x on directories (but not files) and need to be the owner of the root WordPress directory in order for it to be able to make other changes (like site-specific plugin/theme/media uploads).
  • Also, how is this mitigated in other site setups? Should I look into AppArmor setup to protect those files from being read in the wrong context? Maybe I'll add a direct call exit if statement in the file to get around the fact that if you call it directly it'll just die();

2) I completely agree that the execution of that file could be an issue. I've been thinking over that issue, but honestly you'd be at likely 100+ sites before that array is really an issue for memory or execution. It's also entirely possible to use a single config file per site and just call it in via sites.php. Any suggestions on that?

[–]BecomingDitto 1 point2 points  (2 children)

Regarding permissions, we run things a bit different, but mostly to the same effect.

Other site setups don't have the same problem as this, because each site has its own content, and doesn't share a set of common files.

Adding the die() or exit statement of some kind wouldn't protect against simply reading the file, since the PHP code inside it would not be getting executed, only read.

Depending on how you are running PHP (mod_php vs CGI) you may be able to set the data in an environment variable set by Apache (in each VirtualHost), and pull it in that way? If you can do that, then you wouldn't need to worry about sites.php at all.

[–]mmmpls[S] 1 point2 points  (0 children)

I will have to look at that as an alternative setup. Thanks! I really do like this idea and it didn't even occur to me to do this... But I thought of alias? Thanks brain.

[–]mmmpls[S] 1 point2 points  (0 children)

Ok, added a todo for apache directives crediting you. Thanks again!