Mautic Community Forums

Strange Permissions Issue

OS: CentOS 7

PHP Version: 5.6.29

Mautic Version: 2.5.1



This installation has been a massive headache, and after several failed attempts installing in various ways (wget the mautic-master.zip, pull the git repo, download the zip from the main website), all of them run into the same problem.



[Wed Jan 11 15:43:38.403389 2017] [:error] [pid 2821] [client -REDACTED-] exception ‘RuntimeException’ with message ‘Unable to create the cache directory (/var/www/mautic/app/cache/prod)n’ in /var/www/mautic/app/AppKernel.php:521nStack trace:n#0 /var/www/mautic/app/AppKernel.php(489): AppKernel->buildContainer()n#1 /var/www/mautic/app/AppKernel.php(251): AppKernel->initializeContainer()n#2 /var/www/mautic/app/AppKernel.php(109): AppKernel->boot()n#3 /var/www/mautic/app/middlewares/CORSMiddleware.php(92): AppKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)n#4 /var/www/mautic/app/middlewares/CatchExceptionMiddleware.php(44): Mautic\Middleware\CORSMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)n#5 /var/www/mautic/app/middlewares/VersionCheckMiddleware.php(57): Mautic\Middleware\CatchExceptionMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)n#6 /var/www/mautic/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Mautic\Middleware\VersionCheckMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)n#7 /var/www/mautic/vendor/stack/run/src/Stack/run.php(13): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request))n#8 /var/www/mautic/index.php(32): Stack\run(Object(Stack\StackedHttpKernel))n#9 {main}



I have given the apache user (its apache on CentOS, not www-data, I verified what user the service is running under) owner and group of the whole thing. Set permissions to 755, even tried setting them to 777. Rebooted both the server and apache several times. No luck. I have given it every permission I possibly can, and I still get this error.

OS: CentOS 7
PHP Version: 5.6.29
Mautic Version: 2.5.1

This installation has been a massive headache, and after several failed attempts installing in various ways (wget the mautic-master.zip, pull the git repo, download the zip from the main website), all of them run into the same problem.

[Wed Jan 11 15:43:38.403389 2017] [:error] [pid 2821] [client -REDACTED-] exception ‘RuntimeException’ with message ‘Unable to create the cache directory (/var/www/mautic/app/cache/prod)n’ in /var/www/mautic/app/AppKernel.php:521nStack trace:n#0 /var/www/mautic/app/AppKernel.php(489): AppKernel->buildContainer()n#1 /var/www/mautic/app/AppKernel.php(251): AppKernel->initializeContainer()n#2 /var/www/mautic/app/AppKernel.php(109): AppKernel->boot()n#3 /var/www/mautic/app/middlewares/CORSMiddleware.php(92): AppKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)n#4 /var/www/mautic/app/middlewares/CatchExceptionMiddleware.php(44): Mautic\Middleware\CORSMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)n#5 /var/www/mautic/app/middlewares/VersionCheckMiddleware.php(57): Mautic\Middleware\CatchExceptionMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)n#6 /var/www/mautic/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Mautic\Middleware\VersionCheckMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)n#7 /var/www/mautic/vendor/stack/run/src/Stack/run.php(13): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request))n#8 /var/www/mautic/index.php(32): Stack\run(Object(Stack\StackedHttpKernel))n#9 {main}

I have given the apache user (its apache on CentOS, not www-data, I verified what user the service is running under) owner and group of the whole thing. Set permissions to 755, even tried setting them to 777. Rebooted both the server and apache several times. No luck. I have given it every permission I possibly can, and I still get this error.

[quote=18809:@MxyzptlkFishStix]Go to the root of your Mautic directory and type the following commands.

rm -rf app/cache/prod OR sudo -u apache-user app/console cache:clear
find -user root
find -group root

Paste the results.[/quote]
[root@-REDACTED- mautic]# rm -rf app/cache/prod
[root@-REDACTED- mautic]# find -user root
[root@-REDACTED- mautic]# find -group root
[root@-REDACTED- mautic]#

No results.

[root@-REDACTED- mautic]# ls -la total 35384 drwxrwxrwx. 10 apache apache 4096 Jan 11 15:42 . drwxr-xr-x. 5 root root 65 Jan 11 02:49 .. -rwxrwxrwx. 1 apache apache 36127593 Jan 11 15:40 2.5.1.zip drwxrwxrwx. 9 apache apache 253 Jan 4 16:08 app drwxrwxrwx. 2 apache apache 114 Jan 4 16:07 bin -rwxrwxrwx. 1 apache apache 18 Jan 4 16:08 critical_migrations.txt -rwxrwxrwx. 1 apache apache 12862 Jan 4 16:06 favicon.ico drwxrwxrwx. 2 apache apache 86 Jan 4 16:06 .github -rwxrwxrwx. 1 apache apache 1090 Jan 4 16:06 .gitignore -rwxrwxrwx. 1 apache apache 3027 Jan 4 16:06 .htaccess -rwxrwxrwx. 1 apache apache 928 Jan 4 16:06 index.php -rwxrwxrwx. 1 apache apache 38407 Jan 4 16:06 LICENSE.txt drwxrwxrwx. 8 apache apache 86 Jan 4 16:08 media -rwxrwxrwx. 1 apache apache 2264 Jan 4 16:06 offline.php -rwxrwxrwx. 1 apache apache 232 Jan 4 16:06 .php_cs drwxrwxrwx. 12 apache apache 4096 Jan 4 16:06 plugins -rwxrwxrwx. 1 apache apache 149 Jan 4 16:06 robots.txt drwxrwxrwx. 11 apache apache 154 Jan 4 16:06 themes drwxrwxrwx. 2 apache apache 23 Jan 4 16:06 translations -rwxrwxrwx. 1 apache apache 252 Jan 4 16:06 .travis.yml drwxrwxrwx. 46 apache apache 4096 Jan 4 16:07 vendor

