Link to home
Create AccountLog in
Avatar of shames11
shames11

asked on

How to do vHost configuration for MySQL

Hi,

I need to configure MySQL as vhost on similar lines of apache vhost.

I am using LAMP as well as WAMP.
Avatar of glcummins
glcummins
Flag of United States of America image

You will need to be more specific as to your needs.

An Apache vhost (Virtual Host) is simply a website or group of websites that operate under a single Apache installation.

MySQL is a database server. It cannot operate as a website.

Are you looking for a web front-end to manage your MySQL server, perhaps? If so, something like PHPMyAdmin will provide the functionality that you need:

http://www.phpmyadmin.net/
Avatar of shames11
shames11

ASKER

Yes my requirements are like creating mysql access on the basis of different websites

www.sitename1.com
username1/password1

www.sitename2.com
username2/password2
Then I recommend that you download and install PHPMyAdmin, and then use the Alias keyword in your Apache configuration to direct your users to the PHPMyAdmin installation directory.
Yes but I think this will not work for tools such as SQLYog or MySQL GUI Tools


To elaborate more this is where I have reached
http://trac.lighttpd.net/trac/wiki/Docs:ModMySQLVhost#module-mod-mysql-vhost

I just googled it out for an example.
I will be happy if you can give me a better one.
>> my requirements are like creating mysql access on the basis of different websites

Your requirement as stated does not match the document you posted.

Apache uses vhost configuration files to setup and maintain separate virtual hosts. The document you read simply explains how to move the vhost configuration from flat files into a MySQL database. Are you simply attempting to place your vhost configuration into a MySQL database? Or are you trying to give your website users access to your MySQL database? These are very different requirements.
Yes you got this.

As you can see I have mentioned
>>I need to configure MySQL as vhost on similar lines of apache vhost.

and have given examples too like

www.sitename1.com
username1/password1

www.sitename2.com
username2/password2

www.sitename1.com  // is the hostname1 for the same mysql server
www.sitename2.com  // is the hostname2 for the same mysql server
Again, I ask, which way do you need it? Please answer one of the following questions:

Are you simply attempting to place your vhost configuration into a MySQL database?

Or are you trying to give your website users access to your MySQL database?


"Yes you got this" does not tell me which method you are after.
I need to place vhost configuration into a MySQL database
Okay, now I understand. Thank you.

Apache is configured by default to look for the Virtual Host configuration in files. You will need a way to tell it to look at the information in the database. There are two ways to do this:

 1. Modify the code of Apache, adding a MySQL client and configuration details to cause it to look into the database for the VHost information. This will require a high-level of programming knowledge, as well as time to understand the Apache source code and modify it appropriately.

 2. Find a module that someone else has already created to do this for you. This module exists, and you can find it here:

  http://crazygreek.co.uk/content/mod_shapvh

 For more installation details, please see here

  http://pookey.co.uk/wiki/linux/shapvh

You should note that this module substantially changes the way Apache operates, so you should not expect the setup process to be quick or easy. However, if you follow the instructions provided at the links I posted, you will be able to accomplish what you desire.
Thank you glcummins !!!

I will follow the instructions and try this out.

One question - Do we need to close the question here or we can close this after a day so that I can try this out.
You can leave it open for as long as you need. I will look forward to hearing how this works for you.
Hi,

sorry I am late.

I found a better and simple solutions for this
ALl you have to do is In MYSQL ther is one db called as mysql and it contains a table called as host. we just need to enter recrods as per our requirements like hostname and username and password and other privilages preferences.

Anyway Thanks to all. The discussion here gave me inspiration and hints to dig out the matter.

Any further comments are welcome.
I am glad you found a solution that works for your. However, your explanation leaves a little bit out, perhaps. Yes, the creation of a database table to hold the information is straightforward. However, you still need to get that information into Apache. This can either be via an Apache module that reads the database information, or by a separate process that pulls the information from the database and writes it into a standard Apache vhost file. Which method did you choose to use?
Hi glcummins

I found there is a database called mysql which is already present when you install mysql and in that database there is table called as host. This table contains information related to settings for the hostname/username/password and other privilages to be set. You don't need to do any settings in apache. All you have to do is enter a new record as desired in the table host.

I think this is the easiest and fastest method that can be done. All we have to do is a simple entry into a table host of mysql DB which makes the thing go for us.
The table 'mysql' holds MySQL-specific data, and should not be edited directly. It certainly has no pertinence to Apache Vhost configurations. I would strongly recommend against inserting your Apache data into the 'mysql' database.

For more information, please see mysql.com .
ASKER CERTIFIED SOLUTION
Avatar of ee_auto
ee_auto

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer