PHP Fatal Error: Uncaught Exception 'RuntimeException' with message 'Unable to create the store directory #16

Closed
opened 2 years ago by dinosaw · 9 comments
dinosaw commented 2 years ago

Environment

  • GIST version or GIT commit: c9fee1ea42
  • PHP Version: 5.6.40
  • GIT version. 1.8.3.1
  • HTTPD (Nginx, Apache2): Apache/2.4.6
  • DBMS (MySQL, SQLite, PostgreSQL): 5.5.60-MariaDB

Description

After a successful install with no errors, and the DocumentRoot pointing to the correct directory, I am seeing these in my Apache's error logs:

[Wed Jul 10 16:14:48.729107 2019] [:error] [pid 17280] [client 10.12.213.184:35008] PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'Unable to create the store directory (/home/admin/web/gist.test.dev/public_html/gist/app/bootstrap.php.d/../../cache/).' in /home/admin/web/gist.test.dev/public_html/gist/vendor/symfony/http-kernel/HttpCache/Store.php:42\nStack trace:\n#0 /home/admin/web/gist.test.dev/public_html/gist/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php(46): Symfony\\Component\\HttpKernel\\HttpCache\\Store->__construct('/home/admin/web...')\n#1 /home/admin/web/gist.test.dev/public_html/gist/vendor/pimple/pimple/lib/Pimple.php(126): Silex\\Provider\\HttpCacheServiceProvider->Silex\\Provider\\{closure}(Object(Gist\\Application))\n#2 /home/admin/web/gist.test.dev/public_html/gist/vendor/pimple/pimple/lib/Pimple.php(83): Gist\\Application::{closure}(Object(Gist\\Application))\n#3 /home/admin/web/gist.test.dev/public_html/gist/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php(38): Pimple->offse in /home/admin/web/gist.test.dev/public_html/gist/vendor/symfony/http-kernel/HttpCache/Store.php on line 42

[Wed Jul 10 16:14:52.024490 2019] [:error] [pid 3932] [client 10.12.213.184:35012] PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'Unable to create the store directory (/home/admin/web/gist.test.dev/public_html/gist/app/bootstrap.php.d/../../cache/).' in /home/admin/web/gist.test.dev/public_html/gist/vendor/symfony/http-kernel/HttpCache/Store.php:42\nStack trace:\n#0 /home/admin/web/gist.test.dev/public_html/gist/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php(46): Symfony\\Component\\HttpKernel\\HttpCache\\Store->__construct('/home/admin/web...')\n#1 /home/admin/web/gist.test.dev/public_html/gist/vendor/pimple/pimple/lib/Pimple.php(126): Silex\\Provider\\HttpCacheServiceProvider->Silex\\Provider\\{closure}(Object(Gist\\Application))\n#2 /home/admin/web/gist.test.dev/public_html/gist/vendor/pimple/pimple/lib/Pimple.php(83): Gist\\Application::{closure}(Object(Gist\\Application))\n#3 /home/admin/web/gist.test.dev/public_html/gist/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php(38): Pimple->offse in /home/admin/web/gist.test.dev/public_html/gist/vendor/symfony/http-kernel/HttpCache/Store.php on line 42

The web page itself doesn't load an error message, simply a white screen.

