Jump to content

[SOLVED] Redirecting domain name...


teebee

Recommended Posts

Hi All,

 

This is my first post here, being pretty new to Unix based stuff and an utter newbie with Apache, so please be gentle :-)

 

My problem is that I am trying to make a couple of changes to a server that I did not set up and (I think) upon adding ProFTPD I lost some setting that directed my domain name to my web pages. The only other actions I have taken on the server have been to create a test database, so I can only think installation of ProFTPD has overwritten some directive that I am unaware of.

 

The web pages are still served up from home/webadmin/html if I use the url provided by the host, so mydomain.v.servelocity.net still returns the website, but mydomain.net displays the file index of /var/www/html (since I commented out the lines in welcome.conf).

 

I was tempted to change the DocumentRoot path in httpd.conf, but figure this cannot be the right course of action, as if this was incorrect the url provided by servelocity would not fetch the pages(?).

 

Can anyone please give me any pointers as to what may have happened to cause this behaviour?

 

I should mention that the server is running Fedora 4 on Apache 2.0.51.

 

Many thanks in advance,

 

Tone

Link to comment
Share on other sites

Installing ProFTP should not overide any apache configurations, in fact of fedora was a decent distro installing any software won't disturb existing configurations.

 

Well need to see the relevent parts of your httpd.conf file. In particular anything relating to virtual hosts.

Link to comment
Share on other sites

Thanks for the info Thorpe,

 

I have no idea what has happened as I have not modified any of the files myself, but hey ho, wouldn't be the first time I didn't quite understand what was happening.

 

I have posted the virtual hosts section of the httpd.conf file. If you can see in here where it has all gone wrong, could you also tell me if this could happen without human intervention please.

 

[pre]

### Section 3: Virtual Hosts

#

# VirtualHost: If you want to maintain multiple domains/hostnames on your

# machine you can setup VirtualHost containers for them. Most configurations

# use only name-based virtual hosts so the server doesn't need to worry about

# IP addresses. This is indicated by the asterisks in the directives below.

#

# Please see the documentation at

# <URL:http://httpd.apache.org/docs-2.0/vhosts/>

# for further details before you try to setup virtual hosts.

#

# You may use the command line option '-S' to verify your virtual host

# configuration.

 

#

# Use name-based virtual hosting.

#

#NameVirtualHost *:80

 

#

# VirtualHost example:

# Almost any Apache directive may go into a VirtualHost container.

# The first VirtualHost section is used for requests without a known

# server name.

#

#<VirtualHost *:80>

#    ServerAdmin webmaster@dummy-host.example.com

#    DocumentRoot /www/docs/dummy-host.example.com

#    ServerName dummy-host.example.com

#    ErrorLog logs/dummy-host.example.com-error_log

#    CustomLog logs/dummy-host.example.com-access_log common

#</VirtualHost>

 

NameVirtualHost xx.xx.xx.xx:80

<VirtualHost xx.xx.xx.xx:80>

<Directory /home/webadmin/mydomain.v.servelocity.net/html>

Options Indexes Includes FollowSymLinks

AllowOverride All

</Directory>

Alias /myadmin /var/www/html/myadmin

ScriptAlias /mail /var/www/cgi-bin/openwebmail/openwebmail.pl

ScriptAlias /cgi-bin/openwebmail /var/www/cgi-bin/openwebmail

Alias /openwebmail /var/www/html/openwebmail

ServerName mydomain.v.servelocity.net

DocumentRoot /home/webadmin/mydomain.v.servelocity.net/html

SuexecUserGroup webadmin webadmin

ServerAlias "www.mydomain.v.servelocity.net"

ServerAdmin "shop@mydomain.net"

ScriptAlias "/cgi-bin/" "/home/webadmin/mydomain.v.servelocity.net/cgi-bin/"

CustomLog "/home/webadmin/mydomain.v.servelocity.net/access_log" "combined"

ErrorLog "/home/webadmin/mydomain.v.servelocity.net/error_log"

</VirtualHost>

<VirtualHost xx.xx.xx.xx:80>

<Files ~ "\.(jpeg|jpg|gif|bmp|pic|tiff|png)$">

SetEnvIf Referer "^https?:\/\/xx.xx.xx.xx(\/|$)" prevent_hot_link

SetEnvIf Referer "^https?:\/\/mydomain.net(\/|$)" prevent_hot_link

SetEnvIf Referer "^https?:\/\/www.mydomain.net(\/|$)" prevent_hot_link

Order allow,deny

Allow from env=prevent_hot_link

</Files>

<Directory /home/webadmin/mydomain.net/html>

Options Indexes Includes FollowSymLinks

AllowOverride All

</Directory>

Alias /myadmin /var/www/html/myadmin

ScriptAlias /mail /var/www/cgi-bin/openwebmail/openwebmail.pl

ScriptAlias /cgi-bin/openwebmail /var/www/cgi-bin/openwebmail

Alias /openwebmail /var/www/html/openwebmail

ServerName mydomain.net

DocumentRoot /home/webadmin/mydomain.net/html

SuexecUserGroup webadmin webadmin

ServerAlias "www.mydomain.net"

ServerAdmin "webmaster@mydomain.net"

ScriptAlias "/cgi-bin/" "/home/webadmin/mydomain.net/cgi-bin/"

CustomLog "/home/webadmin/mydomain.net/access_log" "combined"

ErrorLog "/home/webadmin/mydomain.net/error_log"

ServerAlias shop.mydomain.net

</VirtualHost>

<VirtualHost xx.xx.xx.xx:443>

<Files ~ "\.(jpeg|jpg|gif|bmp|pic|tiff|png)$">

SetEnvIf Referer "^https?:\/\/xx.xx.xx.xx(\/|$)" prevent_hot_link

SetEnvIf Referer "^https?:\/\/mydomain.net(\/|$)" prevent_hot_link

SetEnvIf Referer "^https?:\/\/www.mydomain.net(\/|$)" prevent_hot_link

Order allow,deny

Allow from env=prevent_hot_link

</Files>

<Directory /home/webadmin/mydomain.net/html>

Options Indexes Includes FollowSymLinks

AllowOverride All

</Directory>

Alias /myadmin /var/www/html/myadmin

ScriptAlias /mail /var/www/cgi-bin/openwebmail/openwebmail.pl

ScriptAlias /cgi-bin/openwebmail /var/www/cgi-bin/openwebmail

Alias /openwebmail /var/www/html/openwebmail

ServerName mydomain.net

DocumentRoot /home/webadmin/mydomain.net/html

SuexecUserGroup webadmin webadmin

ServerAlias "www.mydomain.net"

ServerAdmin "webmaster@mydomain.net"

ScriptAlias "/cgi-bin/" "/home/webadmin/mydomain.net/cgi-bin/"

CustomLog "/home/webadmin/mydomain.net/access_log" "combined"

ErrorLog "/home/webadmin/mydomain.net/error_log"

SSLCertificateFile /etc/httpd/conf/ssl.crt/mydomain.net.hspc.crt

SSLCertificateKeyFile /etc/httpd/conf/ssl.key/mydomain.net.hspc.key

SSLEngine on

ServerAlias shop.mydomain.net

</VirtualHost>

[/pre]

 

I have also included a couple of bits from the top of the main section because they look relevant, but have removed any commented parts for brevity.

 

[pre]

### Section 2: 'Main' server configuration

User apache

Group apache

 

ServerAdmin webmaster@mydomain.net

 

ServerName mydomain.v.servelocity.net:80

 

UseCanonicalName Off

 

DocumentRoot "/var/www/html"

<IfDefine !tmpl_openwebmail-fc1>

ScriptAlias /mail /var/www/cgi-bin/openwebmail/openwebmail.pl

</IfDefine>

 

<Directory />

    Options FollowSymLinks

    AllowOverride None

</Directory>

 

<Directory "/var/www/html">

    Options Indexes FollowSymLinks

    AllowOverride None

    Order allow,deny

    Allow from all

</Directory>

 

<IfModule mod_userdir.c>

    UserDir disable

</IfModule>

[/pre]

 

Thanks again for any advice you can spare.

 

Tone

Link to comment
Share on other sites

Hello Again,

 

I have copied my httpd.conf and am going to be brave and have a fiddle to see if I can make progress. I have learnt a fair bit in the last 24 hours, so I may just have some success  ;D

 

Could someone answer me this please, as it may help if my editing doesn't work... it would also be handy to know.

 

If DocumentRoot and the main <Directory> directive in httpd.conf are set to /var/www/html is it possible to set a .htaccess file to point the server at another directory to fetch the pages? If it is possible, is there anything to be wary about doing this?

 

Thanks again.

 

Tony

Link to comment
Share on other sites

Sorry, forgot about this thread.

 

If DocumentRoot and the main <Directory> directive in httpd.conf are set to /var/www/html is it possible to set a .htaccess file to point the server at another directory to fetch the pages?

 

No, reason being your .htacces file must be within a document root to be read.

 

The reason mydomain.net is trying to serve pages from /var/www/html is because that is the default as defined within your main configuration. Seeing as no vhosts exist for this domain it will default back to that.

 

The best thing to do would be, on each occurence of ServerAlias within your 'Section 3: Virtual Hosts' add a new alias for mydomain.net. So....

 

ServerAlias "www.mydomain.v.servelocity.net"

 

would become....

 

ServerAlias "www.mydomain.v.servelocity.net mydomain.net"

 

 

Link to comment
Share on other sites

Thanks Thorpe... I thought you had turned in, but have just checked and you haven't had lunch yet  ;D

 

I think I may have phrased my .htaccess question poorly. If DocumentRoot was set to /var/www/html and a .htaccess file was put in this location, could you use it to send the server to another directory to fetch all of the pages?

 

