PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label open-basedir. Show all posts
Showing posts with label open-basedir. Show all posts

Tuesday, September 20, 2022

[FIXED] How to disable "ini_set" and "exec" for a particular VirtualHost?

 September 20, 2022     apache, httpd.conf, open-basedir, php, virtualhost     No comments   

Issue

I'm already using open_basedir to restrict a VirtualHost to a certain directory:

<VirtualHost *:80>
  ServerName test.example.com
  DocumentRoot /sites/test/www
  php_admin_value "open_basedir" "/sites/test/www"
  <Directory />
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

How to disable the use of ini_set or exec, but only for this particular VirtualHost (and not for the others)?


Solution

You're looking for the disable_functions entry in your php.ini. So you want a different php.ini for your particular VirtualHost. That could be done via "PHPINIDir"

<virtualhost *:80>
    ServerName www.example.com
    DocumentRoot /path/to/example.com
    PHPINIDir /whatever/path/to/php.ini
</virtualhost>

UPDATE: I removed the example with php_admin_value because, as others have noted in the comments, it wouldn't work with this particular setting. As was discussed here: php_admin_value disable_functions not working ( sorry ... should have looked it up beforehand).



Answered By - Daniel Heinrich
Answer Checked By - Timothy Miller (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, February 4, 2022

[FIXED] jpgraph Warning (2): file_exists() [function.file-exists]: open_basedir restriction in effect

 February 04, 2022     cakephp, cakephp-2.0, jpgraph, open-basedir     No comments   

Issue

I'm having a trouble on making the jpgraph's image work on the web. When I run it in localhost the jpgraphs works but when I uploaded it there is an error message:

Warning (2): file_exists() [function.file-exists]: open_basedir restriction in effect. File(/usr/share/fonts/truetype/arialbd.ttf) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) [APP/Vendor/jpgraph/jpgraph-3.5.0b1/src/jpgraph_ttf.inc.php, line 505]

and this

Warning (2): file_exists() [function.file-exists]: open_basedir restriction in effect. File(/usr/share/fonts/truetype/arialbd.ttf) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) [APP/Vendor/jpgraph/jpgraph-3.5.0b1/src/jpgraph_ttf.inc.php, line 510]

If you guys have any questions for clarifications please don't hesitate to ask. Thank You in advance


Solution

This is actually an issue with your PHP configuration, not CakePHP.

From http://php.net/manual/en/ini.core.php

Limit the files that can be accessed by PHP to the specified directory-tree

Open your php.ini, look for the open_basedir line, and comment it out.

Restart webserver and you should be good to go.



Answered By - robmcvey
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing