/docker_lamp

LAMP Docker (with some small tools that help development)

Primary LanguageDockerfileMIT LicenseMIT

LAMP Stack in Docker

PHP5 + PHP7 + Apache2 + MariaDB in Docker

This docker setup has been tested with Magento 2, Wordpress and Symfony 2 -> Symfony 4

How to set up:

  1. Install docker and docker-compose properly
  2. Clone project and cd into the that
  3. Create .env file
echo "UID=$UID" > .env
  1. Create and run container:
docker-compose up -d

PHP web application:

  • Write your code at public_html directory
  • Browse to URL: localhost/info.php to check if it's running properly
  • Your MariaDB database credentials: root:1@10.5.0.100:3306 or root:1@maziadb:3306

Default VirtualHost

  • Default PHP version(s): PHP 7.3
  • Assume your index.php is located at ./public_html/projectname/public/index.php, please browse to:
    • http://public.project.php73 to run your application with PHP 7.3,
    • http://public.project.php74 (PHP 7.4)
  • Tip:
    • You can use dnsmasq instead of /etc/hosts, example:
# Redirect all sites in 4 domains (phpXX) to 127.0.0.1
address=/php71/php72/php73/php74/127.0.0.1

Custom VirtualHost

  • Add your VirtualHost config files to ./httpd/conf/vhosts/
  • Restart Apache container: docker restart httpd

Use PHP CLI:

  • Run command
docker exec -it php73 /bin/bash

or

docker exec -it php{xx} /bin/bash
  • Run you PHP application with command php ...
  • To debug PHP CLI application: replace php by xdebug
    • Example: php bin/console to xdebug bin/console

Enable/Disable PHP xdebug:

  • After docker exec... into container, run
toggle-php-mod xdebug

or shortcut

toggle-php-mod xd

Enable/Disable PHP Opcache:

  • After docker exec... into container, run
toggle-php-mod opcache

or shortcut

toggle-php-mod op