Why do I get a 403 error when accessing my apache server?
Solution 1
I guess that, Your common
partition may be an ntfs
or fat
partition and You just mounted that partition by clicking on the nautilus side bar icon. Doing so, does not mount the partition with executable
permission, which is required for firefox to be able to execute the file.
The solution:
The easiest solution without using /etc/fstab
file is this:
-
Open a terminal and type
sudo blkid
, give password. -
From the output of the command, see the type of the partition by looking at the corresponding label, i.e
common
. -
If
common
partition happen to be/dev/sda2
, mount that partition with the command:udisks --mount /dev/sda2 --mount-options umask=022
replace,
/dev/sda2
with the actual partition number.
You should now be able to execute/run the files using "Firefox".
Note: You should unmount the partition before using the command. You can unmount it by right-clicking on the partition icon, and select "unmount" from the options
Solution 2
Well, from what i can tell, chmod won't work on directories the way you use it- you really should try chmod -R 777 /path/to/main/directory/
to make it recursive. Then again, You don't want 777 for most things - but the exact permissions level would depend on your setup - I just hand over ownership to www-data and run things with 755 - which dosen't let non owners write, but gives full read/execute powers.
Amusingly the error messages should have given most of this away. For a better writeup on how to set permissions, see this question on webmasters.se
Related videos on Youtube
ish
Updated on September 18, 2022Comments
-
ish over 1 year
Im running Ubuntu 12.04 LTS on a system with 2 GB RAM and a 500 GB HDD.
My hard drive has 4 partitions:
- Partition 1 = 40 gb Windows (NTFS, lable = win32)
- Partition 2 = 320 gb Windows (FAT label = common)
- Partition 3 = 40 gb Ubuntu (EXT4)
I installed
apached2
. Then, to change its defaultwww
directory, I rangksu gedit /etc/apache2/sites-enabled/000-default
and, in the editor, changed the location to/media/common/www
.After that I ran these commands in a terminal:
chmod 777 /media/common/www chmod 777 /media/common/www/*.*
After that I ran:
firefox 127.0.0.1/index.php
It said:
Forbidden You don't have permission to access / on this server. Apache/2.2.22 (Ubuntu) Server at 127.0.0.1 Port 80
Before my changes it was working fine.
How can I run my websites?
-
Eliah Kagan almost 12 yearsNot all questions are answered the day they are posted. You can check out other Ubuntu help resources, but whether or not you decide to use some of those resources now, I counsel patience. Most of us "experts" have lives outside of Ask Ubuntu, school/jobs, and other commitments. We're volunteers who may or may not be able to respond quickly to assist you or anyone else (and you'll find that's the case for the other free support resources too). If that doesn't work for you, you might consider buying support.
-
Eliah Kagan almost 12 yearsWhat do you expect to happen? Does
index.php
exists in that location? Or does not not exist, and you're hoping to see a virtual directory listing? -
ish almost 12 yearsTo be or not to be, that is the question....
-
Anwar almost 12 years@nishan Please consider accepting an answer, if your problem is solved by any one of them. This will help future visitors. Thanks
-
EugeneK almost 12 yearsI covered that and better permissions settings in my answer - the executable bit is for scripts to run - which as i recall, are run by www-data. 755 is what many scripts recommend, and came to mind. "the exact permissions level would depend on your setup" is a VERY important point here.
-
EugeneK almost 12 yearsLets look at the bigger picture here - is he running static sites? He is running a php script, and that would indicate, no, he is running dynamic content through a PHP script. How do PHP scripts run? They need to be executed. What user executes files from PHP? I'm guessing www-data. The top voted answer to the question i referenced agree. You don't. citation needed xkcd.com/285 .
-
Anwar almost 12 yearsI have faced this problem and tested this method, which works. So, I wrote the solution. It is not necessary for you to agree with me.
-
Anwar almost 12 years@neon_overload, I suggest you to setup a web server with document root at a folder in ntfs partition. then mount the partition with nautilus, which mounts without
exec
permission. Then put some.php
file in it, then try access to these files with Firefox. Then let me know what happened. Please, don't overload me with comments without actually you verified that this is not a real solution. I hope you will try this. -
Anwar almost 12 yearsI have tested this today. It is working exactly.