<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: jay-mj</title>
    <description>The latest articles on DEV Community by jay-mj (@johnmajarov).</description>
    <link>https://dev.to/johnmajarov</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F398413%2F4ab2aa3b-0658-4877-97ba-b217f62455cc.jpg</url>
      <title>DEV Community: jay-mj</title>
      <link>https://dev.to/johnmajarov</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/johnmajarov"/>
    <language>en</language>
    <item>
      <title>Docker LAMP Stack</title>
      <dc:creator>jay-mj</dc:creator>
      <pubDate>Sat, 27 Mar 2021 17:56:41 +0000</pubDate>
      <link>https://dev.to/johnmajarov/docker-lamp-stack-2g5i</link>
      <guid>https://dev.to/johnmajarov/docker-lamp-stack-2g5i</guid>
      <description>&lt;p&gt;&lt;strong&gt;Good day!&lt;/strong&gt; &lt;br&gt;
This is my first post on the &lt;strong&gt;DEV blog&lt;/strong&gt;, I'm so glad I joined this amazing resource! &lt;/p&gt;

&lt;p&gt;There are many things in development that may be of interest to specialists of different categories, but I decided to talk about cases from my practice of creating a web environment. &lt;br&gt;
&lt;em&gt;I apologize for some confusion in the text of this article, in view of the correction of the turns of the native speech through machine translation.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There was a time when I used &lt;strong&gt;XAMPP&lt;/strong&gt; on a classic operating system. Then &lt;strong&gt;Windows 10&lt;/strong&gt; came out and &lt;em&gt;small-soft corporation&lt;/em&gt; began to aggressively impose it even on lowest-level calculators. Software hangs and telemetry collection on an astronomical scale were concreted into the foundation of nature and all desire to seek further compromises in this madness disappeared. So I liked &lt;strong&gt;Linux&lt;/strong&gt; as an endless expanse for learning the intricacies and nuances of system administration and data processing. A pleasant asset for me was the fact that the &lt;strong&gt;Docker&lt;/strong&gt;, which became the basis for dynamic virtualization, was developed from a Linux-like OS. Based on this, I decided to combine the routine of daily work with continuous learning in the basics of data development and administration. &lt;/p&gt;

&lt;p&gt;Since changing the working environment, in a dense stream of routine tasks, was an unaffordable luxury for me, I decided to combine access to a single database from &lt;strong&gt;XAMPP&lt;/strong&gt; and &lt;strong&gt;Docker&lt;/strong&gt; at the same time. To be able to switch, if necessary, disks from &lt;strong&gt;Windows&lt;/strong&gt; and &lt;strong&gt;Linux&lt;/strong&gt;, keeping the program settings in a single way. &lt;/p&gt;


&lt;h6&gt;
  
  
  DISCLAIMER: This article is an example of my experience, I do not urge you to repeat this in practice, maybe the steps described in this article will help someone to understand in more detail the nuances of setting up the required environment
&lt;/h6&gt;

&lt;blockquote&gt;
&lt;h6&gt;
  
  
  * READ THE ARTICLE FIRST
&lt;/h6&gt;
&lt;h6&gt;
  
  
  * THEN TRY IF YOU WANT BY YOURSELF
&lt;/h6&gt;
&lt;h6&gt;
  
  
  * DON'T FORGET TO MAKE BACKUPS!
&lt;/h6&gt;
&lt;h6&gt;
  
  
  Thank you all for your attention)
&lt;/h6&gt;
&lt;/blockquote&gt;


&lt;h3&gt;
  
  
  On the &lt;strong&gt;Windows&lt;/strong&gt; side (&lt;em&gt;ntfs HDD&lt;/em&gt;) the &lt;strong&gt;XAMPP&lt;/strong&gt; tool is used.
&lt;/h3&gt;

