LinuxQuestions.org
Help answer threads with 0 replies.
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 05-15-2008, 04:39 PM   #1
Gryyphyn
Member
 
Registered: Dec 2006
Location: Ogden, UT (Go OALUG!)
Distribution: OpenSuSE 10.1
Posts: 61

Rep: Reputation: 15
Post apache configuration (gentoo)


Before we get started here I've checked the threads and the webs and found nothing for this issue.

Current system configuration:
Sabayon 3.4f (patched/updated)
Apache2 updated last night (05142008) on updated portage
vsftpd for ftp server (to be used in conjunction with apache)
SSH and SSL packages all updated, configured and working (for current configuration)

Here's the problem:
I've installed Apache2 and it's looking to /usr/bin/apache2 for the server root (install location of the modules directory). The server loads, both remote and local, but the index.html file isn't being read for the default page. I've created a new dir in /var/www called /Section-9 but I can't figure out how to a) get the document root pointed there and b) how to get the index.html to work despite the fact that it's currently in the document directory the apache2 server is looking for content (/var/www/localhost/htdocs I think). The other problem is that the only configuration file I can see is httpd.conf in /etc/init.d/apache2/conf. So here's what I need:

A link to a good, functional and direct approach to apache2 configuration (not apache1).

-or-

A direct guide to basic apache2 configuration posted here including what files should be used for configuration and where apache2 prefers to pull it's content from.

-or-

A recommendation for a good book on apache2/LAMP configuration.

Everything has changed since I was in school so I'm at a complete loss for where I'm supposed to be at right now. Any help is appreciated. Please, only real posts, no 'go back to windows noob' posts or the like.

Gryyphyn, out.
 
Old 05-16-2008, 01:02 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Code:
wim@webserver:~$ locate httpd.conf
/etc/httpd/httpd.conf
/etc/httpd/original/httpd.conf
wim@webserver:~$ cd /etc/httpd/original
wim@webserver:/etc/httpd/original$ ls
extra/  httpd.conf
wim@webserver:/etc/httpd/original$ grep DocumentRoot *
httpd.conf:# DocumentRoot: The directory out of which you will serve your
httpd.conf:DocumentRoot "/srv/httpd/htdocs"
httpd.conf:# This should be changed to whatever you set DocumentRoot to.
httpd.conf:    # access content that does not live under the DocumentRoot.
wim@webserver:/etc/httpd/original$
Just as an example from my Slackware webserver
run a locate to find the httpd.conf file
pick the one that seems appropriate
cd to that directory
analyse/edit the httpd.conf
restart apache to make the changes take effect
if no changes, you had the wrong file

Once you have the correct httpd.conf, you can find references to other config files in there (e.g. for ssl, virtual hosts etc).

Last edited by Wim Sturkenboom; 05-16-2008 at 01:11 AM.
 
Old 05-16-2008, 04:01 PM   #3
Gryyphyn
Member
 
Registered: Dec 2006
Location: Ogden, UT (Go OALUG!)
Distribution: OpenSuSE 10.1
Posts: 61

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Wim Sturkenboom View Post
Code:
wim@webserver:~$ locate httpd.conf
/etc/httpd/httpd.conf
/etc/httpd/original/httpd.conf
wim@webserver:~$ cd /etc/httpd/original
wim@webserver:/etc/httpd/original$ ls
extra/  httpd.conf
wim@webserver:/etc/httpd/original$ grep DocumentRoot *
httpd.conf:# DocumentRoot: The directory out of which you will serve your
httpd.conf:DocumentRoot "/srv/httpd/htdocs"
httpd.conf:# This should be changed to whatever you set DocumentRoot to.
httpd.conf:    # access content that does not live under the DocumentRoot.
wim@webserver:/etc/httpd/original$
Just as an example from my Slackware webserver
run a locate to find the httpd.conf file
pick the one that seems appropriate
cd to that directory
analyse/edit the httpd.conf
restart apache to make the changes take effect
if no changes, you had the wrong file

Once you have the correct httpd.conf, you can find references to other config files in there (e.g. for ssl, virtual hosts etc).
What about declarations for serverroot and documentroot? That's the one that I'm struggling with the most. Thanks for the input!

Gryyphyn, out.
 
Old 05-17-2008, 03:23 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
I've never had a need for to modify ServerRoot, so not familiar with that one

You can point DocumentRoots anywhere as long as apache can read them.

E.g
Code:
DocumentRoot "/home/youruser1/domain1/www"
DocumentRoot "/home/youruser1/domain2/www"
DocumentRoot "/home/youruser2/domain3/www"
I use the above for virtualhosts. Each virtual host has one of the above lines.
If a visitor visits domain1, pages from /home/youruser1/domain1/www are served
If a visitor visits domain3, pages from /home/youruser2/domain3/www are served
You can figure out for yourself which pages are served when one visits domain 2

If you don't use virtual hosts, just modify the one in httpd.conf (or whichever file defines the document root).


