Troubles with WPLMS on Docker Container from Bitnami

Home Forums Legacy Support Support queries Setup issues Troubles with WPLMS on Docker Container from Bitnami

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #260587
    lendasdab42
    Spectator
    Hi, first of all, I want to thank for your awesome theme, WPLMS is great. My name is Rafael, I'm a PHP Developer and I'm supporting another guys from my company to get Wordpress and WPLMS working. I'm deploying the application on AWS Ec2 Instance. Planning to auto-scale the server on the future, I opted to deploy the application on Docker Containers, so it's way more easy to handle it. I'm using Bitnami Docker Images, which comes with wordpress at latest version and all environment configurations. Well, that being said, I figured out that WPLMS have some problems with absolute path (i.e. php magic constants DIR and FILE when running on Bitnami Wordpress Docker Container from Bitnami. (Which is a trusted library of software packages). I saw this problem when I tried to use vibe-shortcodes. The file wp-content/plugins/vibe-shortcodes/tinymce/get_wp.php fails to request wp-load.php because rely on FILE constant to get the root path to wordpress folder, as the image bellow: get_wp.php This happens because the Wordpress is located on: /opt/bitnami/wordpress but the wp-content folder that is inside is symlinked and the original location is bitnami/wordpress/wp-content. Bitnami do that to allow persist this files when docker container goes down. This is normal, that's how docker works. So, when the FILE constant returns the value from original file location, the require_once is not able to find wp-load.php file, because this file is located on /opt/bitnami/wordpress I fix that problem using the $_SERVER['SCRIPT_FILENAME'] superglobal instead of FILE contant. My get_wp.php is now linke this: changed get_wp.php But to do that It was necessary to hard code this file. Besides, I don't know how many files is using FILE So I think the best thing to do is open this request, explaining the problem and asking more compatibility with Bitnami Wordpress Docker Container. When I'm installing the theme, the same problems occurs, but I worked around to solve.
    #260593
    lendasdab42
    Spectator
    Hi, there are some problems with text format on post above. Please ignore the post above and read this one bellow: Well, that being said, I figured out that WPLMS have some problems with absolute path (i.e. php magic constants DIR and FILE)  when running on Bitnami Wordpress Docker Container from Bitnami. (Which is a trusted library of software packages). I saw this problem when I tried to use vibe-shortcodes. The file wp-content/plugins/vibe-shortcodes/tinymce/get_wp.php fails to request wp-load.php because rely on __FILE__ constant to get the root path to wordpress folder, as the image bellow: get_wp This happens because the Wordpress is located on: /opt/bitnami/wordpress but the wp-content folder that is inside is symlinked and the original location is bitnami/wordpress/wp-content Bitnami do that to allow persist this files when docker container goes down. This is normal, that's how docker works. So, when the __FILE__ constant returns the value from original file location, the require_once is not able to find wp-load.php file, because this file is located on /opt/bitnami/wordpress   I fix the problem using the $_SERVER['SCRIPT_FILENAME'] superglobal instead of __FILE__ constant. My get_wp.php is now like this: get_wp_changed But to do that It was necessary to hard code this file. Besides, I don't know how many files is using __FILE__ Or you guys can look at wp-config.php and use ABSPATH constant instead of FILE So I think the best thing to do is open this request, explaining the problem and asking more compatibility with Bitnami Wordpress Docker Container. When I'm installing the theme, the same problems occurs, but I do the same workaroud to solve.
    #260898
    Anshuman Sahu
    Keymaster
    Well this is not at all related to theme . FILE is a traditional magic constant . Even woocommerce and wordpress itself used this contant .Would you recommend them as well to change their code ?  
    #265894
    lendasdab42
    Spectator
    Hi Alex. You might be right that "this is not at all related to theme" but, my intentions was not to point issues or errors on theme. I just want to help increase more compatibility with all available platforms. Which is a good thing to all of us. Anyway, thank you for support and, please, if it is possible, bring this question to your dev team, I think they will thank you/me to try to help improve wplms :)
    #266105
    Anshuman Sahu
    Keymaster
    sure im sharing this with Mr. vibe .  
    #266132
    MrVibe
    Keymaster
    This is something we are also interested in pursuing.  Docker and Kubernetes with auto-scalability. Would be interested to know how you're planning to add a persistent storage across docker instances. Can you try following change :
    1. In Vibe shortcodes the file get_wp.php  , use below code.
    <?php // $absolute_path = FILE; // $path_to_file = explode( 'wp-content', $absolute_path ); // $path_to_wp = $path_to_file[0];   if ( ! function_exists( 'get_home_path' ) ) { include_once ABSPATH . '/wp-admin/includes/file.php'; } $path_to_wp = get_home_path(); // Access WordPress require_once( $path_to_wp . '/wp-load.php' );
    #266134
    MrVibe
    Keymaster
    The FILE constant is recommended by WordPress for getting the plugin url relative to file.
    #266135
    MrVibe
    Keymaster
    I do not think we;re including file like above, anywhere. This was standard script for generating shortcode popup generators.
    #266986
    lendasdab42
    Spectator
    Hi, Mr.Vibe About the persistence, I suggest you to look this technique to create a docker volume on host. Look, this is exactly how I'm doing by now. https://github.com/bitnami/bitnami-docker-wordpress-nginx#persisting-your-application There's one point of attention: Bitnami stores the wp-content directory on /bitnami/wordpress, wp-config.php too and some other files. but all another files is on /opt/bitnami/wordpress and wp-content is a symlink pointing to /bitnami/wordpress/wp-content. I think they do this because they have an initial shell script that run on when container is bringing up with the command "docker-compose up -d". This shell script could overwrite these files if they were placed in the same location /opt/bitnami. So they created the symlink solution. (that's why I opened this issue). If you allow me, let me share some experience and an overview about my application. despite this, about auto-scalability I will face this situation soon. By now I'm using only one t2.micro instance on aws (1 GB ram, 1vCpu), with a docker and docker-compose to bring up a LEMP stack (Linux, Nginx, MariaDB and PHP). So by now I have 2 main containers: 1 - wordpress 1 - mariadb (and a certbot container to renew my LetsEncrypt certificate automatically) All on the same host, by now. My plans to next week is to move my database to amazon RDS and free cpu and memory from this instance only to wordpress. On the future, I think the persistence with auto-scalling could be done using the aws ECS to manage the scaling and the aws EFS as a shared filesystem across the instances. But it's too early to me to build and opinion about that. I will learn how to do this soon.
    #266989
    lendasdab42
    Spectator
    Mr. Vibe, about the code above you've shared with me, I will test it soon and share with you the results.
    #266990
    lendasdab42
    Spectator
    #267327
    lendasdab42
    Spectator
    Hi, Mr. Vibe About the code you asked me to try, unfortunately not work, I got some errors. Here's the feedback: After click at some options below: the get_wp.php is called and our code throws this error: I've  checked why and tried to debug: ABSPATH is not defined yet, maybe due to Wordpress Load Sequence. So I tried to put the abspath hardcoded only to see if the rest of code will run nice: But I have no success with that too, because another error happens: And I couldn't checked this one.
    #267892
    MrVibe
    Keymaster
    ok, just remove the line above and add the direct path to wp-load.php as you can not load a wordpress file without loading the wordpress.  
    #268292
    lendasdab42
    Spectator
    All Right. We can close this topic. Thank you.
    #268510
    Veronica
    Moderator
    closing the topic.
Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘Troubles with WPLMS on Docker Container from Bitnami’ is closed to new replies.