I have got things running again, but am not very confident with this, so am not sure if my solution is a good one. I have basically changed all references to the directory /home/webadmin/mydomain.net to /home/webadmin/mydomain.v.servelocity.net which has the site back up and running again.

 

I have kept the original httpd.conf file and if you think the solution you have provided is a better one I think I will use it.

 

Just so I am clear, you think I should append mydomain.net to the server alias string in each of the three vhosts defined? You also say that no vhosts exist for mydomain.net, but I see the second definition has "www.mydomain.net" defined.

 

Not that I am questioning you, I am trying to understand why this doesn't count.

 

You sound like you have a fair bit of experience with this, where as I have very limited PHP experience and my Unix Like experience is limited to a failed install of FreeBSD that I gave up on out of frustration a couple of months ago. I am a mature student, almost completed my CS degree, and am proficient with html/css OK with C++ and Java and can manage a bit of JS but haven't really had the time to get a book. This site looks like a good place to hang out to pick up some new stuff, though I would also like to ask you if you know of any good resources for picking up PHP and Unix. The PHP I can probably pick up as I go, having done bits and pieces already, but the documentation for the Unix like projects I have looked at are a nightmare for newbies!

 

Any advice is gratefully received.

 

Thanks again for your help.

 

Tony

 

 

 

 

Link to comment
Share on other sites

I have basically changed all references to the directory /home/webadmin/mydomain.net to /home/webadmin/mydomain.v.servelocity.net which has the site back up and running again.

 

I have kept the original httpd.conf file and if you think the solution you have provided is a better one I think I will use it.

 

No, that seems a very logical solution.

 

You also say that no vhosts exist for mydomain.net, but I see the second definition has "www.mydomain.net" defined.

 

Sorry, looking at your config again I can see several definitions for mydomain.net. Its a little hard to read your post. Normally *.conf files are indented into logical blocks, maybe you lost some of these in your post? We have


tags for this exact purpose.

 

I would also like to ask you if you know of any good resources for picking up PHP and Unix.

 

PHP is cross platform so there really isn't any difference between php on windows or *nix untill you specifially go out of your way to write code for a partiular platform. I'm not sure if your looking for a resource on Linux in particular but there is a link in my signiture (rute) that I have found most usefull over the years.

Link to comment
Share on other sites

No, that seems a very logical solution.

 

Am avoiding logic at the moment... can't think logically how this happened in the first place  ;D

 

Sorry, looking at your config again I can see several definitions for mydomain.net. Its a little hard to read your post. Normally *.conf files are indented into logical blocks, maybe you lost some of these in your post? We have


tags for this exact purpose.

 

No need to apologise, you have been a great help and given me a bit of confidence when I needed it. I had used the pre tags, but will use code for future posts. In this case it wouldn't have helped, because that is what the config files look like when the developer had finished. I can see why the Uni bang on about proper indentation and comments... makes life much easier.

 

And thanks, I have bookmarked rute. Would you have any particular recommendation for the flavour of *nix to start out with? I figure once you learn one, adapting for different versions will be fairly straightforward. I found the docs on FreeBSD a bit disorganised and as soon as I had a problem I found it very hard to troubleshoot.

 

Ubuntu seems to becoming quite popular, but I am not sure for what reason.

 

Anyway, thanks again. I have bookmarked this site and I am sure I will be back. I may even be able to help someone else one day  :D

 

Tony

 

 

 

 

 

Link to comment
Share on other sites

Ubuntu seems to becoming quite popular, but I am not sure for what reason.

 

Yeah ubuntu is very popular. Mostly because of its ease of use. It'll hold your hand pretty tight, which isn't always a good thing when you want to learn. When I started with Linux I found Gentoo to be the best learning experience I had. You need plenty of time for it though, it won't hold your hand at all.

 

I'm now using Debian which I find to be a good middle ground. Its one of the older standing distros so theres plenty of information around and its rock solid stable even if a little slow to release. Depending on your hardware needs you can either go with Etch (also known as stable) which while doesn't provide the very latest is very very stable, or if you like living on the edge a little and need newer hardware support you might need to roll with Sid (also known as unstable, but don't let that deter you).

 

I run Sid on my desktop which needs all the latest drivers etc, while I run Etch on several servers.

 

Have fun!

Link to comment
Share on other sites

Thanks for the info. I'll have a gander through the docs of the various distributions you mention and see which one I think will be the easiest to find stuff for. I think I may start with Debian.

 

Time is always a problem...self employed student, so I kind of grab time for new stuff when it comes along, so I think I may avoid Sid for the minute. I am going to try and use an old Dell Optiplex with a PIII inside, an old machine I use for leaning and testing.

 

Have fun!

 

I'll certainly try!!

Link to comment
Share on other sites

Just need to download it first on my paltry ADSL connection!

 

I'm sure you'll see the cries of despair on the Linux board in the not too distant future ;)

 

Thanks once more for your help and advice.

 

Tone

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.