The reason why I use the user's home direrctories is that I don't have to think about ftp access (just lazy); I've seen too many posts with problems accessing the 'default' DocumentRoot in combination with ftp. In my ftp setup, users are limited to their home directory but as that is where the web pages live, there is no problem.

Only disadvantage that I've found till now:
If you write web pages where apache needs to write to the user's home directory, you need to create a directory where apache indeed can write (I use a subdirectory under www for that and assign group permissions to apache).
 
Old 05-17-2008, 12:35 PM   #5
Gryyphyn
Member
 
Registered: Dec 2006
Location: Ogden, UT (Go OALUG!)
Distribution: OpenSuSE 10.1
Posts: 61

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Wim Sturkenboom View Post

Only disadvantage that I've found till now:
If you write web pages where apache needs to write to the user's home directory, you need to create a directory where apache indeed can write (I use a subdirectory under www for that and assign group permissions to apache).
Makes sense to me. So I should be able to

Code:
DocumentRoot "/var/www/domain"
without any issues. The only problem is, even though I've declared that in /etc/apache2/conf/httpd.conf and there's an index.html there it's not pulling that page, just showing the directory. Is it possible there's multiple httpd.conf files and they're just not visible? I've used
Code:
locate httpd.conf
but I haven't seen any others anywhere.

Gryyphyn, out.
 
Old 05-19-2008, 12:02 AM   #6
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
I suppose that when you open index.html in your browser, it is the correct one. If so, the following lines occur in my httpd.conf:
Code:
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
#WimS: add index.php
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
As you request a directory but get the listting, I suspect that to be missing or incomplete.

With regards to DocumentRoot "/var/www/domain", I suggest to change it to DocumentRoot "/var/www/domain/web" or something similar. The reason is the following:
If you have php-pages that contain confidential information and you place them in the document root (or a subdirectory under it), they are readable by the whole world when they are found. This can be e.g. the connection/login information for a database. I set it up as followes:
Code:
/var/www/domain/
           +--web
           +--inc
For the 'sensitive' stuff, I write functions and store them in php files in the inc directory. This diretory is not accessible by the outside world as it's not in the document root (but apache can access it).
The actual webpage php files go in web and will use include statements to access the php files in inc.

Last edited by Wim Sturkenboom; 05-19-2008 at 12:05 AM.
 
Old 05-19-2008, 11:09 AM   #7
Gryyphyn
Member
 
Registered: Dec 2006
Location: Ogden, UT (Go OALUG!)
Distribution: OpenSuSE 10.1
Posts: 61

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Wim Sturkenboom View Post
I suppose that when you open index.html in your browser, it is the correct one. If so, the following lines occur in my httpd.conf:
Code:
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
#WimS: add index.php
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
As you request a directory but get the listting, I suspect that to be missing or incomplete.

With regards to DocumentRoot "/var/www/domain", I suggest to change it to DocumentRoot "/var/www/domain/web" or something similar. The reason is the following:
If you have php-pages that contain confidential information and you place them in the document root (or a subdirectory under it), they are readable by the whole world when they are found. This can be e.g. the connection/login information for a database. I set it up as followes:
Code:
/var/www/domain/
           +--web
           +--inc
For the 'sensitive' stuff, I write functions and store them in php files in the inc directory. This diretory is not accessible by the outside world as it's not in the document root (but apache can access it).
The actual webpage php files go in web and will use include statements to access the php files in inc.
Hadn't thought about the .php files scenario before, that's good info. As far as the the DirectoryIndex line though, yes, it's in there and declared properly (as far as I can tell). I'll grab my declarations tonight and post them, see what you think.

I'm also going to uninstall/reinstall apache, make sure that everything is where it's supposed to be and just start from scratch, see what happens. I do think that part of the problem is that the location portage installed everything to is incorrect.

*append* I looked at one of your earlier posts and there was something I missed, or didn't take in to account, before. The last time I was playing with this seriously I checked the server root and worked the httpd.conf file from there. I had a dirty read in vi due to a messy swap file and had to delete the swap manually to correct. Once I corrected the issue the serverroot declaration had changed completely and was pointing somewhere it never had before. That's the primary reason for reinstalling, layer 8 error (or pebkac, ID10T or your other fav phrase here).

Gryyphyn, out.

Last edited by Gryyphyn; 05-19-2008 at 11:14 AM. Reason: missing information
 
  


Reply

Tags
apache2, gentoo, lamp, sabayon, server, web


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
gentoo, kde, Xorg configuration novacrasher Linux - Software 7 11-02-2008 06:47 PM
Migrating Apache 1.3 configuration files to Apache 2 kaplan71 Linux - Software 0 03-28-2007 11:05 AM
SVN Server Configuration in Gentoo mclinkor Linux - General 1 09-25-2006 12:17 PM
Gentoo Kernel Configuration discrepant Linux - General 5 03-13-2005 03:41 PM
grub configuration after gentoo install statmobile Red Hat 5 08-05-2004 04:02 PM

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

All times are GMT -5. The time now is 08:22 AM.

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