logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: Configuration to serve common files fails on Linux/cPanel
Author
DavidSpector



Joined: 07 Oct 2017
Posts: 15
Location: Maine, USA

PostPosted: Tue 11 Sep '18 2:10    Post subject: Configuration to serve common files fails on Linux/cPanel Reply with quote

The challenge I set myself was to create a common directory to contain php files used by several of my websites, hosted on Linux using WHM and cPanel. My development version, hosted on my home computer that runs Windows, runs perfectly, but the remote production version fails, which is why I'm posting here.

I've spent a lot of time on this, mostly because Apache fails to have a simple report of the URL as it is modified by directives until an actual file pathname is generated. Without such tracing, debugging is a matter of tedious trial and error.

So, I've discovered that there are two types of file access to such a shared directory: first is PHP Include/Require files, which skip a lot of server processing to allow access to the file system. That is fairly easy to handle, using the PHP include_path directive.

An example of this first type is:

require_once("reuse/functions.php"); // Include common functions

The second type of file access is when a user types a URL into browser, or when an HTML page contains off-page Javascript in a file. This potentiall goes through all the processing of Apache, which can be complex. Naturally, I've tried to simplify.

An example of this second type is:

<script src="reuse/test.js"></script>

The end result of my days of work is the following config fragment, which is included in virtual host blocks to enable access to the shared directory, which is /home/reusep/reuse on the remote server, and C:\WAMP\php\lib\reusep\reuse on the local server.

So, with that preliminary discussion (not complete; ask if something is not clear), here is the remote code that fails:

//------------------------------------------//
php_value include_path ".:/home/reusep"
php_value open_basedir "/home:/home/reusep"
AliasMatch ".*/reuse/(.*)" "/home/reusep/$1"
Alias "/reuse" "/home/reusep/reuse"
<Directory "/home/reusep/">
Require all granted
DirectoryIndex index.php index.html
Options -Indexes
</Directory>
//------------------------------------------//
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Tue 16 Oct '18 23:20    Post subject: Reply with quote

Please post in short what is not working. The php includes fail?
Back to top
DavidSpector



Joined: 07 Oct 2017
Posts: 15
Location: Maine, USA

PostPosted: Tue 16 Oct '18 23:52    Post subject: Latest status Reply with quote

Actually, I got it working perfectly by putting the reuse directory in a different place in the file system (/var/web/reuse). But I've been busy trying to fix a probably unrelated problem where I can't write into a subdirectory of reuse (reuse/data), even though the data directory has permissions drwxrwxrwx (I can read okay, just not write). All my experiments are failing, but I know that sometimes bug fixing requires lots of time instead of relying on Web fora for answers.
Back to top


Reply to topic   Topic: Configuration to serve common files fails on Linux/cPanel View previous topic :: View next topic
Post new topic   Forum Index -> Other Software