0

I'm trying to serve a php file outside my document root with apache 2.4 and php5-fpm. My virtual host looks like this:

<VirtualHost *:8080>
    ServerName www.domain.tld
    DocumentRoot /data/projects/domain/www

    ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/data/projects/domain/www/$1
    DirectoryIndex _start.php
</VirtualHost>

This website uses a webapp which is installed in /opt/vendor/webapp/. I already have an Alias to serve the static files of the webapp, this works perfectly.

But the css less and minified javascript files are generated on the fly by a php file. This doesn't seem to work because the php file is outside my DocumentRoot.

Is there a way to serve php files outside of your DocumentRoot with php-fpm?

Edit: The requests to the css and javascript files that are generated on the fly are rewritten to a php file called _generator.php. The error in de apache error log is:

[proxy_fcgi:error] [pid 22105:tid 140602507183872] [client xxx.xxx.xxx.xxx:47544] AH01071: Got error 'Primary script unknown\n'
2
  • Have you tried to add another ProxyPassMatch directive with a js|css regular expression?
    – Glueon
    Oct 3, 2014 at 14:34
  • The requests to css/js files are rewritten to _generator.php with rewrite engine. Also, the error in the apache error log is from proxy_fcgi.
    – Leon
    Oct 3, 2014 at 14:52

1 Answer 1

0

Typically, when a PHP application's code is moved outside of the DocumentRoot there is a front controller script that acts as a bootstrap to load other PHP code. It may setup include paths, load a configuration PHP file in another location--like your ...vendor/webapp directory, and execute some logic to figure out what code to run based on the web request URI.

I see that you have a file called _start.php for the directory index. This looks like a front controller script; which is accessible from the web. Without more information about the code in _start.php or ...vendor/webapp there's really not enough information to answer your dynamic CSS question.

Try to read the code in ...vendor/webapp for assistance (README?) configuring it to be served. My guess is that your front controller needs to be told where to find the site code (...vendor/webapp).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .