chantown Posted December 11, 2007 Share Posted December 11, 2007 for example, my website is www.domain.com , and it is in /var/www/html (apache) Is there any way I can make www.test.domain.com to /var/www/test ? So that I can test my website while also having it run to the public Quote Link to comment https://forums.phpfreaks.com/topic/81101-how-do-i-make-a-subdomain/ Share on other sites More sharing options...
trq Posted December 11, 2007 Share Posted December 11, 2007 You need to use two seperate virtual hosts. eg; NameVirtualHost * <VirtualHost *> ServerName domain.com ServerAlias www.domain.com DocumentRoot /var/www/domain.com <Directory /var/www/domain.com> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all DirectoryIndex index.php </Directory> ErrorLog /var/log/apache2/domain.com-error.log LogLevel warn CustomLog /var/log/apache2/domain.com-access.log combined </VirtualHost> <VirtualHost *> ServerName test.domain.com DocumentRoot /var/www/test.domain.com <Directory /var/www/test.domain.com> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all DirectoryIndex index.php </Directory> ErrorLog /var/log/apache2/test.domain.com-error.log LogLevel warn CustomLog /var/log/apache2/test.domain.com-access.log combined </VirtualHost> Quote Link to comment https://forums.phpfreaks.com/topic/81101-how-do-i-make-a-subdomain/#findComment-411522 Share on other sites More sharing options...
chantown Posted December 11, 2007 Author Share Posted December 11, 2007 thank you, i'll give that a try! Quote Link to comment https://forums.phpfreaks.com/topic/81101-how-do-i-make-a-subdomain/#findComment-411539 Share on other sites More sharing options...
DK_Sun Posted December 13, 2007 Share Posted December 13, 2007 Also you'll need to setup your DNS entries for it to work. Without it, even though you setup your server right. It still WON'T WORK. Quote Link to comment https://forums.phpfreaks.com/topic/81101-how-do-i-make-a-subdomain/#findComment-413541 Share on other sites More sharing options...
rockhopper-ies Posted December 13, 2007 Share Posted December 13, 2007 Hello all, I'm am new to LAMP server builds, so I will apologize for my newbishness upfront. I *almost* understand about virtual host configurations. I have a development server running Debian Lenny, with several virtual hosts defined in the /etc/apache2/sites-enabled I am accessing the sites through my network, using manual host files on the other computers. I see these sites fine. However, I tried to recreate this setup on my Kubuntu Gutsy laptop, and have hit a patch of fog. (does not work the same) My questions: NameVirtualHosts * <- do I put that in my individuals /sites-available/domain1 files, in a separate vhosts file under /etc/apache2/conf.d, or in the httpd.conf file? Do I declare the virtual hosts in the httpd.conf file or under the sites-available directory? Thank you for your help, Rockhopper Quote Link to comment https://forums.phpfreaks.com/topic/81101-how-do-i-make-a-subdomain/#findComment-413772 Share on other sites More sharing options...
trq Posted December 14, 2007 Share Posted December 14, 2007 There are lots of different ways different distros setup there apache configs, I prefer (usually) to roll my own. You only need to have the NameVirtualHosts * line once and it must be before any vhosts are defined, so with a Debian setup, I usually place this just prior to the... Include /etc/apache2/sites-enabled/* line within the apache.conf file. I'm not exactly sure how Kubuntu would be setup by default, but there usually all pretty similar. You just need to know the order in which each file is included and what there intended pupose is. I have a few posts in my blog (http://thorpesystems.com) that may be of interest to you. I'm not sure how helpfull they will be but you might get some ideas. Quote Link to comment https://forums.phpfreaks.com/topic/81101-how-do-i-make-a-subdomain/#findComment-414408 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.