CAUTION: This gets technical and requires fairly solid ssh knowledge.
CAUTION: Many issues are not covered, such as email users and file ownership and sql-xfer and php stuff and all those functions etc etc.
This is only a very basic tutorial that explains how to get apache to work on the html side of things
-------------------------------
CAUTION: user:user ownership
Following this tutorial verbatim will leave all your sites root:root
-------------------------------
Pre-requisites: A flavor of Linux, debian and apache are the ones I use (Ubuntu Gutsy, CentOS 5.0)
Properly propagated or correctly pointed nameservers.
Working Apache!
This can and does work for Windows servers but this is written for Unix
---------------------------------
WARNING: Editing of critical server files is required!!!
---------------------------------
DANGER: Removing a cp on a production server could delete all your sites!
---------------------------------
NOTES: Probably best for servers with few sites.
----------------------------------
Credits and Thanks to the Orbit Support Team for their invaluable assistance!
Steps:
- Order up a server without a cp or remove the cp on the one you have.
> In my case I waited until a server upgrade to make the switch, I felt it better to start clean.
WARNING: I am not telling you how to remove the cp, this is what I meant about technical, if it works don't fix it.
This might work leaving the cp on your server so long you disable the references within apache, but I would either start clean or remove it entirely myself. Obviously on a production server you'll want to backup every thing.
Once that is done, straight to the good stuff:
/////////////////////////////////
- ssh + su to root (on redhat 'su-' on debian 'sudo su')
- go to root of root folder by doing a 'cd /'
- Create a folder sites 'mkdir sites'
/////////////////////////////////
- Go find httpd.conf (some default 'cd /etc/httpd/conf')
> If you can not find it try doing a 'locate httpd.conf'
- Back it UP! 'cp httpd.conf httpd.conf.LASTWORKING
> So if at anytime it fouls up totally you can restore apache
When editing, ALWAYS make a backup first!
/////////////////////////////////
- edit httpd.conf as follows: (either pico or vi)
Most of this should be right towards the end of your file.
Find: NameVirtualHost
Change the entry from
#NameVirtualHost *
to
NameVirtualHost 127.0.0.1:80 <--- Your server IP address not 127.0....
-----
Find the stuff that looks like:
#<VirtualHost *>
# ServerAdmin webmaster@domainname.com
# DocumentRoot /www/docs/domainname.com
# ServerName domainname.com
# ErrorLog logs/domainname-error_log
# CustomLog logs/domainname-access_log common
#</VirtualHost>
Delete all that (or leave it commented) and replace or add this line:
Include /etc/httpd/conf/virtual/*.conf
^^^^^^^^^^^
(/etc/httpd/conf/ <-- path to your httpd.conf)
Save and Exit.
/////////////////////////////////
From within /etc/httpd/conf/ (or where your httpd.conf is)
mkdir virtual
cd virtual
/////////////////////////////////
You have to decide NOW which way to name your sites.
Either site1, site2, etc...
I used the domainname without the com
Or some kind of nomenclature
This tutorial assumes domainname
SO, time to create a domainname.conf (the name of the domain you wish to host!)
vi domainname.conf
Then, drop this into that:
<VirtualHost domain.com:80>
ServerAdmin webmaster@domain.com
DocumentRoot /sites/domain/www/html
ServerName domain.com
ServerAlias *.domain.com
ScriptAlias /cgi-bin "/sites/domain/www/cgi-bin"
<Directory "/sites/domain/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
(don't forget to change ALL 'domain' instances with the actual name of the domain, with or without .com as stated)
Save and Exit
> Create ONE .conf for every domain you intend to host!