-1

I try share a WordPress plugin directory between two sites. The problem is that the scripts are working but not the URLS. They are output in a strage way that the path is in there when it should not. And this has nothing to do with the plugin or anything, this works right of I not use symlinks.

http://demo.secret.local/bla/wp-content/plugins/var/www/shared/plugins/debug-bar/css/debug-bar.css?ver=20111209

sudo chown -R "$USER":www-data /var/www
find /var/www -type f -exec chmod 0660 {} \;
sudo find /var/www -type d -exec chmod 2770 {} \;

tryed 777 permissions as well but seem not to make a difference

/var/www/shared/plugins <- Files are working, URLS get screweed up
/var/www/secret.com/htdocs/wp-content/plugins      -> symlinked to -> /var/www/shared/plugins
/var/www/demo.secret.com/htdocs/wp-content/plugins -> symlinked to -> /var/www/shared/plugins

.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName secret.local

    DocumentRoot /var/www/secret.com/htdocs

    <Directory />
        Options FollowSymLinks Indexes
        AllowOverride All
    </Directory>

    <Directory /var/www/secret.com/htdocs/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order deny,allow
        deny from all
        allow from 127.0.0.1
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/secret.com-error.log
    CustomLog ${APACHE_LOG_DIR}/secret.com-access.log combined

</VirtualHost>

Same for the other VHost

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName demo.secret.local

    DocumentRoot /var/www/demo.secret.com/htdocs

    <Directory />
        Options FollowSymLinks Indexes
        AllowOverride All
    </Directory>

    <Directory /var/www/demo.secret.com/htdocs/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order deny,allow
        deny from all
        allow from 127.0.0.1
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/demo.secret.com-error.log
    CustomLog ${APACHE_LOG_DIR}/demo.secret.com-access.log combined

</VirtualHost>

I had this setup before and was actually just symlinking to the other site. I am not sure but I think I had it before that It was actaully working when I disabled the site where I linked to. Thats why I now moved the shared folder completely out of both sites. But now I have the same issue. This is driving me crazy.

I could just mount the directory there and be fine but then if I accidentally delete the mounted folder I will delete the files. And this should work with symlinks. Please tell me how.

I also tryed a 3rd directory block to /var/www/shared with the same rules as the .com directorys but this not seem to make any difference.

Sidequestion: I do not really understand this section.

    <Directory />
        Options FollowSymLinks Indexes
        AllowOverride All
    </Directory>
0

1 Answer 1

1

One of the typical solution to share content with multiple VirtualHosts is with the apache Alias directive:

<VirtualHost *:80>
    ServerName secret.local
    Alias /wp-content/plugins/ /var/www/shared/plugins/
    ...
</VirtualHost>
<VirtualHost *:80>
    ServerName demo.secret.local
    Alias /wp-content/plugins/ /var/www/shared/plugins/
    ...
</VirtualHost>

If this works for you or not depends on the type of shared content, e.g. if a script tries to source for example a file like ../../wd-config.php to read the correct database connection string, it will try to source the file in /var/www/ instead of the VirtualHosts' DocumentRoot and therefor fail.

1
  • I know Alias, the thing is I don't know if WordPress plugins need to reference stuff in this way. My guess is bad programmed ones actually do so I not really like this. I guess I will just use a mount --bind as log nobody has a better solution for me. Dec 11, 2013 at 1:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .