DEV Community

vkuberan@gmail.com
vkuberan@gmail.com

Posted on • Updated on

Docker Ubuntu LAMP Setup on Windows

MY LAMP SETUP

  1. Pull Ubuntu

     docker pull ubuntu:latest
    
  2. Pull Mariadb

     docker pull mariadb:latest
    
  3. Create the shared network

     docker network create --driver=bridge lampstack
    
  4. Create MariaDB Container

     docker run -itd -p 33063:3306 --name=lampmysql \
     --network=lampstack \
     --env MARIADB_USER=root \
     --env MARIADB_PASSWORD=google \
     --env MARIADB_ROOT_PASSWORD=google \
     mariadb:latest
    
  5. Create Ubuntu Container

    Replace "./htdocs" with your working directory path.

    docker run -itd -p 8080:80 \
    --user root \
    --name=lampstack \
    --network=lampstack \
    -v ./htdocs:/var/www/html/ \
    ubuntu:22.04 /bin/bash
    
  6. Get in to the Ubuntu Container

    docker attach lampstack
    
  7. Install all necessary Apache/PHP packages

    Refer 1: Ubuntu - Install LAMP Stack

    Execute the following commands one by one.

    Update Ubuntu

    apt-get update
    apt-get upgrade
    

    Install necessary tools along with apache

    apt-get install iputils-ping \
    vim \
    systemctl \
    apache2 \ 
    apache2-utils \
    

    Enable apache server

    systemctl enable apache2
    systemctl start apache2 
    systemctl status apache2
    

    Install mariadb client and PHP

    apt-get install mariadb-client \
    php \
    libapache2-mod-php \
    php-mysql \
    php-curl \
    php-gd \
    php-mbstring \
    php-xml \
    php-soap \
    php-intl \
    php-zip
    

    Enable rewrite and Restart apache server

    a2enmod rewrite
    systemctl restart apache2
    
  8. Rewrite Mode

    If you want seo like links, You need to do some additional work

    Refer 1: Ubuntu - Enable Mod Rewrite

    Refer 2: Ubuntu - Enable Mod Rewrite

    cd /etc/apache2/sites-available/
    vi default.conf or vi 000-default.conf
    

    Add following section to the one of the above mentioned file after CustomLog.

    <Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride all
        Require all granted
    </Directory>
    

    Enable mod rewrite and restart apache

    a2enmod rewrite 
    systemctl apache2 restart
    

Additional configuration

  1. Install phpMyAdmin

    docker pull phpmyadmin/phpmyadmin
    
  2. Create container for phpMyAdmin

    docker run -itd -p 2599:80 --name=lampphpmyadmin \
    -e PMA_ARBITRARY=1 \
    --network=lampstack \
    phpmyadmin/phpmyadmin
    

Top comments (2)

Collapse
 
jeromesch profile image
jeromesch

you should try to put all that stuff in a dockercomposefile :)
makes it easier and you only have to write it once!

Collapse
 
vkuberan_88 profile image
vkuberan@gmail.com

Thanks for your reply. This is just for manual setup.

Here is my docker-compose setup
dev.to/vkuberan_88/docker-compose-...