[SOLVED] Apache 403:Forbidden on sub-directory

Issues related to applications and software problems
Post Reply
linuxleep

[SOLVED] Apache 403:Forbidden on sub-directory

Post by linuxleep » 2013/10/22 00:31:20

CentOS 6.4 64bit, minimal install, in VirtualBox.
Added groupinstall "Development Tools" to install VBox Guest Additions.
Installed Webmin, Apache, MySQL, PHP.

Trying to get a program called "Multicraft" to run. It is downloaded in a .tar.gz file and has an installer that you run. It installed properly but I must visit http://192.168.1.140/multicraft/install.php to finish install. The folder is located at /var/www/html/multicraft. I keep getting a 403:Forbidden every time I try to access the folder itself or the install.php or index.php file within the folder from a browser. I can reach the main http://192.168.1.140 and it shows the "Apache HTTP Server Test Page"

Apache is run under the apache user and apache group
-I have done a "chown -R apache:apache *" within the /var/www directory to make sure all permissions are correct.
-The installer asks which user to run multicraft in and I made a "minecraft" user and added them to the "apache" group.
-I have added the following into my /etc/httpd/conf/httpd.conf file:

#user-added directory

Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all


-There are also .htaccess files located within the directory that were installed with the program. Here is a list of all .htaccess files on the system:

/root/multicraft/panel/.htaccess
/root/multicraft/panel/protected/.htaccess
/root/multicraft/panel/protected/yii/.htaccess
/root/multicraft/panel/protected/yii/cli/views/webapp/protected/.htaccess
/root/multicraft/panel/protected/yii/cli/views/webapp/themes/classic/views/.htaccess
/root/multicraft/panel/themes/mobile/views/.htaccess
/root/multicraft/panel/themes/simple/views/.htaccess
/var/www/html/multicraft/.htaccess
/var/www/html/multicraft/protected/.htaccess
/var/www/html/multicraft/protected/yii/.htaccess
/var/www/html/multicraft/protected/yii/cli/views/webapp/protected/.htaccess
/var/www/html/multicraft/protected/yii/cli/views/webapp/themes/classic/views/.htaccess
/var/www/html/multicraft/themes/mobile/views/.htaccess
/var/www/html/multicraft/themes/simple/views/.htaccess

-Here is the "/var/www/html/multicraft/.htaccess" file:

Options +FollowSymLinks


IndexIgnore */*



RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .? - [S=2]

# redirect to installer if the request ends with install.php
RewriteRule /install\.php$ install.php [L]

# otherwise forward it to index.php
RewriteRule . index.php


I still get this 403:Forbidden on the directory of "/var/www/html/multicraft" access by "192.168.1.140/multicraft" in the browser. I have also tried the "192.168.1.140/multicraft/install.php" and "192.168.1.140/multicraft/index.php" and gotten the same error.

I cannot figure out what I have done wrong. Any ideas on a step I may have missed. Or a configuration I may have screwed up. Thanks in advance for any help.

User avatar
TrevorH
Forum Moderator
Posts: 26331
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Apache 403:Forbidden on sub-directory

Post by TrevorH » 2013/10/22 03:14:22

Try

[code]
restorecon -r /var/www/html
[/code]

linuxleep

Re: Apache 403:Forbidden on sub-directory

Post by linuxleep » 2013/10/22 22:14:25

[quote]
TrevorH wrote:
Try

[code]
restorecon -r /var/www/html
[/code][/quote]

You sir, are my hero.
Days of smashing my head against a wall with no avail. You solved my problem with one line of code.

Thank you again.

:-D

User avatar
TrevorH
Forum Moderator
Posts: 26331
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: [SOLVED] Apache 403:Forbidden on sub-directory

Post by TrevorH » 2013/10/22 22:27:54

The issue is caused when you mv something from one place to another. It preserves the selinux context of the original when you move it, so if you untar something in /home or /tmp it gets given an selinux context that matches its location. Now you mv that to /var/www/html and it takes the context saying it belongs in /tmp or /home with it and httpd is not allowed by policy to access those files.

If you cp the files instead of mv them, the selinux context gets assigned according to the location you're copying to, not where it's coming from. Running restorecon puts the context back to its default and fixes it too.

hadmanysons
Posts: 1
Joined: 2014/11/18 09:35:12

Re: [SOLVED] Apache 403:Forbidden on sub-directory

Post by hadmanysons » 2014/11/18 09:36:56

Thanks from the future. Just created an account so i could post my thanks to TrevorH as I too was beating my head against a wall a year later

cleaner86
Posts: 1
Joined: 2015/07/17 19:32:28

Re: [SOLVED] Apache 403:Forbidden on sub-directory

Post by cleaner86 » 2015/07/17 19:35:30

OMG!! That was the solution for me too... thank you so much!!

abghosh82
Posts: 1
Joined: 2015/07/29 08:13:56

Re: [SOLVED] Apache 403:Forbidden on sub-directory

Post by abghosh82 » 2015/07/29 08:19:55

Thanks a lot that worked for me too after, saw this post after struggling for almost a day.

Post Reply