Issues with session permissions

I have an Ubuntu server (Ubuntu 16.04.2 LTS) using Webuzo by Softaculous and was having permission issues with InvoiceNinja. To fix it (or try to) I deleted the directoy and moved the mysql database to the new install. Unfortunately I get the below errors.

A PHP Error was encountered

Severity: Warning

Message: fopen(/tmp/ip_sessionc389c55d3143915a6da4a6971a284f754b85a50b0fbefc463dd470337234d5d7e1942dae): failed to open stream: Permission denied

Filename: drivers/Session_files_driver.php

Line Number: 172

Backtrace:

File: /home/sangie/sunitai-invoice/application/third_party/MX/Loader.php
Line: 199
Function: _ci_load_library

File: /home/sangie/sunitai-invoice/application/core/Base_Controller.php
Line: 32
Function: library

File: /home/sangie/sunitai-invoice/application/core/User_Controller.php
Line: 25
Function: __construct

File: /home/sangie/sunitai-invoice/application/core/Admin_Controller.php
Line: 20
Function: __construct

File: /home/sangie/sunitai-invoice/application/modules/clients/controllers/Clients.php
Line: 23
Function: __construct

File: /home/sangie/sunitai-invoice/index.php
Line: 327
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: session_start(): Failed to read session data: user (path: /tmp)

Filename: Session/Session.php

Line Number: 143

Backtrace:

File: /home/sangie/sunitai-invoice/application/third_party/MX/Loader.php
Line: 199
Function: _ci_load_library

File: /home/sangie/sunitai-invoice/application/core/Base_Controller.php
Line: 32
Function: library

File: /home/sangie/sunitai-invoice/application/core/User_Controller.php
Line: 25
Function: __construct

File: /home/sangie/sunitai-invoice/application/core/Admin_Controller.php
Line: 20
Function: __construct

File: /home/sangie/sunitai-invoice/application/modules/clients/controllers/Clients.php
Line: 23
Function: __construct

File: /home/sangie/sunitai-invoice/index.php
Line: 327
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/sangie/sunitai-invoice/vendor/codeigniter/framework/system/core/Exceptions.php:271)

Filename: helpers/url_helper.php

Line Number: 564

Backtrace:

File: /home/sangie/sunitai-invoice/application/core/User_Controller.php
Line: 28
Function: redirect

File: /home/sangie/sunitai-invoice/application/core/Admin_Controller.php
Line: 20
Function: __construct

File: /home/sangie/sunitai-invoice/application/modules/clients/controllers/Clients.php
Line: 23
Function: __construct

File: /home/sangie/sunitai-invoice/index.php
Line: 327
Function: require_once

If I do a "chmod /tmp 777 -R"the issue goes away for a few minutes but comes back again. Looking into my permissions of files/folders in my tmp directory, I see:

-rwx------ 1 sangie sangie   168 Jun 15 11:56 ip_sessionc389c55d3143915a6da4a6971a284f752aa1b8e4e972a8739b38e63d74fba504c0ecb71e
-rw------- 1 apache apache   168 Jun 15 12:09 ip_sessionc389c55d3143915a6da4a6971a284f754b85a50b0fbefc463dd470337234d5d7e1942dae
-rwx------ 1 sangie sangie   264 Jun 15 12:06 ip_sessionc389c55d3143915a6da4a6971a284f75a6527cb6c4dcc8a6f9f76f07460dfa9d098583b7
-rwx------ 1 sangie sangie   168 Jun 15 11:41 ip_sessionc389c55d3143915a6da4a6971a284f75f62e977016d4ac638a81ab414e39685b83793b41

Well that’s weird! Webuzo uses the current user to run apache so the user should be sangie, my username. Instead it’s apache. Since Webuzo/InvoicePlane is running on sangie, it now can’t access the session file it created.

I didn’t have this issue with 1.5.2 and I don’t really want to revert unless I have to. This seems to be a server configuration issue.

Indeed. Your temporary storage is not properly configured to be used by InvoicePlane. Please check your permissions for the folder so your web server (guess it’s Apache) is allowed to use it or switch to another folder in your global configuration. For help for both options, contact either your administrator or search the documentation of Webuzo.