Jump to content

Apache Configuration


JayFM

Recommended Posts

Hello everyone :)

 

I have recently made a few changes to my network, and added an Apache server with PHP.

 

On the local network I have a few different URLs which I want to be able to access the web server for different purposes, eg. development.network.local, live.network.local, etc. Each of these has it's own document root, eg F:/development, F:/live, etc. I have read through the Apache documentation, but am not sure of the best way to achieve this.

At present, I have set up virtual hosts for every url/interface (Server has two accessible interfaces, as it's in a DMZ), but it seems only to work when it wants to, and gives me unexpected results. I was wondering if it is possible to do this using a wildcard selector for each URL, or some kind of regex to point to the correct document root, and if it is possible, how would I achieve this?

 

I also need the server to be accessible from externally (It's fine for me to set up an exception in the inbound filter on the firewall to port 80 on the server), but once again, I'm not sure how best to set this up for the server to handle correct and consistently. When accessed externally, it should essentially be the same as viewing live.network.local.

 

Any help would be greatly appreciated.

 

Cheers,

Jay

Link to comment
Share on other sites

Yes you can use vhosts for this.

 

However for http://development.network.local and http://live.network.local to work you'll need to add them to your hosts file. eg

127.0.0.1   development.network.local
127.0.0.1   live.network.local

Once the hosts file is setup. You can setup your vhosts example

NameVirtualHost network.local:80

<VirtualHost live.network.local:80>
    ServerName live.network.local
    DocumentRoot "F:/live"
</VirtualHost>

<VirtualHost development.network.local:80>
    ServerName development.network.local
    DocumentRoot "F:/development"
</VirtualHost>

Save any changes you made to Apache's configuration. Make sure Apache is restarted afterwards.

 

http://development.network.local should serve files from F:/developement and http://live.network.local should server files from F:/live

Link to comment
Share on other sites

Thanks Wildteen for your reply.

 

I set that up, and now, regardless of what URL I am using, it automatically points to F:/live, and I'm not sure why.

 

Do I still need to add every possible URL to my hosts file if I have a DNS server pointing each URL back to the server?

 

Also, is there a way that I can configure Apache to automatically respond to a request from, eg *.kore.local, and set the document root to be F:/* ?  Maybe using mod_rewrite? That way I can just add a new CNAME alias in my DNS serer, pointing to the web server, and add a new directory in F:/.

 

 

Link to comment
Share on other sites

Just for confirmation

 

The two interfaces on the server are

 

192.168.0.2            [internet port will be forwarded here]

192.168.1.1            [internal server address]

And server named svr1.network.local

 

If any of these are accessed, I want it to link to F:/live, otherwise, as previously mentioned, *.network.local should link to F:/*

 

At the moment, I am trying using mod_vhost_alias.so, but have not had any luck as of yet. I will keep you guys updated.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.