Skip to content

whilesmart/magento-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magento Docker Development Setup

Usage Instructions

Follow these instructions to set up Magento 2 in a Docker development environment using Apache and PHP 8.1.

  1. Clone the Repository:

    git clone git@github.com:whilesmart/magento-docker.git
    cd magento-docker
    mkdir code # Required for Magento2 code files
  2. Place your Magento 2 project in the code directory:

    • Copy or clone your Magento 2 project into the code directory. The code directory will serve as the root of your Magento 2 installation.
    • You can use git tracking in the code directory for your actual Magento project if you like, since a .gitignore file is included with the line code/ in it.
  3. Create info.php for testing:

    • Create an info.php file in the code/pub directory with the following content:

      <?php phpinfo(); ?>
    • Access this file in your browser at http://localhost:8000/info.php to verify your PHP settings and configuration.

  4. Build and start the Docker containers:

    docker compose up --build
  5. Build and start the Docker containers:

    docker compose up exec web composer install
  6. Set correct permissions:

    docker compose exec web find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
    docker compose exec web find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
    docker compose exec web chown -R :www-data . # Ubuntu
    docker compose exec web chmod u+x bin/magento
    
  7. Run Magento setup:

    After the containers are up and running, execute the Magento setup within the web container:

    docker compose exec web bin/magento setup:install \
    --base-url=http://localhost:8000 \
    --db-host=db \
    --db-name=magento \
    --db-user=magento \
    --db-password=magento \
    --admin-firstname=admin \
    --admin-lastname=admin \
    --admin-email=admin@admin.com \
    --admin-user=admin \
    --admin-password=admin123 \
    --language=en_US \
    --currency=USD \
    --timezone=America/Chicago \
    --use-rewrites=1 \
    --search-engine=elasticsearch7 \
    --elasticsearch-host=elasticsearch \
    --elasticsearch-port=9200
  8. Access Magento:

Project Structure

Your project directory should have the following structure:

project-root/
├── Dockerfile
├── docker-compose.yml
├── 000-default.conf
├── .gitignore
└── code/
    └── pub/
        └── info.php

Advanced Configuration

Docker Setup Details

The provided Docker setup includes:

  • Apache: Configured with mod_php to serve PHP files.
  • PHP 8.1: Installed with necessary extensions for running Magento 2.
  • MySQL (MariaDB): As the database server.
  • Elasticsearch: For the Magento search engine.

Directory Structure

project-root/
├── Dockerfile
├── docker-compose.yml
├── 000-default.conf
├── .gitignore
└── code/
    ├── app/
    ├── bin/
    ├── lib/
    ├── pub/
    │   └── info.php
    ├── var/
    └── vendor/

Credits

This setup utilizes the install-php-extensions tool from mlocati/docker-php-extension-installer.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published