LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Apache 2 install config (https://www.linuxquestions.org/questions/linux-software-2/apache-2-install-config-243318/)

darb 10-16-2004 03:00 AM

Apache 2 install config
 
I just installed apache 2, it is up and running fine, but I can't figure out how to change the root WWW dir from the /apache2 install.

I have found the docs:

Code:

Description:    Directory that forms the main document tree visible from the web
Syntax:                DocumentRoot directory-path
Default:        DocumentRoot /usr/local/apache/htdocs
Context:        server config, virtual host
Status:        Core
Module:        core

This directive sets the directory from which httpd will serve files.
Unless matched by a directive like Alias, the server appends the path from the
requested URL to the document root to make the path to the document.
Example:

DocumentRoot /usr/web

then an access to http://www.my.host.com/index.html refers to /usr/web/index.html.

The DocumentRoot should be specified without a trailing slash.

But, I have no idea what file to edit. I can't find it in apache2.conf

Also I wan't to run a couple of websites on my dynamic ip using no-ip. Will this work:

Code:

<VirtualHost *:8088>
DocumentRoot /www/example1
ServerName www.example1.no-ip.com

# Other directives here

</VirtualHost>

<VirtualHost *:8088>
DocumentRoot /www/example2
ServerName www.example1.example2.org
 # Other directives here

</VirtualHost>


acid_kewpie 10-16-2004 04:22 AM

it will be in that config file somewhere, or if your version uses multiple config files for ease of management, you might have a commonapache2.conf too..? I don't see what you mean by not being able to find it though... you've found it in your second code block there... :confused: those virtual hosts look ok to me.

darb 10-16-2004 11:32 PM

Thanks for the reply acid. Both code blocks are from the apache docs, easy to find but NOT easy to understand.

WHY doesn't the software industry adhere to the KISS rule?

I did a deb install and from what I can tell have the following config files to choose from:

htppd.conf - appears to be just a legacy file.

apache2.conf - 1.) I can't find any reference to DocumentRoot. 2.) The only reference to VirtualHost is at the very end of the file which refers to: Include /etc/apache2/sites-enabled/[^.#]*

/etc/apache2/sites-enabled/ containes one file: 000-default

This file is obviously a virtual host configuration file, but apart from configure the file W.T.H. do I do with it?

Do I rename it to match the Vhost name?

Do I create one file for each Vhost?

This file still doesn't match the example that I found in the docs(the second code block). There is more config choices than I need or want, you should be able to just set the DocumentRoot and ServerName and leave all of the other configurations global, correct?

rajbaxi 10-17-2004 12:02 AM

what editor are you using? try using something like pico or nano. You can search for the pattern DocumentRoot. It's there somewhere.

acid_kewpie 10-17-2004 05:06 AM

[[KISS]] only really goes so far. At this level, KISS just leaves you with a simple and stupid application. That's not exactly what is required from a web server now is it?

ok so this is on debian, which i've never used... so the virtual hosts are in that sites-enabled directory... so you'd presumably wnat to create another file in there for your domain, and inside that, you'll be free to change the DocumentRoot anyway. You should be able to chaneg it globally in the main apache2.conf, but it'll be outwardly identical whichever way you did it.

darb 10-17-2004 02:00 PM

I meant KISS in respect to the documentation for apache, or any other software(linux) for that matter.

The docs for apache are not anywhere near approaching KISS. Actually it isn't even accurate, or at lease it is contradictory. For example, the docs state that The main configuration file is usually called httpd.conf, yet the file states: This is here for backwards compatibility reasons and to support installing 3rd party modules directly via apxs2, rather than through the /etc/apache2/mods-{available,enabled} mechanism. Helpful, NO in both cases.
Quote:

You should be able to change it globally in the main apache2.conf, but it'll be outwardly identical whichever way you did it.
Yes, that is exactly what I want to do, but don't know how. The ONLY reference to virtual host in my apache2.conf file is:
Code:

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/[^.#]*

/etc/apache2/sites-enabled/ contains one file, 000-default.

The 000-default file is a virtual host configuration file with an extensive amount of configuration options.

Do I config a copy of this file for each virtual host that I want to set up?
What do I name it, 001--vhostnameA & 002--vhostnameB ?

What about the example from the docs:
Code:

<VirtualHost *:8088>
DocumentRoot /www/example1
ServerName www.example1.no-ip.com

# Other directives here

</VirtualHost>

<VirtualHost *:8088>
DocumentRoot /www/example2
ServerName www.example1.example2.org
 # Other directives here

</VirtualHost>

That is all the configuration that I want or need (KISS) where could I use it instead?

There is also a second directory called /etc/apache2/sites-available/ that contains a file: "default" which appears to be identical to /etc/apache2/sites-enabled/000-default. What is this for?

Thanks, Brad

acid_kewpie 10-17-2004 02:16 PM

well this is just a difference in scope for apache / distros. you're presumably reading official apache documentation, which is wholly accurate when related to the official apache source, however is a distro takes it upon themselves to try tosplit up the configuration for reasons they feel they can justify, that's not apaches fault.

But anyway. For your virtual host, a file containing nothing but one of the examples above, e.g:
Code:

<VirtualHost *>
DocumentRoot /www/example2
ServerName www.example1.example2.org
</VirtualHost>

will probably work fine, with the file named accordingly. I have to admit i've not seen a config layout as cut up as that though.

rajbaxi 10-17-2004 02:16 PM

why don't you just create your own apache2.conf or httpd.conf and put what you want? Just make sure your script points to the right conf file on startup.

acid_kewpie 10-17-2004 02:19 PM

well i wouldn't recommend starting from scratch... but in a similar vein you could actually just tag anything at all that you want onto the end of apache2.conf anyway, the individual files are not needed as such.

darb 10-17-2004 02:39 PM

so I could just replace:

Include /etc/apache2/sites-enabled/[^.#]*

in apache2.conf

with:

<VirtualHost *:8088>
DocumentRoot /www/example1
ServerName www.example1.no-ip.com

</VirtualHost>

<VirtualHost *:8088>
DocumentRoot /www/example2
ServerName www.example2.no-ip.com
# Other directives here

</VirtualHost>

As I haven't mentioned, but should be obvious I am a newbie.

acid_kewpie 10-17-2004 03:20 PM

yes, but remember that that does go against the design methods being used within the distro. also you preumably wouldn't want to be using port 8088 etc.....

cavingreer 10-18-2004 02:18 PM

Just above the virtual hosts section is a line that says
#NameVirtualHost *:80

If you uncomment it you can use the name based virtual hosts and below that you
can just start adding virtualhost sections for each domain you want to host.

darb 10-18-2004 08:10 PM

Actually mine comes already uncommented and there is also no servername variable in the file like in the docs.
Code:

NameVirtualHost *
<VirtualHost *>
        ServerAdmin webmaster@localhost
       
        DocumentRoot /var/www/
        <Directory />

and I have a seperate ports.conf file to specify the IP/port(s) to listen on.

I am having problems getting the virtual sites up and responding and was wondering about that and assumed that the ports.conf file maintain the setting for the server?

I did want port 8088 because I am running this at home and port 80 is blocked, plus no ...

darb 10-18-2004 08:47 PM

The files are here , to give you a better idea.

Also, how can I execute a local request for a local virtual site? Doesn't the request have to include the site name, otherwise it will go to the default site?

darb 10-19-2004 06:35 PM

Also could I simply strip out my current files (config) and replace them with the "OEM" ones?


All times are GMT -5. The time now is 04:54 AM.