Adding multiple sites to apache/hosting different sites on apache with DRUPAL
For each site you want to host in apache, you must have created separate folders for each site in /var/www directory. This is same like creating sites on IIS.
mkdir /var/www/www.example.com
mkdir /var/www/www.example.com/htdocs
mkdir /var/www/www.example.com/cgi-bin
mkdir /var/www/www.example.com/logs
Create individual configuration file for each site. User defined settings for apache will be configured in http.conf file.
Copy the drupal installation file to each individual site folder. Ex. Copy the drupal directory to /var/www1/ www.example.net/
This copying process make easy to install and configure the drupal for each site.
Edit the httpd.conf file as follows,
#
# (/var/www1/www.example.com)
#
ServerAdmin user@domain.com
ServerName www. Example.com
ServerAlias *.example.com
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /var/www1 / www.example.com/
# CGI Directory
ScriptAlias /cgi-bin/ /var/www1/ www.example.com/
Options +ExecCGI
# Logfiles
ErrorLog /var/www1/www. Example.com/logs/error.log
CustomLog /var/www/www. example .com/logs/access.log combined
Create configuration file for www.example.net
ServerAdmin user@domain.com
ServerName www. Example.net
ServerAlias *.example.net
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /var/www1 /www.example.net/
# CGI Directory
ScriptAlias /cgi-bin/ /var/www1/ www.example.net
Options +ExecCGI
# Logfiles
ErrorLog /var/www1/www. Example.net/logs/error.log
CustomLog /var/www/www. example .net/logs/access.log combined
Save the site configuration and exit.
/etc/init.d/apache2 reload
Cool.. That’s it. We are running more than one host in Apache server.
Possible errors
NameVirtualHost *:81 – No virtual host is defined.
Remove this line in /etc/apache2/ports.conf
NameVirtual host *:80
You don’t have permission to access the root on this server.
Make sure you have index.html under your site directory /var/www/www.site.com/htdocs/index.html. just copy the default index.html file and paste to virtual host htdocs directory
Make sure to adjust folder permission of www.example.com
chmod –R a=rx /var/www/www.example.com
Create database for drupal site.
Next, create databases in MySQL to use with websites.
CREATE DATABASE `testing`;
GRANT ALL ON *.* TO ‘root’@'localhost’ identified by ‘password’;
FLUSH PRIVILEGES;
This code creates database called testing and give full permission to user root@localhost.
If you want to manage this MySQL database remotely you can specify any ip address in the place of localhost.
For ex.
GRANT ALL ON *.* TO ‘root’@’192.168.0.15′ identified by ‘password’;
GRANT ALL ON *.* TO ‘root’@’218.25.2.78′ identified by ‘password’;
This is the command to update the existing database with new external host or IP address. Only IP address 202.54.10.20 can access the DB webdb with username webadmin.
mysql> update db set Host=’202.54.10.20′ where Db=’webdb’;
mysql> update user set Host=’202.54.10.20′ where user=’webadmin’;
Make sure to disable loop back binding in /etc/mysql/my.cnf. Under [mysqld] comment loopback IP (#127.0.0.1) and comment skip-networking (#skip-networking)
Now you have everything to install DRUPAL CMS in apache site. Just open the URL you will be prompted for installation process.
During installation use the database you have created and corresponding username and password.
You might get error during installation about sites/default/settings.php
This is because the directory you are installing is, write protected. Enable the write permission on drupal installation directory.
Command,
Chmod –R 777 /var/www1/www.example.com/
This will solve errors during install process.
Note: After installation change permissions on site directory.
Download As PDF
For each site you want to host in apache, you must have created separate folders for each site in /var/www directory. This is same like creating sites on IIS.
mkdir /var/www/www.example.com
mkdir /var/www/www.example.com/htdocs
mkdir /var/www/www.example.com/cgi-bin
mkdir /var/www/www.example.com/logs
Create individual configuration file for each site. User defined settings for apache will be configured in http.conf file.
Copy the drupal installation file to each individual site folder. Ex. Copy the drupal directory to /var/www1/ www.example.net/
This copying process make easy to install and configure the drupal for each site.
Edit the httpd.conf file as follows,
#
# (/var/www1/www.example.com)
#
ServerAdmin user@domain.com
ServerName www. Example.com
ServerAlias *.example.com
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /var/www1 / www.example.com/
# CGI Directory
ScriptAlias /cgi-bin/ /var/www1/ www.example.com/
Options +ExecCGI
# Logfiles
ErrorLog /var/www1/www. Example.com/logs/error.log
CustomLog /var/www/www. example .com/logs/access.log combined
Create configuration file for www.example.net
ServerAdmin user@domain.com
ServerName www. Example.net
ServerAlias *.example.net
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /var/www1 /www.example.net/
# CGI Directory
ScriptAlias /cgi-bin/ /var/www1/ www.example.net
Options +ExecCGI
# Logfiles
ErrorLog /var/www1/www. Example.net/logs/error.log
CustomLog /var/www/www. example .net/logs/access.log combined
Save the site configuration and exit.
/etc/init.d/apache2 reload
Cool.. That’s it. We are running more than one host in Apache server.
Possible errors
NameVirtualHost *:81 – No virtual host is defined.
Remove this line in /etc/apache2/ports.conf
NameVirtual host *:80
You don’t have permission to access the root on this server.
Make sure you have index.html under your site directory /var/www/www.site.com/htdocs/index.html. just copy the default index.html file and paste to virtual host htdocs directory
Make sure to adjust folder permission of www.example.com
chmod –R a=rx /var/www/www.example.com
Create database for drupal site.
Next, create databases in MySQL to use with websites.
CREATE DATABASE `testing`;
GRANT ALL ON *.* TO ‘root’@'localhost’ identified by ‘password’;
FLUSH PRIVILEGES;
This code creates database called testing and give full permission to user root@localhost.
If you want to manage this MySQL database remotely you can specify any ip address in the place of localhost.
For ex.
GRANT ALL ON *.* TO ‘root’@’192.168.0.15′ identified by ‘password’;
GRANT ALL ON *.* TO ‘root’@’218.25.2.78′ identified by ‘password’;
This is the command to update the existing database with new external host or IP address. Only IP address 202.54.10.20 can access the DB webdb with username webadmin.
mysql> update db set Host=’202.54.10.20′ where Db=’webdb’;
mysql> update user set Host=’202.54.10.20′ where user=’webadmin’;
Make sure to disable loop back binding in /etc/mysql/my.cnf. Under [mysqld] comment loopback IP (#127.0.0.1) and comment skip-networking (#skip-networking)
Now you have everything to install DRUPAL CMS in apache site. Just open the URL you will be prompted for installation process.
During installation use the database you have created and corresponding username and password.
You might get error during installation about sites/default/settings.php
This is because the directory you are installing is, write protected. Enable the write permission on drupal installation directory.
Command,
Chmod –R 777 /var/www1/www.example.com/
This will solve errors during install process.
Note: After installation change permissions on site directory.
No comments:
Post a Comment