Apache Hosting Multiple Websites

Must have a FQDN for localhost:

vim /etc/hosts
---- add this line ----
192.168.1.5        server1.cafecenter.com server1
----------------------

Install GD most likely needed by some websites:
yum install gd gd-devel php-gd

Enable mod_rewrite:
# vim /etc/httpd/conf/httpd.conf

FIND SECTION BEGINNING
<Directory "/home/www/html">
Options Indexes FollowSymLinks
AND
DocumentRoot "/home/www/html/"

---
Set:
AllowOverride All  //do this 2 times
----


Create home folders for each website:
mkdir -p /home/www
mkdir -p /home/www/sexcenter
mkdir -p /home/www/sexcenter/htdocs
mkdir -p /home/www/sexcenter/logs
mkdir -p /home/www/sexcenter/cgi-bin
mkdir -p /home/www/kimcomputer
mkdir -p /home/www/kimcomputer/htdocs
mkdir -p /home/www/kimcomputer/logs
mkdir -p /home/www/kimcomputer/cgi-bin
mkdir -p /home/www/cafecenter
mkdir -p /home/www/cafecenter/htdocs
mkdir -p /home/www/cafecenter/logs
mkdir -p /home/www/cafecenter/cgi-bin
mkdir -p /home/www/ocgold
mkdir -p /home/www/ocgold/htdocs
mkdir -p /home/www/ocgold/logs
mkdir -p /home/www/ocgold/cgi-bin

Change the policy to let SELinux have access to new DocumentRoot
chcon -R system_u:object_r:httpd_sys_content_t /home/www

# vim /etc/httpd/conf/httpd.conf
NameVirtualHost *:80

<VirtualHost *:80>
# Basic setup
ServerAdmin admin@sexcenter.com
ServerName www.sexcenter.com
       ServerAlias sexcenter.com
DocumentRoot /home/www/sexcenter/
# HTML documents, with indexing.
<Directory />
Options +Includes
</Directory>

# CGI Handling
ScriptAlias /cgi-bin/ /home/www/sexcenter/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>

# Logfiles
ErrorLog /home/www/sexcenter/logs/error.log
CustomLog /home/www/sexcenter/logs/access.log combined
</VirtualHost>

<VirtualHost *:80>
# Basic setup
ServerAdmin admin@cafecenter.com
ServerName www.cafecenter.com
       ServerAlias cafecenter.com
DocumentRoot /home/www/cafecenter/

# HTML documents, with indexing.
<Directory />
Options +Includes
</Directory>

# CGI Handling
ScriptAlias /cgi-bin/ /home/www/cafecenter/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>

# Logfiles
ErrorLog /home/www/cafecenter/logs/error.log
CustomLog /home/www/cafecenter/logs/access.log combined
</VirtualHost>

<VirtualHost *:80>
# Basic setup
ServerAdmin admin@ocgold.com
ServerName www.ocgold.com
       ServerAlias ocgold.com
DocumentRoot /home/www/ocgold/
# HTML documents, with indexing.
<Directory />
Options +Includes
</Directory>

# CGI Handling
ScriptAlias /cgi-bin/ /home/www/ocgold/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>

# Logfiles
ErrorLog /home/www/ocgold/logs/error.log
CustomLog /home/www/ocgold/logs/access.log combined
</VirtualHost>

<VirtualHost *:80>
# Basic setup
ServerAdmin kim@kimcomputer.com
ServerName www.kimcomputer.com
       ServerAlias kimcomputer.com
DocumentRoot /home/www/kimcomputer/
# HTML documents, with indexing.
<Directory />
Options +Includes
</Directory>

# CGI Handling
ScriptAlias /cgi-bin/ /home/www/kimcomputer/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>

# Logfiles
ErrorLog /home/www/kimcomputer/logs/error.log
CustomLog /home/www/kimcomputer/logs/access.log combined
</VirtualHost>

# phpMyAdmin setup
<VirtualHost *:50000>
# Basic setup
ServerAdmin admin@kimconnect.com
ServerName localhost
ServerAlias 192.168.1.80
DocumentRoot /usr/share/phpmyadmin

# HTML documents, with indexing.
<Directory />
Options +Includes
</Directory>
</VirtualHost>

--------------------------
# apachectl configtest //test to see if syntax is ok
# service httpd reload

Set selinux to allow httpd access:
setsebool -P httpd_disable_trans=1
----------------------------------------------

Leave a Reply

Your email address will not be published. Required fields are marked *