Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create virtual host on XAMPP [duplicate]

I am sure this question is being asked many times but I am not encounter with a problem. I am using XAMPP where I configure Zend framework.

XAMPP is running on port 8081 as 80 is being occupied by some Windows process I need to use virtual host for that I configure with following code in C:/xampp/apache/config/extra/httpd-vhosts.config (or C:/xampp/apache/conf/extra/httpd-vhosts.conf in newer releases).

<VirtualHost *:80> ServerName comm-app.local DocumentRoot "C:/xampp/htdocs/CommunicationApp/public" SetEnv APPLICATION_ENV "development"     <Directory "C:/xampp/htdocs/CommunicationApp/public"         DirectoryIndex index.php         AllowOverride All         Order allow,deny         Allow from all     </Directory> </VirtualHost>     

and also update the hosts file with 127.0.0.1 comm-app.local and try to re-start apache but it is showing error.

15:03:01  [Apache]  Error: Apache shutdown unexpectedly. 15:03:01  [Apache]  This may be due to a blocked port, missing dependencies,  15:03:01  [Apache]  improper privileges, a crash, or a shutdown by another method. 15:03:01  [Apache]  Press the Logs button to view error logs and check 15:03:01  [Apache]  the Windows Event Viewer for more clues 15:03:01  [Apache]  If you need more help, copy and post this 15:03:01  [Apache]  entire log window on the forums 
like image 352
Paras Arora Avatar asked Dec 03 '14 09:12

Paras Arora


People also ask

Can I host multiple websites on XAMPP?

You can run more than one WordPress website in your XAMPP staging environment through virtual hosts. Virtual hosts allow us to use aliases to run multiple websites on the same IP address and web server.

Which of the following files is used to create a virtual host in XAMPP windows?

Open 'httpd-. conf' file located in XAMPP installation folder (\xampp\apache\conf\ httpd-. conf) in any text editor and search for 'virtual hosts'.

How do I run multiple projects in XAMPP?

By default XAMPP is setup to run at http://localhost and serve pages that are kept under C:/xampp/htdocs. In this situation, if you want to develop multiple websites, you will need to create a folder under C:/xampp/htdocs for each website and keep the website files thereunder.


1 Answers

Step 1) C:\WINDOWS\system32\drivers\etc\ Open the "hosts" file :

127.0.0.1       localhost 127.0.0.1       test.com 127.0.0.1       example.com 

Step 2) xampp\apache\conf\extra\httpd-vhosts.conf

<VirtualHost *:80>     DocumentRoot C:/xampp/htdocs/test/     ServerName www.test.com </VirtualHost> <VirtualHost *:80>     DocumentRoot C:/xampp/htdocs/example/     ServerName www.example.com </VirtualHost> 

Step 3) C:\xampp\apache\conf\httpd.conf. Scroll down to the Supplemental configuration section at the end, and locate the following section (around line 500), Remove the # from the beginning of the second line so the section now looks like this:

#Virtual hosts Include conf/extra/httpd-vhosts.conf 

Step 4) Restart XAMPP and now run in your browser :

www.example.com or www.test.com 
like image 125
Amit Naraniwal Avatar answered Sep 28 '22 10:09

Amit Naraniwal