I am crazy about this thing, but I want to do it myself in php.
I installed the following on my system.
WAMP Server 2.2, which includes the following
- Apache web server version 2.2.222
- MySQL server version 5.5.24
- PHP Version 5.3.13
- Windows 8 Version 64Bit
Hosts File Location:
C:\Windows\System32\Drivers\etc\hosts
WAMP server location:
C:\wamp
Apache web server location:
- C:\wamp\bin\apache\apache2.2.22 - C:\wamp\bin\apache\apache2.2.22\conf\extra\httpd-vhosts.conf
MySQL Server Location:
C:\wamp\bin\mysql\mysql5.5.24
PHP location:
C:\wamp\bin\php\php5.3.13
I have a simple example of creating VHost in localhost for example I want to create a simple domain www.mylocalsite.com on port 80
For this, I have the following steps:
(1) Enagle Apache Modules
- rewrite_module
- vhosts_alias_module
(2) Open the httpd.conf file to enable Vhost settings
C:\wamp\bin\apache\apache2.2.22\conf\httpd.conf
Virtual hosts
Include conf/extra/httpd-vhosts.conf
(3) Add a VHost entry in the httpd-vhosts.conf file
<VirtualHost *:90> DocumentRoot "C:/mylocalsite.com/" ServerName www.mylocalsite.com # This should be omitted in the production environment SetEnv APPLICATION_ENV development <Directory "C:/mylocalsite.com/"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> ErrorLog "C:/mylocalsite.com/logs/error.log" // Logs folder should be exists CustomLog "C:/mylocalsite.com/logs/access.log" common </VirtualHost>
(4) Add an entry to the hosts file Open the file in Notepad with administrator privileges C: \ Windows \ System32 \ Drivers \ etc \ hosts add the following line to the end of the file and save it.
127.0.0.1 www.mylocalsite.com
(5) Restart the Apache web server (from WAMP) and run it in the browser http://www.mylocalsite.com/ .
Now, my question is: how can I perform the above steps in a dynamic nature using PHP / JSP or any other language .
Suppose I create one HTML form with the following fields, and when submitted, it will create a new MySQL record for this domain.
EDIT:
Domain Type: select option or Radio Options ( Root/Sub-Domain ) Sub-Domain Name ( Optional ): Text field Domain Name: Text field Project Path: text field Log Folder Path: text field Tmp Folder Path: text field Database Type: text field ( mysql/pgsql ) <Submit>
when i press the button , it will automatically create a domain entry in the hosts file, vhosts in httpd-vhosts. conf .
And when you restart the Apache server, it will automatically start the automatically created domain or subdomain.
Does anyone know how I can install the following things in any language just for the local system?