Posted On April 1, 2019

Apache Hosting Multiple Websites

kimconnect 0 comments
blog.KimConnect.com >> Codes , Linux >> 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/kimconnect
mkdir -p /home/www/kimconnect/htdocs
mkdir -p /home/www/kimconnect/logs
mkdir -p /home/www/kimconnect/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 [email protected]
ServerName www.kimconnect.com
       ServerAlias kimconnect.com
DocumentRoot /home/www/kimconnect/
# HTML documents, with indexing.
<Directory />
Options +Includes
</Directory>

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

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

<VirtualHost *:80>
# Basic setup
ServerAdmin [email protected]
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 [email protected]
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 [email protected]
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 [email protected]
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 *

Related Post

PowerShell: Copy Active Directory User

# copyADUser.ps1 # Version 0.01 $fromUsername='mTyson' $newUserFirstname='Bruce' $newUserLastname='Lee' $newPassword='SOMEPASSWORD' $newEmailAddress='[email protected]' $setProxyAddress=$false function copyADUser{ param( $fromUsername,…

PowerShell: Converting Time Stamp from Int64 to DateTime and Vice Versa

Here are some quick conversion methods between time values represented by Integer and DateTime data…

Setting Up FTP on CentOS 5.3

Install VSFTPD yum -y install vsftpd   Configure: vim /etc/vsftpd/vsftpd.conf ------------------- anonymous_enable=NO // line 12:…
Other project: DragonCoin.com