## Environment * GIST version or GIT commit: c9fee1ea427b56ce918127ac9cf3e748ed41e14a * PHP Version: 5.6.40 * GIT version. 1.8.3.1 * HTTPD (Nginx, Apache2): Apache/2.4.6 * DBMS (MySQL, SQLite, PostgreSQL): 5.5.60-MariaDB ## Description After a successful install with no errors, and the DocumentRoot pointing to the correct directory, I am seeing these in my Apache's error logs: ``` [Wed Jul 10 16:14:48.729107 2019] [:error] [pid 17280] [client 10.12.213.184:35008] PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to create the store directory (/home/admin/web/gist.test.dev/public_html/gist/app/bootstrap.php.d/../../cache/).' in /home/admin/web/gist.test.dev/public_html/gist/vendor/symfony/http-kernel/HttpCache/Store.php:42\nStack trace:\n#0 /home/admin/web/gist.test.dev/public_html/gist/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php(46): Symfony\\Component\\HttpKernel\\HttpCache\\Store->__construct('/home/admin/web...')\n#1 /home/admin/web/gist.test.dev/public_html/gist/vendor/pimple/pimple/lib/Pimple.php(126): Silex\\Provider\\HttpCacheServiceProvider->Silex\\Provider\\{closure}(Object(Gist\\Application))\n#2 /home/admin/web/gist.test.dev/public_html/gist/vendor/pimple/pimple/lib/Pimple.php(83): Gist\\Application::{closure}(Object(Gist\\Application))\n#3 /home/admin/web/gist.test.dev/public_html/gist/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php(38): Pimple->offse in /home/admin/web/gist.test.dev/public_html/gist/vendor/symfony/http-kernel/HttpCache/Store.php on line 42 [Wed Jul 10 16:14:52.024490 2019] [:error] [pid 3932] [client 10.12.213.184:35012] PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to create the store directory (/home/admin/web/gist.test.dev/public_html/gist/app/bootstrap.php.d/../../cache/).' in /home/admin/web/gist.test.dev/public_html/gist/vendor/symfony/http-kernel/HttpCache/Store.php:42\nStack trace:\n#0 /home/admin/web/gist.test.dev/public_html/gist/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php(46): Symfony\\Component\\HttpKernel\\HttpCache\\Store->__construct('/home/admin/web...')\n#1 /home/admin/web/gist.test.dev/public_html/gist/vendor/pimple/pimple/lib/Pimple.php(126): Silex\\Provider\\HttpCacheServiceProvider->Silex\\Provider\\{closure}(Object(Gist\\Application))\n#2 /home/admin/web/gist.test.dev/public_html/gist/vendor/pimple/pimple/lib/Pimple.php(83): Gist\\Application::{closure}(Object(Gist\\Application))\n#3 /home/admin/web/gist.test.dev/public_html/gist/vendor/silex/silex/src/Silex/Provider/HttpCacheServiceProvider.php(38): Pimple->offse in /home/admin/web/gist.test.dev/public_html/gist/vendor/symfony/http-kernel/HttpCache/Store.php on line 42 ``` The web page itself doesn't load an error message, simply a white screen.
Owner

Hello,

Is the web server allowed to create the directory /home/admin/web/gist.test.dev/public_html/gist/cache and write into?

Create the directory /home/admin/web/gist.test.dev/public_html/gist/cache and allow the webserver to create files and directories into.

Simon

Hello, Is the web server allowed to create the directory `/home/admin/web/gist.test.dev/public_html/gist/cache` and write into? Create the directory `/home/admin/web/gist.test.dev/public_html/gist/cache` and allow the webserver to create files and directories into. Simon
Poster

Yes permissions and ownership is all correctly set on all directories and files. The cache directory was already present, but I went ahead and deleted it, recreated it, applied the appropriate permissions/ownership once again, and I'm still experiencing the same issue.

Yes permissions and ownership is all correctly set on all directories and files. The cache directory was already present, but I went ahead and deleted it, recreated it, applied the appropriate permissions/ownership once again, and I'm still experiencing the same issue.
Owner

Can you create web/test.php with this content:

<pre><?php echo shell_exec('id; ls -lah ../'); ?></pre>

What's the result after browsing the page (http://your-gist-domain/test.php)?

Can you create `web/test.php` with this content: ``` <pre><?php echo shell_exec('id; ls -lah ../'); ?></pre> ``` What's the result after browsing the page (http://your-gist-domain/test.php)?
Poster

PHP file contents:

# cat web/test.php 
<pre><?php echo shell_exec('id; ls -lah ../'); ?></pre>

Page Results:

