[REOPENED] Apache doesn't find webpage

Issues related to applications and software problems
Post Reply
jody
Posts: 53
Joined: 2015/05/12 12:58:08

[REOPENED] Apache doesn't find webpage

Post by jody » 2019/06/27 07:25:56

I am trying to get Apache running properly on our CentOS 7 machine ('serverB').

After having installed httpd I started it and my browser displayed the default Apache start page when i pointed it at serverB.

The webpage i actually want to access is on serverB at
~jody/public_html/index.html

I added a few lines to httpd.conf (copied from a httpd.conf on our old (CentOS6) server)

Code: Select all

LoadModule userdir_module modules/mod_userdir.so

Code: Select all

<IfModule mod_userdir.c>
    UserDir "enabled *"
    UserDir "disabled root"
    UserDir public_html
</IfModule>

Code: Select all

Redirect permanent /jody http://serverB.uzh.ch/~jody

<Directory "/home/serverB/">
        Deny from all
</Directory>

<Directory "/home/serverB/jody">
        Allow from all
        AllowOverride All
</Directory>

<Directory "/home/">
     Options Indexes FollowSymLinks
     AllowOverride None
     Deny from all
</Directory>
Doing
systemctl restart httpd.service
returned no error.

But when i point my browser at http://serverB.uzh.ch/~jody
I get a 404:

Code: Select all

The requested URL /~jody was not found on this server.
[begin edit]
if i put a simple index.html into /var/www/html it is displayed correctly when i point my browser at http://serverB.uzh.ch/.
[end edit]

What do i have to do to display webpages situated in home directories?
Last edited by jody on 2019/07/03 09:00:07, edited 2 times in total.

User avatar
TrevorH
Site Admin
Posts: 33218
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Apache doesn't find webpage

Post by TrevorH » 2019/06/27 08:15:54

You didn't need to add a LoadModule as one already exists in CentOS 7 as /etc/httpd/conf.modules.d/00-base.conf:LoadModule

You also cannot just copy from CenTOS 6 httpd to CentOS 7 as there are syntax differences between httpd 2.2.15 (el6) and 2.4.6 (el7). You'll want to check the docs to make sure that your additions are valid.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

jody
Posts: 53
Joined: 2015/05/12 12:58:08

Re: Apache doesn't find webpage

Post by jody » 2019/06/27 13:41:22

Thanks for the clarification - i did not expect the syntax to differ...

So i went back to the original httpd.conf and only added the line

Code: Select all

UserDir public_html
which should, according to
https://httpd.apache.org/docs/2.4/howto ... _html.html
translate something like
http://example.com/~rbowen/file.html
to the file path
/home/rbowen/public_html/file.html

I restarted httpd, but even so i only get back a

Code: Select all

The requested URL /~jody/index.html was not found on this server.
Are there any other settings i have to change in order to access http://serverB.uzh.ch/~jody/index.html ?

pjsr2
Posts: 614
Joined: 2014/03/27 20:11:07

Re: Apache doesn't find webpage

Post by pjsr2 » 2019/06/27 15:01:57

You also need to adjust the SELinux context. Did you do that?

Code: Select all

sudo setsebool -P httpd_enable_homedirs on
sudo restorecon -R /home 
See instructions on https://www.server-world.info/en/note?o ... =httpd&f=5

User avatar
TrevorH
Site Admin
Posts: 33218
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Apache doesn't find webpage

Post by TrevorH » 2019/06/27 15:48:59

And edit /etc/httpd/conf.d/userdir.conf as I am fairly sure that the bits needed to make it work are all commented out in there by default
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

jody
Posts: 53
Joined: 2015/05/12 12:58:08

Re: Apache doesn't find webpage

Post by jody » 2019/06/28 06:59:13

Thank you for your suggestions.

After adjusting the SELinux context i followed all steps in the page indicated by pjsr (including setting the mode of the home directory to 711).

Now i can access the pages in my publiic_html directory! :D

jody
Posts: 53
Joined: 2015/05/12 12:58:08

Re: [REOPENED] Apache doesn't find webpage

Post by jody » 2019/07/03 09:42:34

I have hit another obstacle.
On our server we have two home directories, one for normal users (under /home) and one for wiki pages of projects (/home/projects).

For example we have user gorgon (representing a project) which has the home directory /home/projects/gorgon.
In this home directory there is a public_html subdirectory containing an index.html.
I have also added this to conf.d/userdir.conf

Code: Select all

<Directory "/home/projects/*/public_html">
    AllowOverride All
    Options None
    Require method GET POST OPTIONS
</Directory>
But i can not access http://serverB.uzh.ch/~gorgon/index.html: i get
Forbidden You don't have permission to access /~gorgon/index.html on this server.on this server.

But all the permissions of files and subdirectories for /home/projects/gorgon are equal to the ones for /home/jody (which i can access).
I also did

Code: Select all

 $ sudo setsebool -P httpd_enable_homedirs on
 $ sudo restorecon -R /home/projects
 $ sudo systemctl restart httpd
But i still can't access gorgon's index.html.

On our CentOS 6 we had this configuration with two different home directories. How can i achieve this in CentOS 7?

Post Reply