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 07-04-2016, 05:49 PM   #1
jailinux
LQ Newbie
 
Registered: Jul 2016
Posts: 1

Rep: Reputation: Disabled
Apache 404 error


Hi,

Day 3 after installing fedora 24, setting up apache for virtual host. has been hard, ex ubuntu user, seems fedora file location where different, many changes to apache 2.4. searched googles and apache and fedora docs. finally asking for help.

I get a 404 nNot found when trying to access via browser.

here are my config files and error outputs from httpd -S

files may have to much in them at this point. Thank you for any help.

SeLinux has been disabled


httpd -S output:

AH00112: Warning: DocumentRoot [/home/www/apecenergy.co.uk/public_html] does not exist
AH00112: Warning: DocumentRoot [/home/www/rangayoga.co.uk/public_html] does not exist
VirtualHost configuration:
*:80 is a NameVirtualHost
default server www.apecenergy.co.uk (/etc/httpd/conf.d/httpd-vhosts.conf:23)
port 80 namevhost www.apecenergy.co.uk (/etc/httpd/conf.d/httpd-vhosts.conf:23)
alias www.apecenergy.co.uk
port 80 namevhost rangayoga.co.uk (/etc/httpd/conf.d/httpd-vhosts.conf:32)
alias www.rangayoga.co.uk
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/home/david/www"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex lua-ivm-shm: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex cache-socache: using_defaults
Mutex authdigest-opaque: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48

!!!!((( Should the document root be owned by "apache" and not "david", just noticed this now from seeing the last 2 lines)))!!!!

etc/hosts file:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

127.0.0.1 rangayoga.co.uk www.rangayoga.co.uk
127.0.0.1 apecenergy.co.uk www.apecenergy.co.uk

etc/httpd/conf.d/httpd-vhosts.conf

<VirtualHost *:80>
ServerAdmin admin@apecenergy
DocumentRoot /home/www/apecenergy.co.uk/public_html
ServerName www.apecenergy.co.uk
ServerAlias www.apecenergy.co.uk
ErrorLog "/var/log/httpd/apecenergy-error_log"
CustomLog "/var/log/httpd/apecenergy-access_log" common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin admin@rangayoga.co.uk
DocumentRoot "/home/www/rangayoga.co.uk/public_html"
ServerName rangayoga.co.uk
ServerAlias www.rangayoga.co.uk
ErrorLog "/var/log/httpd/rangayoga.co.uk-error_log"
CustomLog "/var/log/httpd/rangayoga.co.uk-access_log" common
</VirtualHost>

ServerName 127.0.0.1


etc/httpd/conf/httpd.conf
(selected data, if you require full document please ask)

ServerRoot "/etc/httpd"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition. These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin@your-domain.com
#
ServerAdmin root@localhost

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all granted
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# 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 "/home/david/www"

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

# Further relax access to the default document root:
<Directory "/home/david/www">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ".ht*">
Require all denied
</Files>
 
Old 07-05-2016, 12:06 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
SELinux?
 
Old 07-05-2016, 12:12 PM   #3
Bapun007
Member
 
Registered: Dec 2010
Location: /home
Distribution: Slackware stable
Posts: 79

Rep: Reputation: 40
Document root is :"/home/david/www"
have you created that directory??
change the permission to 777, and change the user and group to apache.
 
Old 07-05-2016, 12:21 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by Bapun007 View Post
Document root is :"/home/david/www"
have you created that directory??
change the permission to 777, and change the user and group to apache.
Warning: NEVER. EVER use 777 and it is in poor form to suggest such.
 
1 members found this post helpful.
Old 07-05-2016, 12:31 PM   #5
Bapun007
Member
 
Registered: Dec 2010
Location: /home
Distribution: Slackware stable
Posts: 79

Rep: Reputation: 40
Quote:
Originally Posted by Habitual View Post
Warning: NEVER. EVER use 777 and it is in poor form to suggest such.
Dear sir,
I know the directory permission should be 755 and file permission should be 644(I use these, 777 is bad for security), I am asking him to check if changing permission to 777 changes anything, if it helps then we can set it to the correct permission after changing it to correct group and user.
 
Old 07-05-2016, 03:12 PM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by Bapun007 View Post
Dear sir,
I know the directory permission should be 755 and file permission should be 644(I use these, 777 is bad for security)
There is no reason to tell a user to open a security hole in his file system to "check permissions".
Please don't reply with some lame rationalization.
Warning: 777 never fixed a thing. Ever.


Turn your own server into a toaster.
 
1 members found this post helpful.
Old 07-05-2016, 03:31 PM   #7
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
jailinux:

Did you make changes "Main DocumentRoot" in /etc/httpd/conf/httpd.conf ?
Change that back. Restore the original file from backup.

That file controls the httpd server. There is little reason to edit that file.

