Reputation: 7970
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.
Firstly, the problem. This is what I see in the browser
This is what I see in the apache logs:
[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 - -
[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"
[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: http://my_php_site.local/ 127.0.0.1 - -
[11/May/2019:10:55:43 -0400] "GET /favicon.ico HTTP/1.1" 403 585 "http://my_php_site.local/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
Note that apache is trying to execute a .htaccess file in /home/user_name/.htaccess
I do have a .htaccess file in the project folder, and think that's the Apache should look for.
Secondly, my environment. Just in case I miss something I will give here my whole configuration.
The project is located somewhere in my /home/user_name/ folder, and not in /var/www/.
File permissions for .htaccess:
-rwxr-xr-x 1 user_name www-data .htaccess
Project folder permissions:
drwxr-xr-x 11 user_name www-data my_php_site
Since the project is in the home folder I have a rule in my /etc/hosts file:
127.0.0.1 my_php_site.local
The apache config for my site:
<Directory /home/user_name/code/projects/my_php_site>
Require all granted
</Directory>
<VirtualHost *:80>
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
</VirtualHost>
And finally, the .htaccess file itself:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?/$1 [L]
Upvotes: 1
Views: 4690
Reputation: 7970
Solution
Apache — with user group www_data — must be able to traverse the home folder. This means it needs octal value 5
, symbolic r-x.
chmod 750 /home/user_name
One Stack Overflow post mentions permissions for the project folder, but not for the home folder itself: https://askubuntu.com/questions/325498/apache-cant-access-folders-in-my-home-directory
Following steps can also be necessary, depending on versions and system:
Allow Apache to execute files in the home folder
sudo a2enmod userdir
sudo nano /etc/apache2/mods-available/php7.0.conf
Comment this part (put # at the start of each line):
#<IfModule mod_userdir.c>
# <Directory /home/*/public_html>
# php_admin_flag engine Off
# </Directory>
#</IfModule>
sudo nano /etc/apache2/apache2.conf
Add this:
<Directory /home/*/public_html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Upvotes: 1