I have created a new folder example inside /var/www/html/ to run some php code. But when I try to access the files via localhost/example it is showing-
Forbidden
You don't have permission to access this resource.Server unable to read htaccess file, denying access to be safe
Apache/2.4.46 (Ubuntu) Server at localhost Port 80
The other files in the /var/www/html folder like localhost/welcome.php are still working. I also changed permission of the files. Should I create htaccess file and if so where? In general what is the process of creating a new project/folder to run php and it's relation to htaccess? A link for in-depth explanation would be much appreciated.
Related
I have been searching for hours now and I cant find a solution. I have tried much to many things to even start listing the things. So please any assistance would be appreciated.
I have changed the htdocs folder location in httpd.conf because I have all my files sync to cloud storage. This works perfectly on my windows machine but on linux not so much. Every thing runs perfectly but when I try to access my htdocs folder (new location) I get a message:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.48 (Unix) OpenSSL/1.1.1k PHP/8.0.10 mod_perl/2.0.11 Perl/v5.32.1
But When I change the location back to the normal location it works perfectly.
I have already gave full access to the folder.
Think of a directory structure as a series of security doors:
/var
/www
/htdocs
If you give someone a key to htdocs (i.e. set the permissions to give a user access) then they can open that door… but only if they can get to it.
If you don't also give them keys to www and var then they can't get into htdocs.
My dedicated server has Debian wheezy installed along with Apache2 php and mysql. ISPConfig3 is installed as the control panel.
After creating a site under ISPConfig and a shell user account with it I uploaded the tar file into the web directory and extracted the files.
The default ispconfig index.html file would display how ever after the extraction the index.php is not getting picked up and after deleting the default index.php i get the error message
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
I tried going directly to www.domain.com/index.php and that doesnt work too.
Do I have to modify anything in apache? Any help would be appreciated.
That error is telling you the server can't read the file (or files) specified in your DirectoryIndex directive, and is trying to display a 403 (security) error document instead, which is doesn't have permission to read either.
You need to check what user your httpd daemon is running as, and make sure that user had at least read permissions to all the files in your DocumentRoot. The best way to do this is to ensure that user is the owner of the files.
On a Redhat/CentOS system, httpd runs as the user "apache"
chown -R apache:apache /var/www/html
I am doing PHP development using Linux OS ,Lampp Apache server.I changed the default root folder htdocs to another folder PHP on my desktop. When I create a hello.php file in the folder ,I can see it in browser and works well.
But I have another folder inside this root folder called 'front_end'.When I try to see it in browser using http://localhost/front_end ,i get access forbidden.
Firebug shows 'Access forbidden'
How can I get access to this folder using localhost?
Another user asked a similar question on stackoverflow ,but it didn't help.
Ubuntu/Apache2/ Forbidden/Permission error
Assuming you have followed the advice regarding the file permissions.
Have you got an index.php file in the front_end directory?
If not that may be why you get 'Access forbidden'. See Apache 403 Forbidden Error and Solution Try accessing the spesific php file in the directory e.g. /front_end/test.php
Permissions on the folder
Check the permissions of the folder.
Use sudo to create the folders.
why for the directories i creat getting rwx---rwxand rw----r-- permisions for the files i create?
I cant access a folder by externally via url which have rwx---rwx permition but can access the file which have rw----r-- permision.
Even I change permision to rwxrwxrwx i can not access the folder.
eg:
http://www.example.com/folder/
Gives me 403 Forbidden
403 forbidden on a folder url usually means that your server has folder browsing disabled, and there's no default document (index.html, index.php, etc...) in the directory. Since there's no default content to server, and the configuration doesn't allow for browsing, you get the forbidden error.
That's probably a pre-caution of your webserver, that denies to offer files that have the executable bit (x) set.
Check your servers documentation about the features it offers and which file permissions are needed to be set to make them work with your webserver.
Okay so basically, I switched my DocumentRoot in Apache2 default to look like this:
DocumentRoot /home/scott/MySite/
That works. I have a file called index.php in that root.
I created a Zend Studio project, pointing to /home/scott/MySite/, and was able to create my project use this line as it's source, modify the .php file and see the change when I navigate to localhost in my browser.
Now, in Zend I created a folder called 'Index', and placed my index.php file in there, because I want to separate my files in the project to things like Database/, Index/, Login/, etc. all different folders. Now, when I navigate to localhost, I get:
You don't have permission to access / on this server.
When I place the index.php file back in the main root it works fine again.
I tried changing the apache2 default DocumentRoot to look like this:
DocumentRoot /home/scott/MySite/Index/
But that doesn't work either. Is there a way to get all this to work and have like my folder structure be able to separate all the logic for the project as well as apache2 still find my index.php and be able to call all the files it calls correctly?
Thanks guys.
Apache is run by www-user which doesn't have the rights to read you home folder. The quick and dirty solution will be to set the persmission to 777 for you home folder