LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-30-2021, 03:52 PM   #1
garyfritz
LQ Newbie
 
Registered: Apr 2018
Posts: 13

Rep: Reputation: Disabled
Changing Apache DocumentRoot


I want to move my Apache webserver directory. I've looked at literally dozens of websites that claimed to tell you how to do this, and basically they all just said "Oh that's easy, just change DocumentRoot and you're golden." Well I did, and I'm not.

I changed DocumentRoot.
I tried changing the <Directory> settings. (See conf file below)
I've restarted httpd and rebooted the system.
I set the SELinux type to httpd_sys_content_t on my DocumentRoot and on the index.html:
Code:
# semanage fcontext -a -t httpd_sys_content_t "/test(/.*)?"
# restorecon -R -v /test /test/index.html
# ll -dZ /test /test/index.html 
drwxr-xr-x. 2 apache apache unconfined_u:object_r:httpd_sys_content_t:s0 24 Mar 30 14:03 /test
-rw-r--r--. 1 apache apache unconfined_u:object_r:httpd_sys_content_t:s0 22 Mar 30 14:03 /test/index.html
I took care of /etc/httpd/conf/welcome.conf so the "you haven't set up Apache yet" message doesn't display. But all I get is "403 Forbidden: You don't have permission to access this resource."

What am I missing?


Code:
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/test"

#
# Relax access to content within /var/www.
#
<Directory "/test">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

Last edited by garyfritz; 03-30-2021 at 03:54 PM.
 
Old 03-30-2021, 04:55 PM   #2
dc.901
Senior Member
 
Registered: Aug 2018
Location: Atlanta, GA - USA
Distribution: CentOS/RHEL, openSuSE/SLES, Ubuntu
Posts: 1,005

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Quote:
Originally Posted by garyfritz View Post
But all I get is "403 Forbidden: You don't have permission to access this resource."
What is in Apache logs?
 
1 members found this post helpful.
Old 03-30-2021, 05:42 PM   #3
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,750

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
Did you restart httpd after making changes?
 
Old 03-30-2021, 06:14 PM   #4
garyfritz
LQ Newbie
 
Registered: Apr 2018
Posts: 13

Original Poster
Rep: Reputation: Disabled
Yes I did (restart httpd).

Hm, @dc.901, you had the right idea. The error_log says there is no matching DirectoryIndex -- no index.html/whatever.

I loop-mounted the ISO image of a RHEL8.3 install DVD and I'm using it for a yum repository. I was supposed to also point the webserver at that directory, but I don't know how it's possible if it requires an index.html, since I can't create one in the ISO. (Well I probably COULD but that's not the right way to attack this.)

But that's not the only problem. I moved it off the ISO to a normal directory, /test. The error message says "Cannot serve directory /http_repo/," which was a link to the ISO. I thought I had removed all references to that dir! But with some digging I found an entry in conf.d/vhosts.conf. Not sure where that came from, since I didn't knowingly set it up. But once I fixed that, it finally worked.

Thanks for pointing me in the right direction! I should have thought to look for log files...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
changing the Apache DocumentRoot path to new add additional hardisk piaakit Linux - Server 21 07-16-2012 12:55 AM
Ubuntu server apache2 changing documentroot gives a 403 rnx Linux - Server 12 06-01-2010 10:12 AM
Apache is giving me 403 when changing DocumentRoot Lazy Foo' Linux - Software 7 01-30-2006 08:39 PM
Changing Apache DocumentRoot walterbyrd Linux - Software 1 10-18-2005 03:30 PM
DocumentRoot apache illtbagu Linux - Software 6 02-28-2003 12:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration