Setting up test sites for the "production" sites

Discuss Networking
User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Setting up test sites for the "production" sites

Post by Basher52 » Fri Jan 30, 2009 1:30 pm


First I need advice where to place all "spam" I put in here, cos when reading it all I've seen that I might have misplaced some threads, like this http://voidmain.is-a-geek.net/forums/vi ... php?t=1477
This could/should have been placed under General Networking even though I use Fedora. Or just tell me where you want it all



Now to the story, but I think you might need some history...

The latest questions I've been asking about has all to do with the same machine, but two different web sites.
One has the webshop and the other just an info page.
I use IP-based Virtual Host as I think this seems to be the simplest to set up and it sure has the least drawback.
Now when we're still trying to get it up and running fully with all the correct information we noticed that we kinda need a test site of them both.

My question now is, how to do this as the best/easiest way?

one site, xxx.se has one IP address and that is now pointing to this server(but the webshop aint up yet due to incorrect prices, logos etc)
the other site(IP not pointing here yet)
Both these sites needs some sort of a test version of what is running live.

I was thinking like this:

www.xxx.se has a /var/www/html/xxx/ and the test site's directory is xxxtest/ and the same with the other one.

how can I do this or do I really need 4 different NICs to get different V-hosts?

Is there a way to like use: www.xxx.se for the public site and use: www.xxx.se/xxxtest for the test site?

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Re: Setting up test sites for the "production" sit

Post by Void Main » Fri Jan 30, 2009 6:59 pm

Basher52 wrote:This could/should have been placed under General Networking even though I use Fedora. Or just tell me where you want it all
Don't worry about it, put it wherever you want. I think we're the only ones that are using these forums anyway. Besides, you weren't even the one that started that thread. :)
I use IP-based Virtual Host as I think this seems to be the simplest to set up and it sure has the least drawback.
I have always preferred name based virtual hosts myself and just have them all share the same address. Unless you have a specific reason to separate them to separate IP addresses. If you want to use separate SSL certificates for each site you will have to use IP based virtual hosts, other than that I would just use name based. Either way I don't believe one way is any harder than the other.
Now when we're still trying to get it up and running fully with all the correct information we noticed that we kinda need a test site of them both.

My question now is, how to do this as the best/easiest way?

one site, xxx.se has one IP address and that is now pointing to this server(but the webshop aint up yet due to incorrect prices, logos etc)
the other site(IP not pointing here yet)
Both these sites needs some sort of a test version of what is running live.

I was thinking like this:

www.xxx.se has a /var/www/html/xxx/ and the test site's directory is xxxtest/ and the same with the other one.

how can I do this or do I really need 4 different NICs to get different V-hosts?

Is there a way to like use: www.xxx.se for the public site and use: www.xxx.se/xxxtest for the test site?
Well, even if you are using IP based virtual hosts you don't need multiple NICS. You can put multiple IP addresses on the same physical interface by creating subinterfaces off of the physical and giving each subinterface their own IP address.

I always set mine up like this:

vhost: www.mydomain1.com
DocumentRoot: /var/www/mydomain1

vhost: www.mydomain2.com
DocumentRoot: /var/www/mydomain2

vhost: www.mydomain3.com
DocumentRoot: /var/www/mydomain3

...
...

I also give them their own log files and other individual configuration. I usually try and keep the test sites on separate vhosts. Again, using name based virtual hosts you can set up 200 sites on your server and only need 1 address.

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Fri Jan 30, 2009 7:42 pm

what I read about this name based thing, is that you need alot of work, but if you say it¨s better than IP based, I sure believe ya, cos you can't be wrong :)

