# Config.inc.php - relative paths (Docker local environment)

**URL:** <https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477>\
**Category:** Development\
**Tags:** installation, revo-3\
**Created:** [March 2, 2023, 10:02am UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477 "2023-03-02T10:02:37Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![maciej\_ww](https://community.modx.com/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@maciej\_ww](https://community.modx.com/u/maciej_ww)\
**Post date:** [March 2, 2023, 10:02am UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/1 "2023-03-02T10:02:37Z")

</div>

Hello Everyone!

I’m creating a development environment on windows 10 + wsl ubuntu + docker.  
I use this repo [GitHub - modxcms/docker-modx: Docker image for MODX](https://github.com/modxcms/docker-modx) (with some changes to match my needs), **docker-compose up** runs and everything is getting built as expected.

I have two scenarios:

1. I have a new project to start - that’s sorted i can quickly begin to developing with the current state of my development environment.
2. I have an existing project on the live site and I need to add some features and then publish it on the server. What i need to do now is import the live database into my docker database and download all MODx files into Docker. The problem is that on the live site, I have different paths than on the local machine (/home/user/public\_html/ on live site and /var/www/html/ on the local machine) so i will need to manually change paths and i wondering if there is way to make these paths relative (config.inc.php - in core folder) during installation for example in some environmental variables or something.  
Ideal scenario i download files and DB, put in to correct places, clear the cache and its works on my local machine.

Please let me know any thoughts.  
thank you!

---

<div class="post-metadata">

**Author:** ![camicase82](https://community.modx.com/user_avatar/community.modx.com/camicase82/32/2033_2.png) [@camicase82](https://community.modx.com/u/camicase82)\
**Post date:** [March 2, 2023, 12:48pm UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/2 "2023-03-02T12:48:33Z")

</div>

Hi there, at least on 2X what I’ll do is to run the installer after copying the db and all the files to fix all paths, you can try that on 3X, also why you have different paths if you are using docker? I mean, the whole idea behind containers is that you keep the exact same configuration across enviroments

---

<div class="post-metadata">

**Author:** ![maciej\_ww](https://community.modx.com/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@maciej\_ww](https://community.modx.com/u/maciej_ww)\
**Post date:** [March 2, 2023, 1:45pm UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/3 "2023-03-02T13:45:16Z")

</div>

Hello,  
Thank you for your response!  
The reason why paths are different is that the live site is published on cPanel where the absolute directory is “/home/user/public\_html” and on the local docker web server(apache2) is “/var/www/html/”.  
Do you have anything in mind to make them the same (like on live site)?

thanks in advance

---

<div class="post-metadata">

**Author:** ![camicase82](https://community.modx.com/user_avatar/community.modx.com/camicase82/32/2033_2.png) [@camicase82](https://community.modx.com/u/camicase82)\
**Post date:** [March 2, 2023, 1:53pm UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/4 "2023-03-02T13:53:02Z")

</div>

No problem and wellcome to the community!, you could create a simlink inside your Dockerfile or just totally update the routes of the base image, and then update the routes of the config.xlm inside your docker-entrypoint.sh to mimic what you have on your cPanel

Also would be a good idea to check at [Gitify](https://github.com/modmore/Gitify), this is the kind of tool I normally use to manage versions and deploy to different servers since you can cherry pick what you are moving, and many times you just want to move things like chunks, snippets and resources, but preserve user information

---

<div class="post-metadata">

**Author:** ![bruno17](https://community.modx.com/user_avatar/community.modx.com/bruno17/32/71_2.png) [@bruno17](https://community.modx.com/u/bruno17)\
**Post date:** [March 2, 2023, 1:55pm UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/5 "2023-03-02T13:55:26Z")

</div>

usually, you have to set these pathes only once in the config.inc.php and in the config.core.php files on each installation.  
When exporting stuff from one installation to the other, you don’t include them.

---

<div class="post-metadata">

**Author:** ![maciej\_ww](https://community.modx.com/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@maciej\_ww](https://community.modx.com/u/maciej_ww)\
**Post date:** [March 2, 2023, 3:12pm UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/6 "2023-03-02T15:12:20Z")

</div>

Yes, that is also an option just take everything expect config files.  
thank you

---

<div class="post-metadata">

**Author:** ![maciej\_ww](https://community.modx.com/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@maciej\_ww](https://community.modx.com/u/maciej_ww)\
**Post date:** [March 2, 2023, 3:19pm UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/7 "2023-03-02T15:19:53Z")

</div>

Thank you for this response.  
Correct me if I’m wrong, if I update my docker env variables to match the live site path “/home/user/public\_html” I think MODx would not find these files unless I create these directories inside “/var/www/html”. However, the full path to the core would need to be “/var/www/html/home/user/public\_html/core/” - not sure if that make sense or maybe i misunderstood you.

thank you!

---

<div class="post-metadata">

**Author:** ![dimmy](https://community.modx.com/user_avatar/community.modx.com/dimmy/32/56_2.png) [@dimmy](https://community.modx.com/u/dimmy)\
**Post date:** [March 2, 2023, 3:34pm UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/8 "2023-03-02T15:34:02Z")

</div>

You could use dirname instead

In our case we have the core folder outside of the public\_html:

```auto
if (!defined('MODX_CORE_PATH')) {
    $modx_core_path = dirname( __FILE__ , 3) .'/core/';
    define('MODX_CORE_PATH', $modx_core_path);
}
if (!defined('MODX_PROCESSORS_PATH')) {
    $modx_processors_path = dirname( __FILE__ , 3) .'/core/model/modx/processors/';
    define('MODX_PROCESSORS_PATH', $modx_processors_path);
}
if (!defined('MODX_CONNECTORS_PATH')) {
    $modx_connectors_path = dirname( __FILE__ , 3) .'/public_html/connectors/';
    $modx_connectors_url = '/connectors/';
    define('MODX_CONNECTORS_PATH', $modx_connectors_path);
    define('MODX_CONNECTORS_URL', $modx_connectors_url);
}
if (!defined('MODX_MANAGER_PATH')) {
    $modx_manager_path = dirname( __FILE__ , 3) .'/public_html/manager/';
    $modx_manager_url = '/manager/';
    define('MODX_MANAGER_PATH', $modx_manager_path);
    define('MODX_MANAGER_URL', $modx_manager_url);
}
if (!defined('MODX_BASE_PATH')) {
    $modx_base_path = dirname( __FILE__ , 3) .'/public_html/';
    $modx_base_url = '/';
    define('MODX_BASE_PATH', $modx_base_path);
    define('MODX_BASE_URL', $modx_base_url);
}

```

---

<div class="post-metadata">

**Author:** ![markh](https://community.modx.com/user_avatar/community.modx.com/markh/32/36_2.png) [@markh](https://community.modx.com/u/markh)\
**Post date:** [March 2, 2023, 3:41pm UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/9 "2023-03-02T15:41:27Z")

</div>

Be aware that the config file is replaced in its entirety when running the setup. So any customisation to it, other than adding static values to the `$config_options` array, **will** be removed the next time you run an upgrade.

---

<div class="post-metadata">

**Author:** ![camicase82](https://community.modx.com/user_avatar/community.modx.com/camicase82/32/2033_2.png) [@camicase82](https://community.modx.com/u/camicase82)\
**Post date:** [March 2, 2023, 3:50pm UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/10 "2023-03-02T15:50:19Z")

</div>

I think that @bruno17 sugestion would be the best, related to the docker changes, is a bit more complex than just changing the env vars, you’ll have to modify the base [Dockerfile](https://hub.docker.com/r/maki/modx/dockerfile) and then update the values inside your docker-entrypoint.sh betwen lines 106~112

[Here](https://stackoverflow.com/questions/51393494/how-to-change-the-document-root-in-php7-1-apache-from-docker-compose-yml) is a explanation on how to update the document root inside the PHP docker image

---

<div class="post-metadata">

**Author:** ![maciej\_ww](https://community.modx.com/letter_avatar_proxy/v4/letter/m/8dc957/32.png) [@maciej\_ww](https://community.modx.com/u/maciej_ww)\
**Post date:** [March 2, 2023, 4:15pm UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/11 "2023-03-02T16:15:18Z")

</div>

Oh this is great, i think i would go in this direction!  
I have .env file with all information for yml config part, so the only thing to update will be Dockerfile.

thank you!

---

<div class="post-metadata">

**Author:** ![system](https://community.modx.com/user_avatar/community.modx.com/system/32/2_2.png) [@system](https://community.modx.com/u/system)\
**Post date:** [March 4, 2023, 4:15pm UTC](https://community.modx.com/t/config-inc-php-relative-paths-docker-local-environment/6477/12 "2023-03-04T16:15:26Z")

</div>

Closed on March 4, 2023, 4:15pm UTC

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.
