Pages: Previous123
Current Page: 3 of 3
Re: WAMPServer 2.5 The Homepage, Your Projects Menu and the need for Virtual Hosts (OLD)
Posted by: kevsy (---.bb.sky.com)
Date: February 24, 2015 06:27PM

Hello Riggs dear Sir.

Thanks for replying.

My setup is
1. Windows 7 Premium Home. Bit rate not specified
1a. The computer is 64bit
2. Wampserver2.5 32bit
3. Apache Version 2.4.9
4. PHP Version 5.5.12
5. MySQL Verson 5.6.17
6. Icon goes to 'green'

7. 2 lines are hashed:
20 # 127.0.0.1 localhost
21 # ::1 localhost

7. 2 lines not hashed:
23 127.0.0.1 localhost
24 127.0.0.1 localhost

8. Localhost (Homepage Server) accessed OK
9. PHPMyadmin accessed OK
10. Error message = 'Server not found' after trying to access via 'Your Projects'
10a. File accessable without error message if keyed into the url
11. Anti Virus = AVG
12 path = C:\wamp

kevsy

Options: ReplyQuote
Re: WAMPServer 2.5 The Homepage, Your Projects Menu and the need for Virtual Hosts
Posted by: ajbg (---.84.87-224.dyn.dsl.cantv.net)
Date: October 10, 2015 05:12AM

