Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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!
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).
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
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.