Skip to content

Instantly share code, notes, and snippets.

@ajbm6
Created August 10, 2017 11:55
Show Gist options
  • Save ajbm6/94230b635af5ca7888b7a8903845e459 to your computer and use it in GitHub Desktop.
Save ajbm6/94230b635af5ca7888b7a8903845e459 to your computer and use it in GitHub Desktop.
Running multiple Slim Framework PHP sites with XAMPP

Running multiple Slim Framework sites with XAMPP

You can then run a slim framework app it with PHP's built-in webserver:

$ cd [my-app-name]; php -S localhost:8080 -t public public/index.php

The problem is that you have to enter this command every day again and again. If you are running more then one app you have to use the next free port.

I want to configure my XAMPP to have 2 (or more) different localhosts and sites with 2 different root directories.

Let's name them: site1 and site2.

  • The DocumentRoot of site1 is: C:/xampp/htdocs/site1/public
  • The DocumentRoot of site2 is: C:/xampp/htdocs/site2/public

I solved the problem by defining a unique port for every site.

Setup

  • Open with Notepad++: C:\xampp\apache\conf\httpd.conf
  • Add this lines under Listen 80
Listen 8090
Listen 8091
  • Open with Notepad++: C:\xampp\apache\conf\extra\httpd-vhosts.conf

  • Append this new section

<VirtualHost *:8090>
    ServerAdmin webmaster@site.example.com
    DocumentRoot "/xampp/htdocs/site1/public"
    ServerName site1.example.com
    ErrorLog "logs/site1-error.log"
    CustomLog "logs/site1-access.log" common
</VirtualHost>

<VirtualHost *:8091>
    ServerAdmin webmaster@site2.example.com
    DocumentRoot "/xampp/htdocs/site2/public"
    ServerName site2.example.com
    ErrorLog "logs/site2-error.log"
    CustomLog "logs/site2-access.log" common
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment