Hero set document_root

If I have a directory structure such as:

/ /libraries/ /other-nonpublic-stuff/ /webroot/ 

How can I set /webroot/ as document_root so that only content is served under the URL of my hero?

I think Procfile may be a way to achieve this, but it is not documented. Already tried things like

 web: php webroot/ 

or

 web: sh boot.sh webroot/ 

or

 web: sh webroot/ 

in Procfile , but I always only got Heroku push rejected, no Cedar-supported app detected

When I click the repo with "index.php" in the root directory, it works fine, and heroku ps just shows one web process running "boot.sh" on, but even then Procfile is explicitly ignored and the hero is served with "/" instead "/ webroot". So there isn’t quite a hint of how I can configure my Procfile :

 Process State Command ------- --------- ---------- web.1 up for 2h sh boot.sh 

I went into the console of my "instance" via heroku run bash and made cat boot.sh It contains the following:

 sed -i 's/Listen 80/Listen '$PORT'/' /app/apache/conf/httpd.conf for var in `env|cut -f1 -d=`; do echo "PassEnv $var" >> /app/apache/conf/httpd.conf; done touch /app/apache/logs/error_log touch /app/apache/logs/access_log tail -F /app/apache/logs/error_log & tail -F /app/apache/logs/access_log & export LD_LIBRARY_PATH=/app/php/ext export PHP_INI_SCAN_DIR=/app/www echo "Launching apache" exec /app/apache/bin/httpd -DNO_DETACH 

Thus, the problem with the Heroku push rejected, no Cedar-supported app detected error Heroku push rejected, no Cedar-supported app detected (when there is no .php file in "/" is obviously resolvable by changing PHP_INI_SCAN_DIR to "/ app / www / webroot", but this is a) impossible and b ) will not solve the problem of using "/ webroot" as a docroot. To fix this, I also had to change "/app/apache/conf/httpd.conf".

Any suggestions?:)

Thanks Josh

+4
source share
3 answers

You need to use mod_rewrite to serve content from "webroot" on Heroku. Try the following in your .htaccess file:

 RewriteEngine On RewriteRule ^\.htaccess$ - [F] RewriteCond %{REQUEST_URI} ="" RewriteRule ^.*$ /webroot/index.php [NC,L] RewriteCond %{REQUEST_URI} !^/webroot/.*$ RewriteRule ^(.*)$ /webroot/$1 RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^.*$ - [NC,L] RewriteRule ^public/.*$ /webroot/index.php [NC,L] 

To get around the detected "cedar-unsupported application", I just created a new index.php file in the root directory of my repository. It doesn't matter what this file contains, but I am adding a few reminders to document these settings in my own applications.

Hope this helps!

+5
source

Actually it comes down to creating a custom boot.sh and telling Procfile to do this by default. I put all this together with the barebones framework over github: https://github.com/winglian/Heroku-PHP

It includes a hook to use your own conf files too, so feel free to play with it and let me know!

+5
source
 web: vendor/bin/heroku-php-apache2 webroot/ 
+1
source

Source: https://habr.com/ru/post/1386541/


All Articles