How to include a file that is inside another folder on the same server

Asked

Viewed 47 times

1

I’ve seen several other similar questions here in the O.R., and outside the community, but none were really helpful, some options that in theory should have worked, but somehow didn’t work.

I currently manage a Droplet at Digitalocean where I use the control panel Runcloud, on the server I have 3 sites configured, and 2 use Wordpress and 1 to save files.

/home/runcloud/webapps/
                      /domain1.com/
                                  /plugins/meu-plugin/...
                      /domain2.com/
                                  /wp-content/plugins/meu-plugin/...
                      /domain3.com/
                                  /wp-content/plugins/meu-plugin/...

How could I include a file that is inside the domain1.com on my two Wordpress sites.

The idea is to create a plugin to request that files, ai instead of sending the plugin to both sites, I just send the updates to the domain1.com

I have tried using the following options:

 include($_SERVER['DOCUMENT_ROOT'].'../../plugins/meu-plugin/plugin.php');

 $file = '/home/runcloud/webapps/domain1.com/plugins/meu-plugin/plugin.php';
 include($file);

in theory it should work, but somehow it didn’t work.

2 answers

1

Try to include from the direct link.

include(https:http://www.example.com/home/runcloud/webapps/domain1.com/plugins/meu-plugin/plugin.php');

changes the www.example.com/ for your website.

or you can try: include($_SERVER['DOCUMENT_ROOT'].'/plugins/meu-plugin/plugin.php'); without the .. but that depends on what you’ve defined as root of your server.

  • already tried it, I tried to beat drum and nothing seems to work, the files are in the same way of example, I only changed the name of the plugin same because it is extended.

0


I solved the problem one way "easy" so to speak, was using NGINX which is the standard of Runcloud and for some reason it wasn’t working, so I created another Droplet and installed the LAMP standard that the Digitalocean available, then configured my sites, after that worked perfectly the inclusion of the file, I believe it is for this using the apache, what got "bugged" was just the style and the js inside the file, but this was easily solved added only the path of the Wordpress folder in the file '/wp-content/plugins/meu-plugin/css/style.css'.

Fiz um plugin para chamar o arquivo e adicionei dentro do diretório dos plugin do Wordpress
include('/var/www/dominio.com/meu_plugin/plugin.php');

/var/www/
        /domain1.com/
                    /meu_plugin/plugin.php
                    /public_html/wp-content/plugins/meu-plugin/plugin-include.php

I didn’t do the test but I believe it also works outside the domain folder /var/www/.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.