Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR 403 in loading resources like CSS and JS in my index.php

I'm in Linux, Elementary OS, and installed lampp in opt.

My CSS and JS won't load. When I inspect my page through browser. The console says Failed to load resource: the server responded with a status of 403 (Forbidden) I'm really sure that my directories are correct.This is my workspace

This is the error enter image description here

enter image description here

like image 921
Mark Vizcarra Avatar asked Sep 10 '13 16:09

Mark Vizcarra


People also ask

How do I fix Error 403 API?

Check the Requested URL The most common cause of a 403 Forbidden Error is simply inputting an incorrect URL. As discussed before, many tightly secured web servers disallow access to improper URLs. This could be anything from accessing a file directory to accessing a private page meant for other users.

What is the reason for error 403?

The HTTP 403 Forbidden response status code indicates that the server understands the request but refuses to authorize it. This status is similar to 401 , but for the 403 Forbidden status code re-authenticating makes no difference.


2 Answers

You need to change permissions on the folder bootstrap/css. Your super user may be able to access it but it doesn't mean apache or nginx have access to it, that's why you still need to change the permissions.

Tip: I usually make the apache/nginx's user group owner of that kind of folders and give 775 permission to it.

like image 179
Edson Horacio Junior Avatar answered Sep 17 '22 17:09

Edson Horacio Junior


Find out the web server user

open up terminal and type lsof -i tcp:80

This will show you the user of the web server process Here is an example from a raspberry pi running debian:

COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME apache2  7478 www-data    3u  IPv4 450666      0t0  TCP *:http (LISTEN) apache2  7664 www-data    3u  IPv4 450666      0t0  TCP *:http (LISTEN) apache2  7794 www-data    3u  IPv4 450666      0t0  TCP *:http (LISTEN) 

The user is www-data

If you give ownership of the web files to the web server:

chown www-data:www-data -R /opt/lamp/htdocs 

And chmod 755 for good measure:

chmod 755 -R /opt/lamp/htdocs 

Let me know how you go, maybe you need to use 'sudo' before the command, i.e. sudo chown www-data:www-data -R /opt/lamp/htdocs

if it doesn't work, please give us the output of: ls -al /opt/lamp/htdocs

like image 26
Joeme Avatar answered Sep 17 '22 17:09

Joeme