Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Old 2nd September 2011, 15:21
Gufran Gufran is offline
Junior Member
Join Date: Sep 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to create Subdomain on Apache 2

Is there any way I can create a subdomain on my Server using console ?
I do not use any control panel so I want to do it via SSH.
Reply With Quote
Sponsored Links
Old 3rd September 2011, 07:51
zcworld zcworld is offline
Senior Member
Join Date: Jul 2006
Location: South Australia
Posts: 329
Thanks: 2
Thanked 37 Times in 37 Posts
Send a message via MSN to zcworld Send a message via Skype™ to zcworld

you meaning an vhost
like (top level domain)
note ** when you turn on vhosting your default /var/www/html site will go away (most times)

and you want

type of deal ?
if so , its just an easy

at the command line
you can change this for your own needs
type in
mkdir -p /var/www/vhost/x1.mysite.com/htdocs
mkdir -p /var/www/vhost/x1.mysite.com/logs
mkdir -p /var/www/vhost/x1.mysite.com/cgi-bin

mkdir -p /var/www/vhost/x2.mysite.com/htdocs
mkdir -p /var/www/vhost/x2.mysite.com/logs
mkdir -p /var/www/vhost/x2.mysite.com/cgi-bin

==== centos / redhat / fedora ====
chown -R apache:apache /var/www/vhost
=== deb / Ubuntu ====
chown -R www-data:www-data /var/www/vhost

chmod -R 775 /var/www/vhost

(you may want to check the chmod levels there )

i know mainly where the redhat and its clones keep the apache conf files
so you may need to look around for the deb and its clone apache files

open this file and add to the bottom of it the command than quite and save

vi /etc/httpd/conf/httpd.conf

NameVirtualHost *.80

<VirutalHost *:80>
ServerAdmin webmaster@mysite.com
DocumentRoot /var/www/vhost/x1.mysite.com
ServerName x1.mysite.com
ServerAlias www.x1.mysite.com
ErrorLog /var/www/vhost/x1.mysite.com/logs/error_log
CustomLog /var/www/vhost/x1.mysite.com/logs/access_log common
ScriptAlias /cgi-bin/ /var/www/vhost/x1.mysite.com/cgi-bin/

<VirutalHost *:80>
ServerAdmin webmaster@mysite.com
DocumentRoot /var/www/vhost/x2.mysite.com
ServerName x2.mysite.com
ServerAlias www.x2.mysite.com
ErrorLog /var/www/vhost/x2.mysite.com/logs/error_log
CustomLog /var/www/vhost/x2.mysite.com/logs/access_log common
ScriptAlias /cgi-bin/ /var/www/vhost/x2.mysite.com/cgi-bin/

save and quit

than you get access to them update your DNS server records
or edit the hosts files on your system that u will be trying to access the sites from and add

<IP_OF_WWW_BOX> x1.mysite.com x2.mysite.com

save it

windows : \windows\system32\drivers\etc\hosts
linux : /etc/hosts
Shane Ebert :: Facebok
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
create a ftp account for subdomain only all Installation/Configuration 2 4th August 2009 10:01
How do I create a subdomain? torqhost Installation/Configuration 8 23rd February 2008 01:32
Apache 2 subdomain help. Somken Server Operation 1 2nd August 2007 18:38
MaxClients set to appropriate level, but ISPconfig is crashing from it (I think) bpmee Server Operation 6 11th January 2007 20:29
apache user/group won't create directory weedguy Installation/Configuration 6 20th September 2005 00:40

All times are GMT +2. The time now is 14:27.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.