&lt;p&gt;Let's explore some defaults...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MYSQL default DB location is:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\xampp\mysql\data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;em&gt;You can find your actual DB folder by following command (ex. at phpmyadmin):&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT @@datadir
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;or check &lt;strong&gt;datadir&lt;/strong&gt; parameter of my.ini file located in:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\xampp\mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;htdocs default folder location is:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\xampp\htdocs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This path is specified in &lt;strong&gt;DocumentRoot&lt;/strong&gt; line of the httpd.conf file&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To be able to use the &lt;strong&gt;XAMPP&lt;/strong&gt; MYSQL database and htdocs folders on both &lt;strong&gt;Windows&lt;/strong&gt; &amp;amp; &lt;strong&gt;Linux&lt;/strong&gt; systems, I moved them to the other drive prudently correcting the above &lt;strong&gt;datadir&lt;/strong&gt; &amp;amp; &lt;strong&gt;DocumentRoot&lt;/strong&gt; parameters
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;D:\DB\mysql\data
D:\Projects\htdocs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I rebooted Windows to make sure the new settings were accepted without error, phpmyadmin are logged in successfully, I have no password for development use...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkmd6zk4fz1ijv0k2vxjt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkmd6zk4fz1ijv0k2vxjt.jpg" alt="Say Hello to Bill"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fugytekpcjhfib4ikwfpr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fugytekpcjhfib4ikwfpr.jpg" alt="Say Bye to Windows 10"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  On the &lt;strong&gt;Linux&lt;/strong&gt; side (&lt;em&gt;ext4 HDD&lt;/em&gt;) the &lt;strong&gt;Docker&lt;/strong&gt; tool is used.
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;At first we need to install ntfs drives support and one handy utility "blkid" - if it not present in the system for some reasons:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt update &amp;amp;&amp;amp; sudo apt install -y util-linux ntfs-3g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;em&gt;Just keep in mind that Linux is widely open to solving many tasks in many different ways, so the commands used in my case are for my specific case, and you can use more preferable alternative ways to do the same&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a mount point for our shared ntfs hard drive:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo mkdir /media/paste-your-username-here/point-folder 
$ cd /media/paste-your-username-here/ 
$ sudo chown paste-your-username-here point-folder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;Replace &lt;strong&gt;paste-your-username-here&lt;/strong&gt; with your actual user name&lt;br&gt;
The first command creates a directory for the shared drive&lt;br&gt;
Then we go to the current user's disk mount directory&lt;br&gt;
and set the owner for this folder as the current user&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Now we need to discover UUID of our shared ntfs hard drive, to set its auto mounting options:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo blkid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;em&gt;You should see something like this:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/dev/sdb1: BLOCK_SIZE="512" UUID="BCBF273CHE84F05E" TYPE="ntfs" PARTUUID="8b2f7e1d-01"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;so the string between &lt;strong&gt;UUID&lt;/strong&gt; and &lt;strong&gt;TYPE&lt;/strong&gt; words is our needed combination...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Once UUID is found we need to write mounting rule for this drive, mount options are specified in the file called &lt;strong&gt;fstab&lt;/strong&gt; it is located in etc directory...
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo vim /etc/fstab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will see a current attached drives table. You need to go to the end of file and add one string such following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UUID=BCBF273CHE84F05E   /media/username/point-folder   ntfs-3g         auto,defaults,permissions,uid=1000,gid=1000,umask=000,nofail,errors=continue,exec 0 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;IMPORTANT:&lt;/strong&gt; read &amp;amp; modify this file very carefully, don't forget to make backups&lt;/li&gt;
&lt;li&gt;replace &lt;strong&gt;UUID&lt;/strong&gt; value with yours obtained with &lt;strong&gt;blkid&lt;/strong&gt; command&lt;/li&gt;
&lt;li&gt;replace &lt;strong&gt;username&lt;/strong&gt; to yours&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;uid&lt;/strong&gt; &amp;amp; &lt;strong&gt;gid&lt;/strong&gt; tags are setting access to the shared drive&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;nofail&lt;/strong&gt;, &lt;strong&gt;errors=continue&lt;/strong&gt; will skip any mount errors on system boot in case of missing drive or other cases&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;exec&lt;/strong&gt; tag allows to perform scripts execution on the shared drive&lt;/li&gt;
&lt;li&gt;you can also set &lt;strong&gt;umask&lt;/strong&gt; tag with &lt;strong&gt;022&lt;/strong&gt; value - it will reset user rights of all drive contents to unix &lt;strong&gt;0755&lt;/strong&gt; (&lt;em&gt;rwx-rx-rx&lt;/em&gt;) format, but in this case I prefer to make it simpler, as &lt;strong&gt;000&lt;/strong&gt; value which corresponds to &lt;strong&gt;0777&lt;/strong&gt; (&lt;em&gt;rwx&lt;/em&gt;) full access format&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Refresh mounted drives can be done with following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo mount -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;But I prefer to reboot the system and see how it starts at all, &lt;em&gt;it is very exciting step because inaccurate &lt;strong&gt;fstab&lt;/strong&gt; modifying can bring you blank screen on boot ^&lt;/em&gt;__&lt;em&gt;^&lt;/em&gt; &lt;br&gt;
At last, once system is started... &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.meme-arsenal.com%2Fmemes%2Ff55b986a2181613c4547268ec7e55fa9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.meme-arsenal.com%2Fmemes%2Ff55b986a2181613c4547268ec7e55fa9.jpg" alt="cat being trapped"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  We begin to create our docker project
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;assume that you're already set up the &lt;strong&gt;Docker&lt;/strong&gt; &amp;amp; &lt;strong&gt;docker-compose&lt;/strong&gt; utilities. Otherwise, the description of this step will take too long and distract attention from the original topic of the article&lt;/em&gt;&lt;br&gt;
Let's check installed components by command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker -v &amp;amp;&amp;amp; docker-compose -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my case the stdout looks like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Docker version 20.10.4+dfsg1, build d3cb89e
docker-compose version 1.25.0, build unknown
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;As we mentioned before, our shared drive contains following folders:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -lah /media/username/point-folder 
drwxrwxrwx  1 username username 4.0K Sep  7  2020 'DB'
drwxrwxrwx  1 username username 4.0K Sep  7  2020 'Projects'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;We will attach them into our docker containers, so the &lt;strong&gt;Docker LAMP Stack&lt;/strong&gt; will use real &lt;strong&gt;XAMPP&lt;/strong&gt; folders&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Create &amp;amp; Get in to our project folder:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd /media/username/point-folder/Projects
$ mkdir lamp &amp;amp;&amp;amp; cd $_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;as the base of my &lt;strong&gt;Docker LAMP Stack&lt;/strong&gt; image I've use such an awesome github project:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone https://github.com/sprintcube/docker-compose-lamp .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;h5&gt;
  
  
  I've made some changes on it
