Template Rebuild Fails With Apache. Works With LiteSpeed. How To Fix?

TheBigK

Well-known member
I recently installed LiteSpeed through WHM plugin and it's working great so far. The only issue is that when I switch back to Apache, I get errors while recompiling the templates. It works fine with LiteSpeed.

Here's the error I'm getting when I rebuild templates with Apache working-

Code:
file_put_contents(/home/USER/public_html/internal_data/templates/S.1,L.1,ad_below_content.php): failed to open stream: Permission denied

XenForo_Application::handlePhpError()
file_put_contents() in XenForo/Template/FileHandler.php at line 95
XenForo_Template_FileHandler->_saveTemplate() in XenForo/Template/FileHandler.php at line 50
XenForo_Template_FileHandler::save() in XenForo/Model/Template.php at line 1116
XenForo_Model_Template->compileAndInsertParsedTemplate() in TMS/Model/Template.php at line 183
TMS_Model_Template->compileAndInsertParsedTemplate() in XenForo/Model/Template.php at line 1029
XenForo_Model_Template->compileTemplateInStyleTree() in XenForo/Model/Template.php at line 983
XenForo_Model_Template->compileNamedTemplateInStyleTree() in XenForo/Model/Template.php at line 923
XenForo_Model_Template->compileAllTemplates() in TMS/Model/Template.php at line 121
TMS_Model_Template->compileAllTemplates() in XenForo/CacheRebuilder/Template.php at line 55
XenForo_CacheRebuilder_Template->rebuild() in XenForo/ControllerHelper/CacheRebuild.php at line 26
XenForo_ControllerHelper_CacheRebuild->rebuildCache() in XenForo/ControllerAdmin/Tools.php at line 78
XenForo_ControllerAdmin_Tools->actionCacheRebuild() in XenForo/FrontController.php at line 313
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
XenForo_FrontController->run() in /home/USER/public_html/admin.php at line 13

It seems to be a a permissions error and I want things to work smoothly under Apache & LiteSpeed. Would appreciate help in fixing this issue.

------------------

My WebHost has given me a specific question I should ask. Here it goes-

Currently there are permissions errors when doing certain actions on the site.
There are several 777 folders in public_html and many subfolders that are also
777.

Inside these subfolders there are files such as the ones in
data/avatars/s/164/ that appear to have mixed ownership and permissions that
is likely causing problems:


-rw-r--r-- 1 crazzzz nobody 1556 Jun 21 22:34 164879.jpg

-rw-r--r-- 1 crazzzz nobody 1297 Jun 22 03:15 164880.jpg

-rw-rw-rw- 1 nobody nobody 1547 Jun 22 17:39 164887.jpg

-rw-r--r-- 1 crazzzz crazzzz 1694 Jun 22 22:42 164888.jpg

-rw-r--r-- 1 crazzzz crazzzz 1694 Jun 23 14:48 164893.jpg

I can fix the permissions on the files but my question is what the permissions
are supposed to be and in what locations.

If the permissions and ownership are being set incorrectly at times would he
like us to try to use Filesystem ACL's to set the default permissions for
files that are created to be 664 instead of 644?

Would he like us to use the group sticky bit on folders to ensure that they
are owned by the group nobody?

How is this ownership and group ownership currently being set?
 
They are set based on how you run your server to what is the most sane default. In some cases, this is 0644, in others it's 0666. You can override this by adding this to your config.php:

$config['chmodWritableValue'] = 0666;

That will force everything created by XF from then on to be 0666 (or 0777 for directories).
 
Could we get answers to following questions?

1) Where does the php script set the chown user, is that also in config.php?

2) In order to fix the current permissions I need to know what are all the files/file locations that need to be writable by php, whether to be created changed or deleted.
 
Could we get answers to following questions?

1) Where does the php script set the chown user, is that also in config.php?

2) In order to fix the current permissions I need to know what are all the files/file locations that need to be writable by php, whether to be created changed or deleted.


1. The files are created by the web server, so the owner and permissions will be set by the php handler and however that is configured. (for example, on my server the php handler is run under a specific user account, to keep the owner and group the same)

2. The data and internal_data folders and all files in them.
 
Could we get answers to following questions?

1) Where does the php script set the chown user, is that also in config.php?

2) In order to fix the current permissions I need to know what are all the files/file locations that need to be writable by php, whether to be created changed or deleted.

If you have access via SSH change the permissions directly. type ps aux | grep httpd
look under that account the process httpd is running, for example is the nobody account simply change the owner of all files with the following command.
chown -R nobody data
chown -R nobody internal_data
If you want to set permissions to all files in this directory.
chmod -R 755 data
chmod -R 755 internal_data
 
Back
Top Bottom