uid=1001(admin) gid=1001(admin) groups=1001(admin),48(apache)
total 160K
drwxr-xr-x  9 root  root   311 Jul 10 16:14 .
drwxr-x--x  8 admin admin  126 Jul 10 15:41 ..
drwxr-xr-x  8 admin admin  198 Jul 10 15:52 .git
-rw-r--r--  1 admin admin  224 Jul 10 15:42 .gitignore
-rw-r--r--  1 admin admin  145 Jul 10 16:14 .htaccess
-rw-r--r--  1 admin admin  282 Jul 10 15:42 ISSUE_TEMPLATE.md
-rw-r--r--  1 admin admin  35K Jul 10 15:42 LICENSE
-rw-r--r--  1 admin admin 1.1K Jul 10 15:42 Makefile
-rw-r--r--  1 admin admin  551 Jul 10 15:42 README.md
drwxr-xr-x  6 admin admin  130 Jul 10 15:47 app
-rw-r--r--  1 admin admin  860 Jul 10 15:42 composer.json
-rw-r--r--  1 admin admin  86K Jul 10 15:54 composer.lock
drwxr-xr-x  4 admin admin   30 Jul 10 15:42 data
drwxr-xr-x  7 admin admin   92 Jul 10 15:55 node_modules
-rw-r--r--  1 admin admin 1.2K Jul 10 15:55 package-lock.json
-rw-r--r--  1 admin admin  165 Jul 10 15:42 package.json
-rw-r--r--  1 admin admin 1017 Jul 10 15:47 propel.yaml
drwxr-xr-x  3 admin admin   18 Jul 10 15:42 src
drwxr-xr-x 16 admin admin  232 Jul 10 15:54 vendor
drwxr-xr-x  4 admin admin  123 Jul 12 15:20 web
**PHP file contents**: ``` # cat web/test.php <pre><?php echo shell_exec('id; ls -lah ../'); ?></pre> ``` **Page Results**: uid=1001(admin) gid=1001(admin) groups=1001(admin),48(apache) total 160K drwxr-xr-x 9 root root 311 Jul 10 16:14 . drwxr-x--x 8 admin admin 126 Jul 10 15:41 .. drwxr-xr-x 8 admin admin 198 Jul 10 15:52 .git -rw-r--r-- 1 admin admin 224 Jul 10 15:42 .gitignore -rw-r--r-- 1 admin admin 145 Jul 10 16:14 .htaccess -rw-r--r-- 1 admin admin 282 Jul 10 15:42 ISSUE_TEMPLATE.md -rw-r--r-- 1 admin admin 35K Jul 10 15:42 LICENSE -rw-r--r-- 1 admin admin 1.1K Jul 10 15:42 Makefile -rw-r--r-- 1 admin admin 551 Jul 10 15:42 README.md drwxr-xr-x 6 admin admin 130 Jul 10 15:47 app -rw-r--r-- 1 admin admin 860 Jul 10 15:42 composer.json -rw-r--r-- 1 admin admin 86K Jul 10 15:54 composer.lock drwxr-xr-x 4 admin admin 30 Jul 10 15:42 data drwxr-xr-x 7 admin admin 92 Jul 10 15:55 node_modules -rw-r--r-- 1 admin admin 1.2K Jul 10 15:55 package-lock.json -rw-r--r-- 1 admin admin 165 Jul 10 15:42 package.json -rw-r--r-- 1 admin admin 1017 Jul 10 15:47 propel.yaml drwxr-xr-x 3 admin admin 18 Jul 10 15:42 src drwxr-xr-x 16 admin admin 232 Jul 10 15:54 vendor drwxr-xr-x 4 admin admin 123 Jul 12 15:20 web
Owner

drwxr-xr-x 9 root root 311 Jul 10 16:14 . means that admin is not allowed to create the directory cache directly below /home/admin/web/gist.test.dev/public_html/gist/.

You could try 2 different things:

  • root@server # chgrp admin /home/admin/web/gist.test.dev/public_html/gist/ && chmod g+w /home/admin/web/gist.test.dev/public_html/gist/
  • or root@server # mkdir /home/admin/web/gist.test.dev/public_html/gist/cache && chown admin:admin /home/admin/web/gist.test.dev/public_html/gist/
```drwxr-xr-x 9 root root 311 Jul 10 16:14 .``` means that `admin` is not allowed to create the directory `cache` directly below `/home/admin/web/gist.test.dev/public_html/gist/`. You could try 2 different things: * `root@server # chgrp admin /home/admin/web/gist.test.dev/public_html/gist/ && chmod g+w /home/admin/web/gist.test.dev/public_html/gist/` * or `root@server # mkdir /home/admin/web/gist.test.dev/public_html/gist/cache && chown admin:admin /home/admin/web/gist.test.dev/public_html/gist/`
Poster