&lt;/h5&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Let's take a first look on the lamp stack project structure:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls /media/username/point-folder/Projects/lamp
bin  config  data  docker-compose.yml  logs  sample.env  www
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;bin&lt;/strong&gt; folder contains &lt;em&gt;Dockerfiles&lt;/em&gt; which would be used to build our services:
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./bin/mysql/Dockerfile:
FROM mariadb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./bin/webserver/Dockerfile:
FROM php:7.3-apache

RUN apt-get -y update --fix-missing
RUN apt-get -y upgrade

RUN apt-get install -y apt-utils nano wget dialog

RUN apt-get install -y --fix-missing apt-utils build-essential git curl libcurl4 libcurl4-nss-dev zip libzip-dev

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

RUN apt-get install -y libmcrypt-dev
#RUN docker-php-ext-install mcrypt
RUN pecl install mcrypt &amp;amp;&amp;amp; docker-php-ext-enable mcrypt

RUN apt-get install -y libsqlite3-dev libsqlite3-0 default-mysql-client
RUN docker-php-ext-install pdo_mysql 
RUN docker-php-ext-install pdo_sqlite
RUN docker-php-ext-install mysqli

RUN docker-php-ext-install curl
RUN docker-php-ext-install tokenizer
RUN docker-php-ext-install json

RUN apt-get install -y zlib1g-dev
RUN docker-php-ext-install zip

RUN apt-get install -y libicu-dev
RUN docker-php-ext-install -j$(nproc) intl

RUN docker-php-ext-install mbstring

RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 
RUN docker-php-ext-install -j$(nproc) gd

RUN a2enmod rewrite headers

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;config&lt;/strong&gt; folder contains &lt;em&gt;specific user configurations&lt;/em&gt; which represents Windows serices values from XAMPP (for instance)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;logs&lt;/strong&gt; folder for error &amp;amp; server-access reports&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;data&lt;/strong&gt; folder are linked to the &lt;em&gt;XAMPP MYSQL database&lt;/em&gt; in our case it corresponds to:
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/media/username/point-folder/DB/mysql/data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;www&lt;/strong&gt; corresponds to &lt;em&gt;XAMPP htdocs folder&lt;/em&gt;:
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/media/username/point-folder/Projects/htdocs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;sample.env&lt;/strong&gt; is a template where defined some very necessary system paths&lt;/li&gt;
&lt;li&gt;and the main guest of the project... &lt;strong&gt;docker-compose.yml&lt;/strong&gt; file, which contains all set of the instructions to assemble &lt;em&gt;LAMP Stack&lt;/em&gt; properly:
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: "3"

