• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

PHP accessible directories outside httpdocs

C

ComTech

Guest
Is it possible to create PHP accessible directories outside httpdocs?

For example, I need to setup a directory to store configuration files that cannot be accessed directly.

Creating a password protected sub directory in httpdocs might work but I would really rather not do it this way.
 
There's a couple of ways to handle this

1. Make your PHP files somewhere on the server and call them via the command line using /usr/bin/php command and then entering the path to your PHP script. This is more useful for Crontab jobs really.

2. Put your files into the tmp directory (it's in the same directory as httpdocs) and call them via include. Files in that directory cannot be accessed via the web server.
 
Does the tmp directory get cleared out systematically? Basically another directory just like tmp is what I would like to create. Typically i name this directory config and store files that get included in my PHP scripts there.
 
Not that I know of. The /tmp directory is provided so that you have a directory outside httpdocs that you can put files in (none of the other directories in the root of your FTP is owned by you, the FTP user).
 
Use the following configuration in apache config:

php_admin_value open_basedir "/tmp:/any_other_path"
 
Back
Top