Web server and PHP

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

What methods did we used to run web pages on our browser ?

  • Simply open a file on the browser
  • Github pages
  • Built-in web server in PHP
    php -S localhost:8080
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Live server

Launch a local development server with live reload feature for static & dynamic pages.

Live server

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

What is a web server ?

A web server is a computer that have:

  • a software that can answer to HTTP requests (HTTP server) and ;
  • files to be displayed.
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Problems with the built-in web server ?

  • Only for development
  • Too much logs
  • No security
  • Bad efficiency
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

What are the alternative ?

  • Apache
    • LAMP (Linux, Apache, MySQL, PHP)
    • XAMP (MySQL+PHP+PHPMyAdmin)
  • Nginx
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Is it easy to use ?

You can install XAMPP! on your computer, but if you work with a team or lose your computer you have to install all of it.

What can be the solution ?

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

La containerisation c'est bien.

Vincent Guidoux, everyday.

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Xampp container

docker run --name myXampp -p 41061:22 -p 41062:80 -d -v /www:/www tomsik68/xampp:8
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Xampp container

services:
  myXampp:
    image: tomsik68/xampp:8
    container_name: myXampp
    ports:
      - 41061:22
      - 41062:80
    volumes:
      - ./www:/www
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

What should I remember?

  • What is a web server
  • Why I should not use the built-in web server in PHP
HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Can I still use the built-in web server in PHP ?

Yes, but only for development.

And yes, you can use it for the practical work 2, just be sure to document it in the README.md.

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

Sources

HEIG-VD - WEB Course 2023-2024 - AGPL-3.0 license

This is a way to make link and shortcut in the code

This comment will center everything on the page

## This is some code ```bash php -S localhost:8080 ``` ## This is a quote > This is a quote ## This is an image to the right ![bg right][illustration] ## This is an image to the left ![bg left][illustration] ## This is a full image on the right ![bg right contain][illustration] ## This is an image on the right, but only 30% ![bg right:30%][illustration]