andrzej.kmicic Wrote: I need this script I have tried to copy but gives me error as it is added to the code please smile if I can send the script would appreciate
-------------------------------------------------------
> I do a lot and often virtual hosts. That's why I
> did alongside the script and I put to Wamp. The
> script looks at hosts founded in file
> C:\Windows\System32\drivers\etc\hosts ", orders
> them and removes duplicate names. Interact with
> the console asks for the host name and inserts it
> with the ip adersem the same as localhost
> (127.0.0.1).
> Then the script asks for the host directory, email
> the Admin, the index file and inserts the file ""
> settings of virtual hosts and their settings
> directories.
>
> If someone wants to can easily add a list of hosts
> as:
> 1. jump to a folder (shell execute)
> 2. open the host by default browser
>
>
> Note: copy and run at your own risk, for me in
> win7 is OK.
>
> Script : C:\wamp\scripts\addVHost.php
>
> <?php
> $hostemail="johndoe@mail.com";
> $dindex=array("DirectoryIndex","index.php"winking smiley ;
> start_again:
> $path=$_SERVER['SystemRoot'].'\\System32\\drivers\
> \etc\\hosts';
> $vpath="C:\\wamp\\vhosts\\httpd-vhosts.conf";
> $vhostStr = file_get_contents($path) ;
> $lines = preg_split("/[\r?\n]+/",$vhostStr) ;
> $hosts = array() ;
> $unique = array() ;
> $ipV4Patt
> ="(\b(?sad smiley?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.
> ){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)";
> $ipV6Patt
> ="(((\b[\da-fA-F]{1,4}smiling smiley{7}|:{2,7})([\da-fA-F]{1,4
> }))";
> $hostPatt="([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)
> ?)?";
> 
> $virtualHostData ="
> <VirtualHost *:80>
> ServerName {{hostname}}
> DocumentRoot \"{{folder}}\"
> {{directory_index}}
> ServerAdmin {{admin_email}}
> ErrorLog \"logs/{{hostname}}.log\"
> CustomLog \"logs/{{hostname}}-access.log\" common
> </VirtualHost>
> 
> <Directory \"{{folder}}\">
>     Options Indexes FollowSymLinks MultiViews
>     AllowOverride all
>         Order allow,deny
>     Allow from all
> </Directory>
> 
> ";
> 
> 
> 
> foreach($lines as $line) {
> if (preg_match("/^\s*\#/",$line)) continue;
> if
> (preg_match("%^\s*(?<ip>($ipV6Patt)||($ipV4Patt))\
> s+(?<host>$hostPatt)%",$line,$match)) {
>     $hosts[$match['host']]=$match['ip'];
>     $unique[$match['host']]=$match['ip'];
>     }
> }
> $localip="127.0.0.1";
> $str="";
> foreach($lines as $line) {
> if (preg_match("/^\s*\#/",$line)) $str .=
> $line."\n";
> if
> (preg_match("%^\s*(?<ip>($ipV6Patt)||($ipV4Patt))\
> s+(?<host>$hostPatt)%",$line,$match)) {
>     if (isset ($hosts[$match['host']])) {
>         $str .=
> "\t".$match['ip']."\t".$match['host']."\n";
>         if (trim($match['host'])=="localhost"winking smiley
> $localip=trim($match['ip']) ; 
>         unset ($hosts[$match['host']]) ;
>         }
>     }
> }
> 
> echo "
> 
> virtual host be create on addres : $localip
> input name of new virtual host (eg) : www.my.zone
> >";
> $newVirtHost = strtolower (trim(fgets(STDIN))) ;
> $message = "";
> if (! preg_match("%^($hostPatt)$%",$newVirtHost))
> $message="Host name is not correct\n";
> if (isset ($unique[$newVirtHost])) $message .=
> "Host is not unique (hostname conflict!)\n";
> 
> if ($message ==""winking smiley {
>     $str .= "\t$localip\t$newVirtHost\n";
>     echo "
> 
>     ",$str;
> 
>     echo "
> 
>     If this list is good, and to be saved, enter
> ([no] or yes):>";
>     $save = trim(fgets(STDIN)) ;
>     if (strtolower($save)=="yes"winking smiley {
>         if (file_put_contents($path,$str)) {
>             echo $message,"\nVHost is saved,Press
> Enter to continue...";
>             trim(fgets(STDIN)) ;
>             
>            
> $vpath="C:\\wamp\\vhosts\\httpd-vhosts.conf";
>             $virtualStr =
> file_get_contents($vpath) ;
>             
>            
> $appdata=$_SERVER['APPDATA']."\\$newVirtHost";
> echo "
> 
> to complette input data for real path on virtual
> host : $newVirtHost
> 
> input folder name to this host (eg) : $appdata
> >>";
> 
>             $result= (trim(fgets(STDIN))) ;
>             $newFolder = $result=="" ? $appdata :
> $result;
>             
>             if(!is_dir($newFolder)) {
>                     echo "The Directory
> {$newFolder} not exists, you want to create it ?
> Press <yes> to create >";
>                     $message="";
>                     $result=
> strtolower(trim(fgets(STDIN))) ;
>                     if ($result=='yes') {
>                     if (! mkdir($newFolder ,
> 0777)) {
>                         $message="Error Create
> Folder: $newFolder \n";
>                         goto toend;
>                     } else 
> $message.="Succesfully, Create Folder: $newFolder
> \n";
>                     }
>             }
> 
> echo "
> input host admin email (eg) : <$hostemail>>";
> 
>             $result= (trim(fgets(STDIN))) ;
>             $newEmail = $result=="" ? $hostemail :
> $result;
> echo "
> input file name for Directory Index (eg) :
> <$dindex[1]>>";
> 
>             $dindex[1]= (trim(fgets(STDIN))) ;
>             $newDirIndex = $dindex[0]."
> ".$dindex[1];
> 
>             $virtualHostData =
> preg_replace(array("/{{hostname}}/","/{{folder}}/"
> ,"/{{admin_email}}/","/{{directory_index}}/"winking smiley,
>                                            
> array($newVirtHost,$newFolder,$newEmail,$newDirInd
> ex),
>                                            
> $virtualHostData) ;
>             $virtualStr .=$virtualHostData;
>             if
> (file_put_contents($vpath,$virtualStr)) {
>                 $message .="You Have New
> VirtualHost: [$newVirtHost]
> DocumentRoot = $newFolder
> ";
>             }
>             goto toend;
>         }
>     }
> }
> else  {
> 
>     goto toend;
>     
> 
> }
> 
> toend:
>     echo "$message\n\nPress Enter to exit, Any Key
> then Again";
>     $result = trim(fgets(STDIN)) ;
>     if ($result==""winking smiley exit; else goto start_again; 
>  
> ?>
>
>
> fragments to add to WAMP
> menu:

>
>
> change file : C:\wamp\wampmanager.ini
>
> [apacheMenu]
> ;WAMPAPACHEMENUSTART
> Type: submenu; Caption: "Version"; SubMenu:
> apacheVersion; Glyph: 3
> Type: submenu; Caption: "Service"; SubMenu:
> apacheService; Glyph: 3
> Type: submenu; Caption: "Moduly Apache"; SubMenu:
> apache_mod; Glyph: 3
> Type: submenu; Caption: "Apache
> Virtual Host"; SubMenu: vhost_add; Glyph:
> 3
> Type: submenu; Caption: "Katalog aliasów";
> SubMenu: alias_dir; Glyph: 3
> Type: item; Caption: "httpd.conf"; Glyph: 6;
> Action: run; FileName: "C:/Program
> Files/notepad++.exe";
> parameters:"c:/wamp/bin/apache/apache2.4.9/conf/ht
> tpd.conf"
> Type: item; Caption: "Apache error log"; Glyph: 6;
> Action: run; FileName: "C:/Program
> Files/notepad++.exe";
> parameters:"c:/wamp/logs/apache_error.log"
> Type: item; Caption: "Apache access log"; Glyph:
> 6; Action: run; FileName: "C:/Program
> Files/notepad++.exe";
> parameters:"c:/wamp/logs/access.log"
> ;WAMPAPACHEMENUEND
>
>
> the same changes in file :
> C:\wamp\wampmanager.tpl
>
> [apacheMenu]
> ;WAMPAPACHEMENUSTART
> Type: submenu; Caption: "Version"; SubMenu:
> apacheVersion; Glyph: 3
> Type: submenu; Caption: "Service"; SubMenu:
> apacheService; Glyph: 3
> Type: submenu; Caption: "${w_apacheModules}";
> SubMenu: apache_mod; Glyph: 3
> Type: submenu; Caption: "Apache
> Virtual Host"; SubMenu: vhost_add; Glyph:
> 3
> Type: submenu; Caption: "${w_aliasDirectories}";
> SubMenu: alias_dir; Glyph: 3
> Type: item; Caption: "httpd.conf"; Glyph: 6;
> Action: run; FileName: "${c_editor}";
> parameters:"${c_apacheConfFile}"
> Type: item; Caption: "${w_apacheErrorLog}"; Glyph:
> 6; Action: run; FileName: "${c_editor}";
> parameters:"${c_installDir}/${logDir}apache_error.
> log"
> Type: item; Caption: "${w_apacheAccessLog}";
> Glyph: 6; Action: run; FileName: "${c_editor}";
> parameters:"${c_installDir}/${logDir}access.log"
> ;WAMPAPACHEMENUEND
>
>
> and in file : C:\wamp\wampmanager.tpl
>
> [alias_dir]
> ;WAMPALIAS_DIRSTART
> Type: separator; Caption: "${w_aliasDirectories}"
> Type: item; Caption: "${w_adddAlias}"; Action:
> multi; Actions: add_alias;Glyph : 1
> Type: separator
> ;WAMPADDALIAS
> ;WAMPALIAS_DIREND
> 
> [vhost_add]
> ;WAMPALIAS_DIRSTART
> Type: separator; Caption: "VIRTUAL HOST"
> Type: item; Caption: "AddVHOST"; Action: multi;
> Actions: add_vhost;Glyph : 1
> Type: separator
>
>
>
> regards Andrzej Kmicic

Options: ReplyQuote
Pages: Previous123
Current Page: 3 of 3


Sorry, you can't reply to this topic. It has been closed.