services:
  webserver:
    build: 
      context: ./bin/webserver
    container_name: 'lamp-webserver'
    restart: 'on-failure'
    ports:
      - "80:80"
      - "443:443"
    links: 
      - mysql
    volumes: 
      - ${DOCUMENT_ROOT-./www}:/var/www/html
      - ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini
      - ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled
      - ${LOG_DIR-./logs/apache2}:/var/log/apache2
  mysql:
    build: ./bin/mysql
    container_name: 'lamp-mysql'
    restart: 'on-failure'
    ports:
      - "3306:3306"
    volumes: 
      - ${MYSQL_DATA_DIR-./data/mysql}:/var/lib/mysql
      - ${MYSQL_LOG_DIR-./logs/mysql}:/var/log/mysql
      - ./config/mysql/my.cnf:/etc/mysql/my.cnf
      - /etc/localtime:/etc/localtime:ro
    environment:
      # MYSQL_ROOT_PASSWORD: ''
      MYSQL_DATABASE: &amp;lt;place-your-db-name-here&amp;gt;
      MYSQL_USER: root
      # MYSQL_PASSWORD: ''
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: 'lamp-phpmyadmin'
    links:
      - mysql
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
    ports:
      - '8080:80'
    volumes: 
      - /sessions
      - ./config/phpmyadmin/phpmyadmin-misc.ini:/usr/local/etc/php/conf.d/php-phpmyadmin.ini
  redis:
    container_name: 'lamp-redis'
    image: redis:latest
    ports:
      - "6379:6379"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Read this file carefully&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;notice how user-configuration &amp;amp; log files are attached to the stack containers&lt;/li&gt;
&lt;li&gt;MYSQL passwords are commented out, because I'm not using them on development&lt;/li&gt;
&lt;li&gt;VARIABLES of this file are defined in env file&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Assemble the LAMP Stack
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker-compose up --build -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the execution result on container status:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker ps -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My stdout is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5cf0a5b46b18   lamp_webserver            "docker-php-entrypoi…"   1 minute ago   Up 8 seconds   0.0.0.0:80-&amp;gt;80/tcp, 0.0.0.0:443-&amp;gt;443/tcp   lamp-webserver
538243f42ab2   phpmyadmin/phpmyadmin         "/docker-entrypoint.…"   1 minute ago   Up 6 seconds   0.0.0.0:8080-&amp;gt;80/tcp                       lamp-phpmyadmin
5fe638335f1a   377ad5bc26fe                  "docker-entrypoint.s…"   1 minute ago   Up 1 second    0.0.0.0:3306-&amp;gt;3306/tcp                     lamp-mysql
31e73c59abaf   redis:latest                  "docker-entrypoint.s…"   1 minute ago   Up 7 seconds   0.0.0.0:6379-&amp;gt;6379/tcp                     lamp-redis

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.gifer.com%2FM4ZJ.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.gifer.com%2FM4ZJ.gif" alt="Victory is My!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  If everything is fine you could go to the browser and type:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PHPMyAdmin&lt;/strong&gt; interface will appear, you can use root account to login, we're not provide any password in our file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost/site/index.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Apache&lt;/strong&gt; also ready to use on port 80, replace &lt;strong&gt;site&lt;/strong&gt; with name of your early created project, and happy to coding!&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.gifer.com%2F1tQe.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.gifer.com%2F1tQe.gif" alt="debugging"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  if something goes wrong you can:
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Inspect containers for its own settings:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   $ docker inspect 5fe6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;5fe6&lt;/strong&gt; in this case is the beginning of the hash of the mysql container&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;View logs of returned errors:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   $ docker logs 5fe6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Login into container to manually set necessary modifications:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   $ docker exec -it 5fe6 /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The &lt;em&gt;5fe6 container shell&lt;/em&gt; will appear, use &lt;strong&gt;exit&lt;/strong&gt; command to logout &lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;If you're making changes in the structure of any Dockerfiles or docker-compose.yml do not forget to delete previously created containers and in some cases unused images, to gain some free space:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   $ docker image prune -a
   $ docker container prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Be careful with this command&lt;/strong&gt; it will removes all unused images and stopped containers!&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;While I was practicing on this project, it was not as big as it looks now. I hope you guys will succeed in development and you will be able to gain the necessary experience and create great projects! Thanks to everyone who read this article to the end! Good luck!&lt;/p&gt;

</description>
      <category>docker</category>
      <category>lamp</category>
      <category>xampp</category>
      <category>mysql</category>
    </item>
  </channel>
</rss>
