title: How to run PHP project with Apache from home folder
body: <p>Old codeignitor project just won't run due to apache problem. Tried all the solutions found in other posts and other fora, but luck so far. It's a simple problem and I think it has something to do with permissions. Yet the permission settings seem to be fine.</p>
  
  <p>Firstly, the problem. This is what I see in the browser</p>
  
  <p><a href="https://i.stack.imgur.com/4T16L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4T16L.png" alt="this is what I see in the browser"></a></p>
  
  <p>This is what I see in the apache logs:</p>
  
  <blockquote>
    <p>[Sat May 11 10:55:43.026415 2019] [core:crit] [pid 10672] (13)Permission denied: [client 127.0.0.1:38216] AH00529: /home/user_name/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/home/user_name/' is executable 127.0.0.1 - - </p>
    
    <p>[11/May/2019:10:55:43 -0400] "GET / HTTP/1.1" 403 575 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"</p>
    
    <p>[Sat May 11 10:55:43.314120 2019] [core:crit] [pid 10672] (13)Permission denied: [client 127.0.0.1:38216] AH00529: /home/user_name/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/home/user_name/' is executable, referer: <a href="http://my_php_site.local/" rel="nofollow noreferrer">http://my_php_site.local/</a> 127.0.0.1 - -</p>
    
    <p>[11/May/2019:10:55:43 -0400] "GET /favicon.ico HTTP/1.1" 403 585 "<a href="http://my_php_site.local/" rel="nofollow noreferrer">http://my_php_site.local/</a>" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"</p>
  </blockquote>
  
  <p>Note that apache is trying to execute a .htaccess file in <strong>/home/user_name/.htaccess</strong></p>
  
  <p>I do have a <strong>.htaccess</strong> file in the project folder, and think that's the Apache should look for.</p>
  
  <p>Secondly, my environment. Just in case I miss something I will give here my whole configuration.</p>
  
  <p>The project is located somewhere in my <strong>/home/user_name/</strong> folder, and not in <strong>/var/www/</strong>.</p>
  
  <p>File permissions for .htaccess:</p>
  
  <pre><code>-rwxr-xr-x  1 user_name www-data .htaccess
  </code></pre>
  
  <p>Project folder permissions:</p>
  
  <pre><code>drwxr-xr-x 11 user_name www-data my_php_site
  </code></pre>
  
  <p>Since the project is in the home folder I have a rule in my /etc/hosts file:</p>
  
  <pre><code>127.0.0.1       my_php_site.local
  </code></pre>
  
  <p>The apache config for my site:</p>
  
  <pre><code>&lt;Directory /home/user_name/code/projects/my_php_site&gt;
      Require all granted
  &lt;/Directory&gt;
  &lt;VirtualHost *:80&gt;
          ServerName my_php_site.local
          ServerAlias my_php_site.local
          ServerAdmin webmaster@localhost
          DocumentRoot /home/user_name/code/projects/my_php_site
  
          ErrorLog /home/user_name/code/projects/my_php_site/logs/apache2-error.log
          CustomLog /home/user_name/code/projects/my_php_site/logs/apache2-access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>And finally, the .htaccess file itself:</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?/$1 [L]
  </code></pre>