Xampp Access Forbidden php
I’m a windows user. I’ve been using xampp for quite a while but suddenly none of my .php files are working now! I get this error message: Access forbidden! You don’t have permission to access the requested object. It is either read-protected or not readable by the server. If you think this is a server error, please contact the webmaster. Error 403 localhost Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.16 I can see the list of my .php files in localhost/Practice (Practice is the folder where I’ve saved my files) The file even opens whenever I click on it. But when I click on any ‘submit’ button inside any of my files, it gives this error. Please help! I updated xampp from 1.8.1 to 1.8.2 but still the same problem persists!
17 Answers 17
Try with this code below, add it in your virtual host config. Add this lines to httpd-vhosts.conf file:
/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Order Deny,Allow Allow from all Require all granted
I fixed the same issue by this way. Hope it helps.
after changes please test it in incognito because you redirected by cache
I had the problem that my virtual hosts that linked to a folder that was not on C: wouldn’t work and give me the mentioned error, but this answer finally fixed it!
if used ubuntu operating system then check chmod of /Practice folder change read write permission
Open terminal press shortcut key Ctrl+Alt+T Goto
$ cd /opt/lampp/htdocs/
and change folder read write and execute permission by using chmod command
e.g folder name is practice and path of folder /opt/lampp/htdocs/practice
$ sudo chmod 777 -R Practice
what is chmod and 777 ? visit this link http://linuxcommand.org/lts0070.php
Could you please elaborate more your answer adding a little more description about the solution you provide?
The way I resolved this was setup error logs correctly, first
DocumentRoot "D:/websites/test/" ServerName test.dev ErrorLog "D:/websites/test/logs/error.log" CustomLog "D:/websites/test/logs/access.log" common AllowOverride none Require all granted
After this error are being logged into «D:/websites/test/logs/» make sure to create logs folder yourself. The exact error that was recorded in error log was
AH01630: client denied by server configuration:
Which pointed me to correct solution using this link which said for the above error
is required. My sample sample code above fixes the problem by the way.
sudo chmod -R 0777 /Applications/XAMPP/xamppfiles/htdocs/myprojectname
NOTE: remember to change ‘myprojectname’ to your actual project name. Also, make sure the project is on the root directory of htdocs or change the path accordingly.
The only solution that worked for me after spending hours researching online
sudo chmod -R 0777 /opt/lampp/htdocs/projectname
Edit this file C:\xampp\apache\conf\httpd.conf Change:
AllowOverride none Require all denied
AllowOverride All Options All Allow from all Order allow,deny
I am using xxamp using ubuntu 16.04 — and its working fine for me
DocumentRoot "/opt/lampp/htdocs/" ServerAdmin localhost Options Indexes FollowSymLinks AllowOverride All Require all granted
Go in to your Xampp folder xampp/apache/conf/extra/httpd-xampp.conf
#close XAMPP sites here . . . Deny from all . .
#close XAMPP sites here . . . Allow from all . .
I’ve tried that! Did not work.. As I said, I can access localhost, but .php is not getting processed by any interpreter.
Look at the link you submit button is heading to , maybe its not a valid link. It has to submit the form to a file in the xampp directory where the others are. Also look for naming mistakes , maybe it is example.php but you wrote exampel.php 😉
Well I got it! Was some error in my code! Hadn’t included some required files! That’s why it was showing an error only when I clicked the submit button 🙂 Thanks anyways 🙂
For me it was solved instantly by the following
- Going to C:\xampp\apache\conf\extra
- Editing inside the file httpd-xampp.conf
- Edit the file as follows:
find the following lines by cont+f:
Alias /phpmyadmin "C:/xampp/phpMyAdmin/" AllowOverride AuthConfig Require local ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
only change local —-> all granted, so it becomes like this
Alias /phpmyadmin "C:/xampp/phpMyAdmin/" AllowOverride AuthConfig Require all granted ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
After this the localhost will stop showing the error and will show admin panel. I found this solution in a video here: https://www.youtube.com/watch?v=MvYyEPaNNhE
Did you change any thing on the virtual-host before it stop working ?
Add this line to xampp/apache/conf/extra/httpd-vhosts.conf
DocumentRoot "C:/xampp/htdocs" ServerAdmin localhost Options Indexes FollowSymLinks AllowOverride All Require all granted
I had this problem after moving the htdocs folder to outside the xampp folder. If you do this then you need to change the document root in httpd.conf. See https://stackoverflow.com/a/1414/3543329.
I had the same problem. So I got remembere. Yesterday I had commented this code in htttp-xampp.conf
Alias /phpmyadmin "C:/xampp/phpMyAdmin/" # AllowOverride AuthConfig # Require local # ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
SO I can access my localhost using other system on same network(LAN/WIFI) as it make localhost require local.
Alias /phpmyadmin "C:/xampp/phpMyAdmin/" AllowOverride AuthConfig # Require local ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
and now its working on my local machine and also localhost is accessible using other systems on same LAN/WIFI.
WAY-1
- this is for a specific project/ folder inside htdocs folder
- open your cmd/ terminal and go to the htdocs folder directory for me it was ( /opt/lampp/htdocs/ ) and I used the ( cd directory_name ) command for changing the directory cd /opt/lampp/htdocs/
- then run the below command sudo chmod 777 -R Project-Folder-Name
replace the Project-Folder-Name with your project folder name
WAY-2
- this is for all projects/ folders inside lampp folder
- open your cmd/ terminal and go to the lampp folder directory for me it was ( /opt/lampp/ ) and I used the ( cd directory_name ) command for changing the directory cd /opt/lampp/
- then run the below command sudo chmod 777 -R htdocs
A. #LoadModule vhost_alias_module modules/mod_vhost_alias.so B. AllowOverride none Require all denied
Replace with:
A. LoadModule vhost_alias_module modules/mod_vhost_alias.so B: Options FollowSymLinks AllowOverride All Order allow,deny Allow from all
This opens your whole disk up to any hacker that successfully gains access to your web server. Thats so very nice of you to make their lives nice and easy!
If you dont understand what a section of the httpd.conf file does, its better to look it up in that manual before giving such bad advice to others
I got the same error because somehow deleted the index.php and accessing the folder without index.php gave same error.
following steps might help any one
- check error log of apache2
- check folder permission is it accessible ? if not set it
- add following in vhost file Options Indexes FollowSymLinks MultiViews AllowOverride all Order Deny,Allow Allow from all Require all granted
- last but might save time like mine check folder name(case sensitive «Pubic» is different form «public») you put in vhosts file and actual name. thanks
In my case I exported Drupal instance from server to localhost on XAMPP. It obviously did not do justice to the file and directory ownership and Apache was throwing the above error.
This is the ownership of files and directories initially:
To give read permissions to my files and execute permission to my directories I could do so that all users can read, write and execute:
but that would not be the ideal solution coz this would be migrated back to server and might end up with a security loophole.
#!/bin/bash # Help menu print_help() < cat --drupal_path=PATH --drupal_user=USER --httpd_group=GROUP Example: (sudo) bash $ --drupal_path=/usr/local/apache2/htdocs --drupal_user=john --httpd_group=www-data HELP exit 0 > if [ $(id -u) != 0 ]; then printf "**************************************\n" printf "* Error: You must run this with sudo or root*\n" printf "**************************************\n" print_help exit 1 fi drupal_path=$ drupal_user=$ httpd_group="$" # Parse Command Line Arguments while [ "$#" -gt 0 ]; do case "$1" in --drupal_path=*) drupal_path="$" ;; --drupal_user=*) drupal_user="$" ;; --httpd_group=*) httpd_group="$" ;; --help) print_help;; *) printf "***********************************************************\n" printf "* Error: Invalid argument, run --help for valid arguments. *\n" printf "***********************************************************\n" exit 1 esac shift done if [ -z "$" ] || [ ! -d "$/sites" ] || [ ! -f "$/core/modules/system/system.module" ] && [ ! -f "$/modules/system/system.module" ]; then printf "*********************************************\n" printf "* Error: Please provide a valid Drupal path. *\n" printf "*********************************************\n" print_help exit 1 fi if [ -z "$" ] || [[ $(id -un "$" 2> /dev/null) != "$" ]]; then printf "*************************************\n" printf "* Error: Please provide a valid user. *\n" printf "*************************************\n" print_help exit 1 fi cd $drupal_path printf "Changing ownership of all contents of "$":\n user => "$" \t group => "$"\n" chown -R $:$ . printf "Changing permissions of all directories inside "$" to "rwxr-x---". \n" find . -type d -exec chmod u=rwx,g=rx,o= '<>' \; printf "Changing permissions of all files inside "$" to "rw-r-----". \n" find . -type f -exec chmod u=rw,g=r,o= '<>' \; printf "Changing permissions of "files" directories in "$/sites" to "rwxrwx---". \n" cd sites find . -type d -name files -exec chmod ug=rwx,o= '<>' \; printf "Changing permissions of all files inside all "files" directories in "$/sites" to "rw-rw----". \n" printf "Changing permissions of all directories inside all "files" directories in "$/sites" to "rwxrwx---". \n" for x in ./*/files; do find $ -type d -exec chmod ug=rwx,o= '<>' \; find $ -type f -exec chmod ug=rw,o= '<>' \; done echo "Done setting proper permissions on files and directories"
And need to invoke the command:
sudo bash /Applications/XAMPP/xamppfiles/htdocs/fix-permissions.sh --drupal_path=/Applications/XAMPP/xamppfiles/htdocs/rkmission --drupal_user=daemon --httpd_group=admin
In my case the user on which Apache is running is ‘daemon’. You can identify the user by just running this php script in a php file through localhost:
Below is the right user with right file permissions for Drupal:
You might have to change it back once it is transported back to server!
Access forbidden 403 error in xampp
sudo su cd /tmp wget bit.ly/1cmyrUo -O xampp-32bit.run chmod 777 ./xampp-32bit.run sudo ./xampp-32bit.run
#!usr/bin/perl print "content-type:text/html\n"; print(header()); use CGI qw(:standard); print(start_html()); print "Hello. I am ram"; print(end_html());
After copying my perl file from /home/vicky/desktop to /opt/lampp/cgi-bin . I started my xampp with the following command.
Then I ran my sample.pl in the localhost with the help of the http://localhost/cgi-bin/sample.pl in my mozilla browser. I just got the following window. I found only answers relating to the ‘new security concept error’ and ‘accessing virtual host issue’. I did came across an askubuntu query, a bid similar to that of mine. It had no answers but some comments. One comment suggested to change the file permissions. It directed to get help from here. It said to change the directory permission as 755 and file permission as 644 to resolve this kind of issue. When I tried to do that, I came to know that my cgi-bin directory already had 755 permission and my sample.pl had 644 permission. I have no solutions now. PostScript: I have attached the content of my /opt/lampp/apache2/conf/httpd.conf file. Hope this will help the answer-providers to understand my problem completely.
Alias /bitnami/ "/opt/lampp/apache2/htdocs/" Alias /bitnami "/opt/lampp/apache2/htdocs" Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all