Reputation: 1075
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!
Upvotes: 87
Views: 425006
Reputation: 805
I got this error when I disabled PMA while installing XAMPP. Try rerunning the installer & selecting "phpMyAdmin" or download phpMyAdmin and put it in C:/xampp/phpMyAdmin
.
Upvotes: 0
Reputation: 1300
I might be late but the error was resolved after I created a new folder inside htdocs and pasted all the files from the folder I was getting an error.
In my impression the problem is not in XAMPP but in the folder read/write permissions.
Upvotes: 1
Reputation: 55
htdocs
folderopen 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
lampp
folderopen 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
Upvotes: 1
Reputation: 1200
Edit this file C:\xampp\apache\conf\httpd.conf
Change:
AllowOverride none
Require all denied
To
AllowOverride All
Options All
Allow from all
Order allow,deny
Restart apache
Upvotes: 8
Reputation: 82
following steps might help any one
Upvotes: 0
Reputation: 119
I got the same error because somehow deleted the index.php and accessing the folder without index.php gave same error.
Upvotes: 0
Reputation: 2630
Try with this code below, add it in your virtual host config. Add this lines to httpd-vhosts.conf
file:
<Directory "c:/<path-to-projects>/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
I fixed the same issue by this way. Hope it helps.
Note:
after changes please test it in incognito because you redirected by cache
Upvotes: 175
Reputation: 1374
For XAMPP on Mac
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.
Upvotes: 26
Reputation: 85
The only solution that worked for me after spending hours researching online
sudo chmod -R 0777 /opt/lampp/htdocs/projectname
Upvotes: 7
Reputation: 101
For me it was solved instantly by the following
find the following lines by cont+f:
Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
AllowOverride AuthConfig
Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
only change local ----> all granted, so it becomes like this
Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
AllowOverride AuthConfig
Require all granted
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
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
Upvotes: 3
Reputation: 17354
The way I resolved this was setup error logs correctly, first
<VirtualHost *:80>
DocumentRoot "D:/websites/test/"
ServerName test.dev
ErrorLog "D:/websites/test/logs/error.log"
CustomLog "D:/websites/test/logs/access.log" common
<Directory D:/websites/test/>
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
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
Require all granted
is required. My sample sample code above fixes the problem by the way.
Upvotes: 21
Reputation: 49
I am using xxamp using ubuntu 16.04 - and its working fine for me
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/"
ServerAdmin localhost
<Directory "/opt/lampp/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Upvotes: 5
Reputation: 889
A. #LoadModule vhost_alias_module modules/mod_vhost_alias.so
B. <Directory />
AllowOverride none
Require all denied
</Directory>
Replace with:
A. LoadModule vhost_alias_module modules/mod_vhost_alias.so
B:
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
From E:\xamp**apache\conf/httpd.conf**
Upvotes: 0
Reputation: 7438
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:
sudo chmod 777 -R
but that would not be the ideal solution coz this would be migrated back to server and might end up with a security loophole.
A script is given in this blog: https://www.drupal.org/node/244924
#!/bin/bash
# Help menu
print_help() {
cat <<-HELP
This script is used to fix permissions of a Drupal installation
you need to provide the following arguments:
1) Path to your Drupal installation.
2) Username of the user that you want to give files/directories ownership.
3) HTTPD group name (defaults to www-data for Apache).
Usage: (sudo) bash ${0##*/} --drupal_path=PATH --drupal_user=USER --httpd_group=GROUP
Example: (sudo) bash ${0##*/} --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=${1%/}
drupal_user=${2}
httpd_group="${3:-www-data}"
# Parse Command Line Arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--drupal_path=*)
drupal_path="${1#*=}"
;;
--drupal_user=*)
drupal_user="${1#*=}"
;;
--httpd_group=*)
httpd_group="${1#*=}"
;;
--help) print_help;;
*)
printf "***********************************************************\n"
printf "* Error: Invalid argument, run --help for valid arguments. *\n"
printf "***********************************************************\n"
exit 1
esac
shift
done
if [ -z "${drupal_path}" ] || [ ! -d "${drupal_path}/sites" ] || [ ! -f "${drupal_path}/core/modules/system/system.module" ] && [ ! -f "${drupal_path}/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 "${drupal_user}" ] || [[ $(id -un "${drupal_user}" 2> /dev/null) != "${drupal_user}" ]]; 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 "${drupal_path}":\n user => "${drupal_user}" \t group => "${httpd_group}"\n"
chown -R ${drupal_user}:${httpd_group} .
printf "Changing permissions of all directories inside "${drupal_path}" to "rwxr-x---"...\n"
find . -type d -exec chmod u=rwx,g=rx,o= '{}' \;
printf "Changing permissions of all files inside "${drupal_path}" to "rw-r-----"...\n"
find . -type f -exec chmod u=rw,g=r,o= '{}' \;
printf "Changing permissions of "files" directories in "${drupal_path}/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 "${drupal_path}/sites" to "rw-rw----"...\n"
printf "Changing permissions of all directories inside all "files" directories in "${drupal_path}/sites" to "rwxrwx---"...\n"
for x in ./*/files; do
find ${x} -type d -exec chmod ug=rwx,o= '{}' \;
find ${x} -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:
<?php echo exec('whoami');?>
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!
Upvotes: -1
Reputation: 336
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
Type command
$ sudo chmod 777 -R Practice
what is chmod
and 777
? visit this link
http://linuxcommand.org/lts0070.php
Upvotes: 18
Reputation: 171
Did you change any thing on the virtual-host before it stop working ?
Add this line to xampp/apache/conf/extra/httpd-vhosts.conf
<VirtualHost localhost:80>
DocumentRoot "C:/xampp/htdocs"
ServerAdmin localhost
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Upvotes: 2
Reputation: 3849
I had the same problem. So I got remembere. Yesterday I had commented this code in htttp-xampp.conf
Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
# AllowOverride AuthConfig
# Require local
# ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
SO I can access my localhost using other system on same network(LAN/WIFI) as it make localhost require local.
So I just make it like
Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
AllowOverride AuthConfig
# Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
and now its working on my local machine and also localhost is accessible using other systems on same LAN/WIFI.
Upvotes: 1
Reputation: 3012
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.
Upvotes: 1
Reputation: 973
Go in to your Xampp folder xampp/apache/conf/extra/httpd-xampp.conf
Edit the last paragraph:
#close XAMPP sites here
.
.
.
Deny from all
.
.
to
#close XAMPP sites here
.
.
.
Allow from all
.
.
or just watch this video: http://www.youtube.com/watch?v=ZUAKLUZa-AU.
Upvotes: 4