0

I am currently being tasked with setting up three separate web applications on the same Windows server. The web applications are all built with PHP/Laravel and use MySql for a database.

I typically approach such a task by manually setting up Apache, PHP and MySql on the server and running the PHP web apps each with their own vhost on Apache. The issue I have with this approach is that if there's some maintenance required for one of the web applications that result in the need to shut down a service like Apache or MySql then the other webs suffer from the downtime too.

So, I would like to explore other options where I can run many web applications and their dependent services as independent processes. As far as I am aware I should be able to do something like this using Docker (or some other virtualisation solution), but I am unsure if it's overkill or if there are any other solutions I can explore.

So to summarise...

  • How can I independently run several web applications on the same server?
  • Is docker the right approach (pls give examples) or is it overkill?
  • Are there alternatives I should consider?
  • Anything else (potential issues, solutions) I should consider?
haakym
  • 12,050
  • 12
  • 70
  • 98

1 Answers1

1

I used docker for years and it's very easy to deploy several applications in the same server. Each application runs independently, can have different configurations even different OS.

The approach is :

  • 1 (or 3) mysql servers (image: mysql)

  • 3 php servers (image: php)

  • 1 nginx for redirect the request, as a proxy (image: jwilder/nginx-proxy)

This can be an example for services in docker-compose (repeat services for mysql and application as required):

services:
  nginx:
    image: jwilder/nginx-proxy
    restart: on-failure:3
    hostname: nginx
    volumes:
        - /var/run/docker.sock:/tmp/docker.sock:ro
        - /opt/docker/nginx/vhost.d:/etc/nginx/vhost.d:ro
        - /opt/docker/nginx/certs:/etc/nginx/certs
        - /opt/docker/nginx/htpasswd:/etc/nginx/htpasswd
        - ./html:/usr/share/nginx/html:rw
    environment:
        - "DEFAULT_HOST=www.example.com"
        - "ENABLE_IPV6=true"
    ports:
        - "80:80"
        - "443:443"
    cpuset: "0"
    mem_limit: 256M

    mysql:
      image: mysql:5.7
      volumes:
       - ./mysql/data:/var/lib/mysql
      environment:
       - MYSQL_ROOT_PASSWORD=password

    aplication:
      image: php:7
      links:
       - mysql
      volumes:
       - ./www/:/var/www/html
      environment:
       - "VIRTUAL_HOST=application.example.com"

Please refer to the description of each image for more information.

About the overhead, read:

What is the runtime performance cost of a Docker container

In my opinion is the BEST way to accomplish your objective.

Alfonso Tienda
  • 3,442
  • 1
  • 19
  • 34