Apache2 error 403 on localhost
Tofloor
poster avatar
savanweylyn
deepin
2017-02-03 02:17
Author
Hi all,

whenever i try to access the website I'm working on i get error 403 Permission denied. I've tried a few things they mention on the sites below:
  • https://askubuntu.com/questions/561201/apache-2-4-10-giving-403-forbidden-issue-on-ubuntu-14-04
  • https://askubuntu.com/questions/817575/apache-403-forbidden-error
  • https://bbs.archlinux.org/viewtopic.php?id=83481
And even tried reinstalling apache, but nothing helped.

Reply Favorite View the author
All Replies
Feng Yu
deepin
2017-02-03 02:26
#1
Please check the apache log in /var/log/apache2/.
Reply View the author
savanweylyn
deepin
2017-02-04 07:15
#2
Edited by savanweylyn at 2017-2-3 16:24
https://bbs.deepin.org/post/134610
Please check the apache log in /var/log/apache2/.

I've copied the error.log to here:
http://myubuntuserver.duckdns.org/log/errors.txt
I've tried to set DocumentRoot to /media/weylyn1/data/www, but after I couldn't fix the 403 error, i've changed it back to /var/www. But it still complains about that path.
Reply View the author
Feng Yu
deepin
2017-02-05 21:18
#3
本帖最后由 abcfy2 于 2017-2-5 23:33 编辑

apache use a low permission user named www-data. You should make sure this user has read access to the path at least.

And I find your log contains this:
  1. [client 127.0.0.1:50058] AH00037: Symbolic link not allowed or link target not accessible: /var/www
Copy the Code


So your /var/www is a soft link? If so, you must add an option "+FollowSymLinks" to the Directory context, see: https://httpd.apache.org/docs/2.4/mod/core.html#Options

But this option is the default config, if you don't modify the default options, that I think the reason is that your target path does not allow www-data user to read.

Please check the permissions of your path.
Also, if you have any questions, you can also upload your apache2 config in /etc/apache2/.
  1. tar zcvf apache2.conf.tar.gz /etc/apache2/
Copy the Code
Then upload the apache2.conf.tar.gz file in your work directory.
Reply View the author
savanweylyn
deepin
2017-02-06 07:29
#4
https://bbs.deepin.org/post/134610
本帖最后由 abcfy2 于 2017-2-5 13:24 编辑

apache use a low permission user named www-data. You sho ...

/var/www is not a softlink, it's a real folder and is owned by www-data. And it's permissions are [pre]drwxr-xr-x  3 www-data root   4096 febr   2 11:07 www[/pre] so www-data HAS permissions to read it.
Reply View the author
Feng Yu
deepin
2017-02-06 07:37
#5
https://bbs.deepin.org/post/134610
/var/www is not a softlink, it's a real folder and is owned by www-data. And it's permissions are  ...

Would you please upload your /etc/apache2/ directory? Let me check if you have any config issues.

Also, the /var/log/apache2/ would be helpful.
Reply View the author
savanweylyn
deepin
2017-02-07 04:32
#6
Edited by savanweylyn at 2017-2-6 14:34
https://bbs.deepin.org/post/134610
Would you please upload your /etc/apache2/ directory? Let me check if you have any config issues.
...
  1. sudo apt purge apache2
  2. sudo apt autoremove --purge
  3. sudo rm -rf /etc/apache2
  4. sudo mv /var/www/html /media /weylyn1/htdocs # Just to make sure that the permissions are set by the system
  5. sudo apt install apache2
  6. sudo mv /media /weylyn1/htdocs/* /var/www/html/
Copy the Code
And now it's finally working!
Reply View the author