include PHP scripts

Frank Bonnemeier March 18, 2018

Dear Support

I need to include PHP scripts in pages. Failed so far.

What I tried:

- Using HTML macro and copied files to /var/atlassian/application-data/confluence/script . ok for html, but no output for php.

- Assuming /var/atlassian/application-data/confluence is the home directory of the browser I include the file by URL: https://bbv-deutschland.de/confluence/script/test.php . Result: URL not found.

Thanks for advise how to do this.

Thanks,

Frank

3 answers

0 votes
Daniel Schulz November 26, 2019

Hello Community,

is there a solution to the problem? I read the article and unfortunately only the iFrame works for me. But I would like to include the php script directly on the Confluence page. I put the php script on the whitelist and followed the instructions. Unfortunately nothing is displayed on the Confluence page. Can anyone help me?

Thanks in advance

Daniel

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 26, 2019

Hello Daniel,

Welcome to Atlassian Community! It's great to have you. To troubleshoot, you can try going to the Developer Tools > Network section of your browser, and see if any errors are thrown when Confluence tries to access the PHP file.

If you continue to have issues, please confirm the following:

  1.  You are attempting to include an Apache-hosted PHP script in a Confluence page, using the html-include macro as instructed. Is that right?
  2. In the html-include macro, can you show us how you've entered the page URL?
  3. Let me know your Confluence version as well!

Thank you for your help.

Regards,

Shannon

0 votes
Pavel Potcheptsov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2018

It's not possible to just "include" .php files by design.

To be able to do this you need either apache+php or nginx+php-fpm. You can install that to same host where confluence is running. If your confluence runs on  default port then it's ok to use default 80 port for nginx/apache.

When your .php files work through apache, i.e. http://your.host/file.php then you can add HTML macro and insert URL with php there by using iframe tag.

Above works very well for me.

php2.pngphp1.png

0 votes
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 19, 2018

Hi Frank,

We have an article explaining this below:

If you can confirm PHP and Apache are on the same server, you can add the URL to your whitelist in Confluence as instructed.

Could you give that a try?

Regards,

Shannon

Frank Bonnemeier March 19, 2018

Hi Shannon

I'm aware of this article. And, yes, both are on the same server.

But whitelist is for URLs only (what I understand at least). I cannot enter pathes to files.

Also, turning off whilelist doesn't make a difference.

 

Is it - in principle - possible to include local files directly or only via browser URLs?

Best regards,

Frank

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 19, 2018

The way to include "local files" is to make them accessible on a url.

Frank Bonnemeier March 19, 2018

understood.

My confluence home directory is

/var/atlassian/application-data/confluence/

That's where https://bbv-deutschland.de/confluence/ is point to, isn't it?

This works with html files but not with php files.

Example:

https://bbv-deutschland.de/confluence/test.html works

https://bbv-deutschland.de/confluence/test.php doesn't work. No output.

Best regards,

Frank

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 19, 2018

Frank,

Your /confluence path is just part of your context path and that's why it's trying to load your php file inside Confluence.

I would recommend storing it somewhere else on the server and just link to the full path that way.

Shannon

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events