Your httpd-vhosts.conf is for shit.
Did you copy another file to make this /etc/httpd/conf.d/httpd-vhosts.conf?
Start over:
Code:
<VirtualHost *:80>
     ServerAdmin root@localhost
     DocumentRoot /fix/me/ 
     ServerName rangayoga.co.uk
     ServerAlias rangayoga.co.uk
     ErrorLog /var/log/httpd/rangayoga.co.uk-error_log
     CustomLog /var/log/httpd/apecenergy-access_log common
</VirtualHost>
        <Directory /fix/me/[/B][/COLOR]>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                deny from x.x.x.x
        </Directory>
DocumentRoot /fix/me/
should be (guessing)...
Code:
DocumentRoot /home/david/www/rangayoga.co.uk/public_html
vs.
Code:
DocumentRoot "/home/www/rangayoga.co.uk/public_html"
Service restart after editing, duh.

If done correctly, issuing
Code:
httpd -S
should spit out only
Code:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   rangayoga.co.uk (/etc/httpd/conf.d/httpd-vhosts.conf:1)
Syntax OK
Keep it simple. Don't deviate.

What's with the quoting? (unnecessary since there are no spaces or special characters in paths...?)
Code:
ErrorLog "/var/log/httpd/apecenergy-error_log"
CustomLog "/var/log/httpd/apecenergy-access_log" common
DocumentRoot "/home/www/rangayoga.co.uk/public_html"

Last edited by Habitual; 07-05-2016 at 03:39 PM.
 
Old 07-06-2016, 02:41 AM   #8
Bapun007
Member
 
Registered: Dec 2010
Location: /home
Distribution: Slackware stable
Posts: 79

Rep: Reputation: 40
Thanks for the advice Habitual,sorry for giving bad and potentially dangerious advice. I am going to remember what you told.

Main topic:

After following Habitual's steps change the directory owner to apache from david
Code:
chown -R apache:apache /home/david/www/rangayoga.co.uk/public_html
You should also enable selinux, its a good security feature.
Apache document roots have "httpd_sys_content_t" context.

This command is going to change selinux context for your document root.
Code:
semanage fcontext -a -t httpd_sys_content_t "/home/david/www/rangayoga.co.uk/public_html(/.*)?"
Restore the context to default
Code:
restorecon -vRF /home/david/www/rangayoga.co.uk/public_html/
After this you can enable selinux.
 
Old 07-06-2016, 10:54 AM   #9
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by Bapun007 View Post
Thanks for the advice Habitual,sorry for giving bad and potentially dangerious advice. I am going to remember what you told.

Main topic:

After following Habitual's steps change the directory owner to apache from david
Code:
chown -R apache:apache /home/david/www/rangayoga.co.uk/public_html
No harm, no foul. Been there, learned that.

We not going to add david to apache group?
Good job on the semanage stuff, I haz to gurgle it, every time. Grrr.
 
Old 07-06-2016, 11:19 AM   #10
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Here's the default /etc/httpd/conf/httpd.conf from
Code:
CentOS release 6.7 (Final)
[root@guardian ~]# httpd -V
Server version: Apache/2.2.15 (Unix)
...
httpd-2.2.15-47.el6.centos.x86_64
All the file ever needed was
Code:
ServerName localhost
at the bottom of the file, and this was/is to suppress a "Warning" upon httpd restart.

I suggest in the future, you learn to make copies of files (file.ext.org or file.ext.original) before edits.
I also suggest that you use the guideline of "One domain, one conf" in /etc/httpd/conf.d/ to keeps things neat and tidy.
e.g.:
Code:
/etc/httpd/conf.d/rangayoga.conf
perhaps?

If you decide to do that, your
Code:
httpd -D DUMP_VHOSTS
would show this output (maybe with some minor variance)
Code:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   rangayoga.co.uk (/etc/httpd/conf.d/rangayoga.conf:1)
Syntax OK
Your output should look nothing like the output in Post #1 and should basically look like ^^.

Restoring /etc/httpd/conf.d/httpd.conf from backup before editing /etc/httpd/conf.d/rangayoga.conf
And the SELinux is important. Bapun007 laid it out nicely.

Good Luck. It's quite a learning curve, but once you get the hang of it, it's pretty routine.
You got my attention using "Poor Man's DNS" in /etc/hosts.

Have fun.

Last edited by Habitual; 07-06-2016 at 01:54 PM.
 
1 members found this post helpful.
  


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
Apache error: 404 Not Found, why? cucolin@ Ubuntu 3 08-14-2006 11:01 AM
Unwanted 404 error with apache Vossy Linux - Software 0 12-26-2005 08:31 PM
why is apache giving me a 404 error linuxmandrake Linux - Software 4 06-17-2005 09:16 AM
odd Apache 404 error Seventh Linux - Software 1 03-27-2005 03:43 AM

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

All times are GMT -5. The time now is 11:26 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