Search code examples
phpxampphttp-status-code-403

403 Error while getting images but not other resources


I have xampp installed on ubuntu (/opt/lampp) and I created a public_html folder (I think it is a symbolic link, I am new with linux) in /home/mustafa/public_html I put my php files and other resources in the public_html folder, the problem is when I want to get things like images I get a 403 Error (Access forbidden) but other files are ok like PHP, CSS, JS files. What is the problem? What should I do?

UPDATE

the output of ls -l /home/mustafa/public_html/templates/assets/images/ in terminal:

total 8
-rwxrwx--- 1 mustafa mustafa 4638 Feb 17 22:06 hbg.png

ls -l /home/mustafa/public_html/templates/assets/style/

total 16
-rw-rw-r-- 1 mustafa mustafa 1571 Feb 23 13:06 style.css
-rw-rw-r-- 1 mustafa mustafa 1567 Feb 23 13:06 style.css~
-rw-rw-r-- 1 mustafa mustafa  689 Feb 23 18:07 style_I.css
-rw-rw-r-- 1 mustafa mustafa  691 Feb 23 17:58 style_I.css~

I moved images to other directories and found that I cannot access any images in public_html and children directories


Solution

  • Looks to me that the other group can't access images based on your ls -l output.

    It's showing rwxrwx--- while your css files are rw-rw-r--.

    You should chmod 664 your images so they match your css files, or chown apache all the files (assuming apache runs as apache) and see if that works.

    To check which process is running apache you can use ps aux | grep httpd

    [user@host ~]$ ps aux | grep httpd
    root      6407  0.0  0.3  11204  3288 ?        Ss   09:06   0:00 /usr/sbin/httpd
    apache    6409  0.0  0.2  11340  2952 ?        S    09:06   0:00 /usr/sbin/httpd
    apache    6410  0.0  0.2  11340  2948 ?        S    09:06   0:00 /usr/sbin/httpd
    apache    6411  0.0  0.2  11340  2940 ?        S    09:06   0:00 /usr/sbin/httpd
    apache    6412  0.0  0.2  11340  2948 ?        S    09:06   0:00 /usr/sbin/httpd
    apache    6413  0.0  0.2  11340  2948 ?        S    09:06   0:00 /usr/sbin/httpd
    apache    6414  0.0  0.2  11340  2948 ?        S    09:06   0:00 /usr/sbin/httpd
    apache    6415  0.0  0.2  11340  2948 ?        S    09:06   0:00 /usr/sbin/httpd
    apache    6416  0.0  0.2  11340  2948 ?        S    09:06   0:00 /usr/sbin/httpd
    root      6426  0.0  0.0   5500   720 pts/1    S+   09:14   0:00 grep httpd