[root@-REDACTED- mautic]# ps aux apache 2406 0.0 0.0 380136 12880 ? S Jan11 0:00 /usr/sbin/httpd -DFOREGROUND apache 2407 0.0 0.0 378172 8596 ? S Jan11 0:00 /usr/sbin/httpd -DFOREGROUND apache 2408 0.0 0.0 378172 8576 ? S Jan11 0:00 /usr/sbin/httpd -DFOREGROUND apache 2409 0.0 0.0 378172 7448 ? S Jan11 0:00 /usr/sbin/httpd -DFOREGROUND apache 2410 0.0 0.0 378172 7448 ? S Jan11 0:00 /usr/sbin/httpd -DFOREGROUND apache 2495 0.0 0.0 378172 7448 ? S Jan11 0:00 /usr/sbin/httpd -DFOREGROUND apache 2496 0.0 0.0 378172 7448 ? S Jan11 0:00 /usr/sbin/httpd -DFOREGROUND

Seems I had to shorten it due to some character limit on these forums. I posted what I assume is the relevant bits of ps aux

It’s 777 as an attempt to resolve the issue, I’ll make it 755 once its resolved.

I cannot do ls -la on app/cache/prod because you had me delete that directory

It doesn’t generate, as the error above indicates. I just get that error in my apache logs again.

[code][root@-REDACTED- app]# ls -la
total 96
drwxrwxrwx. 9 apache apache 253 Jan 4 16:08 .
drwxrwxrwx. 10 apache apache 4096 Jan 11 15:42 …
-rwxrwxrwx. 1 apache apache 141 Jan 4 16:06 AppCache.php
-rwxrwxrwx. 1 apache apache 17853 Jan 4 16:06 AppKernel.php
-rwxrwxrwx. 1 apache apache 383 Jan 4 16:06 autoload.php
-rwxrwxrwx. 1 apache apache 41038 Jan 4 16:07 bootstrap.php.cache
drwxrwxrwx. 24 apache apache 4096 Jan 4 16:06 bundles
drwxrwxrwx. 2 apache apache 6 Jan 11 19:25 cache
drwxrwxrwx. 2 apache apache 173 Jan 4 16:08 config
-rwxrwxrwx. 1 apache apache 1422 Jan 4 16:06 console
-rwxrwxrwx. 1 apache apache 13 Jan 4 16:06 .htaccess
drwxrwxrwx. 2 apache apache 6 Jan 4 16:08 logs
drwxrwxrwx. 4 apache apache 224 Jan 4 16:06 middlewares
drwxrwxrwx. 2 apache apache 4096 Jan 4 16:06 migrations
drwxrwxrwx. 3 apache apache 31 Jan 4 16:06 Resources
-rwxrwxrwx. 1 apache apache 5 Jan 4 16:06 version.txt

[root@-REDACTED- cache]# ls -la
total 0
drwxrwxrwx. 2 apache apache 6 Jan 11 19:25 .
drwxrwxrwx. 9 apache apache 253 Jan 4 16:08 …
[/code]

No, I haven’t even finished the install. I can’t pull up the web interface at all to finish it.

I performed the above, restarted apache, refreshed my browser. Same error.

[root@-REDACTED- sbin]# httpd -S AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using -REDACTED-. Set the 'ServerName' directive globally to suppress this message VirtualHost configuration: *:80 -REDACTED- (/etc/httpd/conf.d/vhost.conf:1) ServerRoot: "/etc/httpd" Main DocumentRoot: "/var/www/html" Main ErrorLog: "/etc/httpd/logs/error_log" Mutex rewrite-map: using_defaults Mutex authdigest-client: using_defaults Mutex proxy: using_defaults Mutex authn-socache: using_defaults Mutex default: dir="/run/httpd/" mechanism=default Mutex mpm-accept: using_defaults Mutex authdigest-opaque: using_defaults Mutex proxy-balancer-shm: using_defaults PidFile: "/run/httpd/httpd.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="apache" id=48 Group: name="apache" id=48

The referenced vhost simply contains:

<VirtualHost *:80> DocumentRoot /var/www/mautic </VirtualHost>

the tread is pretty old, however it could be helpful for someone. I have faced with the same error and the issue was in Selinux.

If you have selinux enabled you can test with the following two commands:

semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/mautic(/.*)" restorecon -Rv /var/www/mautic/

The first row sets the default context of the directory to be writable by the apache. The second row restores the default context of the directory.