so, what's the least work for me to set these two sites up?
IP-thru NICs or IP-thru... ur thing(which I knew but didn't even think of :( )

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Fri Jan 30, 2009 7:51 pm

Read this and look at the examples:

http://httpd.apache.org/docs/2.2/vhosts/

There really isn't a lot to it. If you have any questions about any of what you read just ask.

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Sun Feb 01, 2009 5:29 am

I removed these lines from the httpd.conf file and create a tperacing.conf file in conf.d/ instead

Code: Select all

<VirtualHost *:80>
    ServerAdmin root@localhost
    DocumentRoot /var/www/html/tperacing
    ServerName xenonlyse.se
    ErrorLog logs/tperacing.se-error_log
    CustomLog logs/tperacing.se-access_log common
</VirtualHost>
<VirtualHost *:443>
    ServerAdmin root@localhost
    DocumentRoot /var/www/html/tperacing
    ServerName xenonlyse.se
    ErrorLog logs/tperacing.se-error_log
    CustomLog logs/tperacing.se-access_log common
    SSLCertificateFile /etc/pki/tls/certs/server.crt
    SSLCertificateKeyFile /etc/pki/tls/private/server.key
</VirtualHost>
but I get this error for the 443 port

Code: Select all

[root@webserver conf.d]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: [Sun Feb 01 12:24:22 2009] [warn] _default_ VirtualHost overlap on port 443, the first has precedence
                                                           [  OK  ]
[root@webserver conf.d]# 
in the httpd.conf file there is a line with this in it, should that be removed?

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sun Feb 01, 2009 9:58 am

Add this line to the top of your tperacing.conf file:

Code: Select all

NameVirtualHost *:443

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Sun Feb 01, 2009 12:06 pm

Seems that just adding that too made the SSL thing work also :D

This is what I got in the tperacing.conf file
the site name is xenonlyse.se since this is the site right now, but I'm also gonna change the tperacing.se into the same site and that is the first web site that was started thus the name of it.

Can you see anything wrong with this?

Code: Select all

Alias /tperacing /var/www/html/tperaing
<Directory /var/www/html/tperaing/>
   order allow,deny
   allow from all
</Directory>

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
    ServerAdmin root@localhost
    DocumentRoot /var/www/html/tperacing
    ServerName xenonlyse.se
    ErrorLog logs/tperacing.se-error_log
    CustomLog logs/tperacing.se-access_log common
</VirtualHost>
<VirtualHost *:443>
    ServerAdmin root@localhost
    DocumentRoot /var/www/html/tperacing
    ServerName xenonlyse.se
    ErrorLog logs/tperacing.se-error_log
    CustomLog logs/tperacing.se-access_log common
    SSLCertificateFile /etc/pki/tls/certs/server.crt
    SSLCertificateKeyFile /etc/pki/tls/private/server.key
</VirtualHost>

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sun Feb 01, 2009 12:39 pm

I'm not exactly sure what your question is. Are you planning on having two names for the same virtual host? If so all you have to do is use the "ServerAlias hostname2" in the vhost config.

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Sun Feb 01, 2009 1:04 pm

yeah, two domains using the same web site.
ok alias, as the alias you told me about phpmyadin and phpMyAdmin?

but this line: ServerName xenonlyse.se
doesn't this has anything to do with it?
If I got to tperacing.se won't the server redirect me to xenonlyse.se?
Can I just remove the ServerName totally?

oh and how about the name set in the browser?
how will that be set if I use one VHost and an alias.

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sun Feb 01, 2009 1:19 pm

No, I thought you wanted to have two different names for the same site (domain1.se and domain2.se) in which case you would just do this in your vhost:

ServerName domain1.se
ServerAlias domain2.se

If you just want to change the name then just change the ServerName to whatever the new name is. No, "ServerAlias" is not "Alias", two completely unrelated directives.

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Sun Feb 01, 2009 1:57 pm

hehe me and my bad English lol

There's gonna be to different domain names that people can browse
tperacing.se and xenonlyse.se but both will use the same web site, same database and same php/css/html files. Later I'm going to change the IP that tperacing.se is now pointing to so it point so this server.
The ServerAlias won't make anyone able to use that in their browser right?

and when I wrote alias, I used that as short for ServerAlias, sorry

Right now I'm trying to setup test versions of this so I can do tests "offline" from the public, but now I got an error again :(

Code: Select all

Alias /tpetest /var/www/html/tpetest
<Directory /var/www/html/tpetest/>
   order deny,allow
   deny from all
   allow from 127.0.0.1
   allow from 192.168.67.10
   allow from 85.119.130.132
   allow from 82.196.123.58
</Directory>

NameVirtualHost *:80
#NameVirtualHost *:443

<VirtualHost *:80>
    ServerAdmin root@localhost
    DocumentRoot /var/www/html/tpetest
    ServerName tpetest.servehttp.com
    ErrorLog logs/tpetest.se-error_log
    CustomLog logs/tpetest.se-access_log common
</VirtualHost>
this is what I get:

Code: Select all

root@webserver html]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: [Sun Feb 01 21:01:27 2009] [warn] NameVirtualHost *:80 has no VirtualHosts
                                                           [  OK  ]
[root@webserver html]# 

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sun Feb 01, 2009 2:04 pm

I never said to put the "NameVirtualHost *:80" in your config and I think if you comment it out it should work.

I'm still not quite sure if we're on the same page with the rest of it but I *think* you've got the idea. :) I can tell you one thing, your English is 1000% better than my Swedish. :)

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Sun Feb 01, 2009 2:50 pm

Void Main wrote:Add this line to the top of your tperacing.conf file:

Code: Select all

NameVirtualHost *:443
well you said the above so I guessed that port 443 could be placed the too :P

But I removed it and I got no errors when restarting httpd
I had some other errors though, it couldn't find a database file, but then I looked at the files that I copied from tperacing and they were owned by root so I chown them to mysql and it warted to work.

About the same page thing...
I don't know how to explain this, but I'll try again.

The two domain names: tperacing.se and xenonlyse.se are both domains that are bought and these two will use the same web server and by same server I mean, the exact same database and other files.
When someone browses to xenonlyse.se the url should point to this name where ever you are inside that site and vice versa for tperacing.se

You said I could use ServerAlias, but can that be used for two different bought domain names?






Why not give Swedish a try, I guess you know some words

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Sun Feb 01, 2009 3:13 pm

Yes. If all content should be identical for both domains then just use the ServerAlias as I mentioned. The only difference between the two sites would be the host.domain portion of the URL in their location box. If they get to the site using the first name, the first name is what will be in the location/URL box in their browser and as far as they know there is no other name for it. People who get to the site by the second name will behave the exact same way, that is, the 2nd site name will be what the user sees in the location box of their browser when they navigate the site (assuming you use relative paths in your content and don't hard code one site name or the other in your links in your code).

User avatar
Basher52
guru
guru
Posts: 923
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Sun Feb 01, 2009 3:29 pm

I just saw some hard coded things in the config files for both Joomla and the webshop files, I a guess this is out of the question :(
We'll see what sis and her husbands says about this.

I think I can have same database for them though and that is the main thing I think.

Post Reply