1

I added a virtual host in httpd-vhosts.conf as follows

<VirtualHost *:80>
    ServerAdmin webmaster@localhost.com
    DocumentRoot "C:/xampp/htdocs/basicwebsite/public"
    ServerName basicwebsite.dev
</VirtualHost>

and I also uncommented Include conf/extra/httpd-vhosts.conf from https.conf as suggested in similar threads. I also added 127.0.0.1 basicwebsite.dev in windows/system32/drivers/etc/hosts.

Now when I start Apache it gives the following error

12:07:33 PM  [Apache]   Error: Apache shutdown unexpectedly.
12:07:33 PM  [Apache]   This may be due to a blocked port, missing dependencies, 
12:07:33 PM  [Apache]   improper privileges, a crash, or a shutdown by another method.
12:07:33 PM  [Apache]   Press the Logs button to view error logs and check
12:07:33 PM  [Apache]   the Windows Event Viewer for more clues
12:07:33 PM  [Apache]   If you need more help, copy and post this
12:07:33 PM  [Apache]   entire log window on the forums

When I remove the VirtualHost from httpd-vhosts.conf, Apache starts working smoothly again..

What I am doing wrong? Any suggestions/help would be appreciated.

Nadeem Iqbal
  • 2,357
  • 1
  • 28
  • 43
Nasir Zia
  • 564
  • 1
  • 6
  • 20

2 Answers2

0

Step 1:

Open httpd.conf file present in C:\xampp\apache\conf\httpd.conf Remove the #(hash) sign present to include the “httpd-vhosts.conf” file in httpd.conf file.

Virtual hosts

#Include conf/extra/httpd-vhosts.conf

To

Virtual hosts

Include conf/extra/httpd-vhosts.conf

Step 2:

Create a virtualhost file. Open “httpd-vhosts.conf” file. And copy the below lines of code.

<VirtualHost *:80>
  ServerAdmin webmaster@localhost.com
  DocumentRoot <PATH_TO_PROJECT_DIRECTORY_HERE>
  ServerName <SERVER_NAME like local.pos.com>
</VirtualHost>

Replace PATH_TO_PROJECT_DIRECTORY_HERE & SERVER_NAME with appropriate values, Save the file.

Step3:

Open C:\Windows\System32\drivers\etc\hosts

Add the below line at the end of file.

127.0.0.1      <SERVER_NAME like local.pos.com>

Restart apache server and visit the site URL.

That’s all is needed to set up a virtual host.

mukesh kumar
  • 580
  • 3
  • 14
  • Done that already as mentioned in my question, but as soon as I complete this process, the apache doesn't starts at all.. and the moment i remove the virtual host from httpd-vhosts, it starts working again. – Nasir Zia Aug 22 '19 at 07:25
  • Did you try this https://stackoverflow.com/questions/18300377/xampp-apache-error-apache-shutdown-unexpectedly – mukesh kumar Aug 22 '19 at 07:39
0

Try adding the Directory tag in your VirtualHost

<VirtualHost *:80>
    ServerAdmin webmaster@localhost.com
    DocumentRoot "C:/xampp/htdocs/basicwebsite/public"
    ServerName basicwebsite.dev
    <Directory "C:/xampp/htdocs/basicwebsite/public">
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>
Tojhan
  • 21
  • 5