Thank you for pointing that out. That was a very obvious oversight on my part so my apologies.

I unfortunately have a new problem however, and I feel like it may have something to do with the DocumentRoot possibly. Currently, Apache uses the /web directory as the DocumentRoot. This is confirmed as navigating to the site, it reads the index page and shows some of the page. Unfortunately, a lot of the scripts and assets are not being found. In the Apache logs they show 404. Additionally on the actual index page, it shows the following error:

Error: Symfony\Component\HttpKernel\Exception\NotFoundHttpException

No route found for "GET /gist/"

Here is an image.

I know configuring the VirtualHost in the Apache configuration is the most ideal way to set the DocumentRoot, but in this particular use case it's not possible. That said, I'm using an .htaccess file to accomplish this. Here are its contents:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^gist.test.dev/gist$ [NC,OR]
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) web/$1 [L]

Any ideas on this one? Sorry for so many questions.

Thank you for pointing that out. That was a very obvious oversight on my part so my apologies. I unfortunately have a new problem however, and I feel like it may have something to do with the `DocumentRoot` possibly. Currently, Apache uses the `/web` directory as the DocumentRoot. This is confirmed as navigating to the site, it reads the index page and shows *some* of the page. Unfortunately, a lot of the scripts and assets are not being found. In the Apache logs they show `404`. Additionally on the actual index page, it shows the following error: ``` Error: Symfony\Component\HttpKernel\Exception\NotFoundHttpException No route found for "GET /gist/" ``` Here is [an image](https://i.imgur.com/rrCePvC.png). I know configuring the VirtualHost in the Apache configuration is the most ideal way to set the DocumentRoot, but in this particular use case it's not possible. That said, I'm using an `.htaccess` file to accomplish this. Here are its contents: ``` RewriteEngine on RewriteCond %{HTTP_HOST} ^gist.test.dev/gist$ [NC,OR] RewriteCond %{REQUEST_URI} !web/ RewriteRule (.*) web/$1 [L] ``` Any ideas on this one? Sorry for so many questions.
Owner

If the DocumentRoot is web, the the home page is / instead of /gist. That's why you have a 404 error. So if http://gist.test.dev/ equals /home/admin/web/gist.test.dev/public_html/gist/web/ using DocumentRoot /home/admin/web/gist.test.dev/public_html/gist/web/, then use the given .htaccess (https://gitnet.fr/deblan/gist/src/branch/master/web/.htaccess).

But if http://gist.test.dev/ equals /home/admin/web/gist.test.dev/public_html/gist/ using DocumentRoot /home/admin/web/gist.test.dev/public_html/gist/ and if you want to perform a fake DocumentRoot /home/admin/web/gist.test.dev/public_html/gist/web/ using your htaccess, you gonna have security issue because of accessible directories like /app.

If the DocumentRoot is `web`, the the home page is `/` instead of `/gist`. That's why you have a 404 error. So if `http://gist.test.dev/` equals `/home/admin/web/gist.test.dev/public_html/gist/web/` using `DocumentRoot /home/admin/web/gist.test.dev/public_html/gist/web/`, then use the given `.htaccess` (https://gitnet.fr/deblan/gist/src/branch/master/web/.htaccess). But if `http://gist.test.dev/` equals `/home/admin/web/gist.test.dev/public_html/gist/` using `DocumentRoot /home/admin/web/gist.test.dev/public_html/gist/` and if you want to perform a fake `DocumentRoot /home/admin/web/gist.test.dev/public_html/gist/web/` using your htaccess, you gonna have security issue because of accessible directories like `/app`.
Poster

Alright. At this point it appears it's not an issue with the application, moreso my server's configuration. Thank you for helping me out thus far! I'll go ahead and close out this issue.

Alright. At this point it appears it's not an issue with the application, moreso my server's configuration. Thank you for helping me out thus far! I'll go ahead and close out this issue.
dinosaw closed this issue 2 years ago
Owner

You're welcome!

You're welcome!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.