Answers.Body: <p>Actually that looks good - your webserver user www-data needs to be able to write to files/ (and anything below it); </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-11T15:26:24.137Z
Answers.Text: That is the name of the group. The owner for everything else, including on my dev site is `fclub`. Perhaps the problems I'm having are unrelated.
Answers.UserDisplayName: Christia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-11T18:18:10.370Z
Answers.Text: Make the www-data user and group the owner of your var/www/drupal/sites/default/files (or equivalent)
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-11T15:05:41.673Z
Answers.LastActivityDate: 2017-01-11T15:05:41.673Z
Answers.UserDisplayName: KarinG - Semper IT
Answers.Body: <p>If you getting the error: Uncaught PHP Exception Unable to write to the .../files/civicrm/templates_c&quot; directory.</p>
  <p>You have probably used drush cache clear run under your account and that created the temp files owned by the user running drush.
  SO you can &quot;run drush as the web server user&quot;</p>
  <pre><code>sudo -u apache drush cr
  </code></pre>
  <p>or you can just look at the location [/files/civicrm/templates_c] and after you find the &quot;civicrm&quot; folder at the top, just change ownership so web server can read &amp; write that location (cached files).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-27T21:02:25.323Z
Answers.LastActivityDate: 2020-10-27T21:02:25.323Z
Answers.UserDisplayName: salah-1
Body: <p>I have just upgraded from 4.3.8 to 4.7.15 on Drupal 7.50. Everything went well except the <code>&lt;drupal_root&gt;sites/default/files/civicrm/templates_c</code> directory is rebuilt with the wrong file permissions. The owner should be fclub, not www-data, I think. For example, if I delete this directory in order to solve cached template loading problems and reload the page, it rebuilds itself.</p>
  
  <pre><code>drwxr-sr-x 3 www-data www-data  4096 Jan 11 14:24 templates_c
  </code></pre>
  
  <p>If I change the owner manually to the correct owner, as all other files and directories, there is an error message about not being able to write to temp files in templates_c.</p>
  
  <p>This seems to be the residual affect of something that is causing multiple problems, including possibly outgoing mail, scheduled jobs and showing the menu.</p>
  
  <p>Edit: Here is what it looks like after upgrading on an exact copy/dev site:</p>
  
  <p><code>drwxrwsr-x 3 fclub www-data  4096 Jan  8 21:30 templates_c</code></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-12T03:59:18.717Z
Comments.Text: Congrats on the big upgrade :)
Comments.UserDisplayName: Coleman
Tags: <drupal><upgrade><permissions><templates>
Title: CiviCRM rebuilding templates_c with permissions
ThreadText: # CiviCRM rebuilding templates_c with permissions
  
  (Asked by: username_0 on 2017-01-11)
  
  I have just upgraded from 4.3.8 to 4.7.15 on Drupal 7.50. Everything went well except the `<drupal_root>sites/default/files/civicrm/templates_c` directory is rebuilt with the wrong file permissions. The owner should be fclub, not www-data, I think. For example, if I delete this directory in order to solve cached template loading problems and reload the page, it rebuilds itself.
  
  ```
  drwxr-sr-x 3 www-data www-data  4096 Jan 11 14:24 templates_c
  
  ```
  
  If I change the owner manually to the correct owner, as all other files and directories, there is an error message about not being able to write to temp files in templates\_c.
  
  This seems to be the residual affect of something that is causing multiple problems, including possibly outgoing mail, scheduled jobs and showing the menu.
  
  Edit: Here is what it looks like after upgrading on an exact copy/dev site:
  
  `drwxrwsr-x 3 fclub www-data 4096 Jan 8 21:30 templates_c`
  
  **Tags:** drupal, upgrade, permissions, templates
  
  > **Comments:**
  > **username_1**: Congrats on the big upgrade :)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2017-01-11. Score: 2 | Accepted answer
  
  Actually that looks good - your webserver user www-data needs to be able to write to files/ (and anything below it);
  
  > **Comments:**
  > **username_0**: That is the name of the group. The owner for everything else, including on my dev site is `fclub`. Perhaps the problems I'm having are unrelated.  
  > **username_2**: Make the www-data user and group the owner of your var/www/drupal/sites/default/files (or equivalent)  
  
  ---
  
  ### Answer by username_3 on 2020-10-27. Score: 0
  
  If you getting the error: Uncaught PHP Exception Unable to write to the .../files/civicrm/templates\_c" directory.
  
  You have probably used drush cache clear run under your account and that created the temp files owned by the user running drush.
  SO you can "run drush as the web server user"
  
  ```
  sudo -u apache drush cr
  
  ```
  
  or you can just look at the location [/files/civicrm/templates\_c] and after you find the "civicrm" folder at the top, just change ownership so web server can read & write that location (cached files).
  
  
  ---
  
  