Giter VIP home page Giter VIP logo

docker-lamp's Introduction

Docker LAMP

Linux + Apache + MariaDB (MySQL) + PHP 7.2 on Docker Compose. Mod_rewrite enabled by default.

Instructions

Enter the following command to start your containers:

$ docker-compose up -d

To stop them, use this:

$ docker-compose stop

Feel free to make pull requests and help to improve this.

If you are looking for phpMyAdmin, take a look at this.

docker-lamp's People

Contributors

celsocelante avatar keirodev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

docker-lamp's Issues

Unable to access phpmyadmin container's 'localhost' mysqli_connect(): (HY000/2002): Cannot assign requested address

After quite a lot of hours of wondering how to go about using LAMP stack on Docker. I finally decided to use your docker-compose. I've also added the phpmyadmin as per another issue here. I've changed some ports to not run into errors.

My docker-compose looks like this -

web:
   image: php:7.2-apache
   environment:
     - ALLOW_OVERRIDE=true
   ports:
     - "80:80"
   links:
     - db
   volumes:
     - ./app:/var/www/html/

db:
  image: mariadb
  restart: always
  volumes:
    - ./mysql:/var/lib/mysql
  environment:
    MYSQL_ROOT_PASSWORD: root
    MYSQL_USER: admin
    MYSQL_PASSWORD: test
    MYSQL_DATABASE: database
  ports:
    - "3306:3306"

phpmyadmin:
  image: phpmyadmin/phpmyadmin:latest
  links:
    - db
  ports:
    - 8888:80
  environment:
    MYSQL_USER: admin
    MYSQL_PASSWORD: test
    MYSQL_DATABASE: database

The problem I'm facing is this -

Warning: mysqli_connect(): (HY000/2002): Cannot assign requested address in /var/www/html/config.php on line 7

I tried using the container's IP Address using inspect, that didn't work either. I hope you can shed some light on what I might be doing wrong here.

the config.php file looks like this -

<?php
    $host='localhost:8888';
    $username="admin";
    $password="";
    $database="database";
    $conn=mysqli_connect($host,$username,$password,$database);
?>

PS: I have changed(removed) the password from inside phpmyadmin

could not find PDO driver

I'm getting this error while using PDO
Fatal error: Uncaught PDOException: could not find driver in /var/www/html/

Setup php.ini file

Hi! Sorry my bad english. I'm a newbie to PHP and Docker. How can i setup my php.ini file? I don't know where is and how to modify it.

How to test that PHP can pull data from the database with PDO?

I've tried creating a Dockerfile for PHP that looks like this:

FROM php:7.2-apache
RUN docker-php-ext-install pdo_mysql

...and then adjusting the docker-compose.yml accordingly:

web:
   build: .

But still I get 'connection refused'

Index file looks like:

try{
    $db = new pdo('mysql:host=db:8889;dbname=database', 'root', 'root');
}catch(Exception $e){
    echo $e -> getmessage();
}

tried both admin and root credentials specified in yml file. I've also tried 127.0.0.1 in place of db.

.htaccess and Rewrite

Hi,
I need to use RewriteEngine, but I can not goal. I am pretty new in Docker, so sorry if it is stupid question.

I have docker-compose.yml only a bit edited:

version: '3.8'
services:
  web:
    container_name: c-web
    image: php:7.4-apache
    environment:
      - ALLOW_OVERRIDE=true
    ports:
      - "80:80"
    links:
      - db
    working_dir: /application
    volumes:
      - .:/application
      - ./www:/var/www/html/

  phpmyadmin:
    container_name: c-phpmyadmin
    image: phpmyadmin/phpmyadmin:latest
    links:
      - db
    ports:
      - 8081:80
    environment:
      MYSQL_USER: HOUser
      MYSQL_PASSWORD: HOSokol12.
      MYSQL_DATABASE: HO-Sokol

  db:
    container_name: c-mariadb
    image: mariadb
    restart: always
    working_dir: /application
    volumes:
      - .:/application
      - ./mysql:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: toor
      MYSQL_USER: HOUser
      MYSQL_PASSWORD: HOSokol12.
      MYSQL_DATABASE: HO-Sokol
    ports:
      - "3306:3306"

and I need to use this .htaccess in www (html root) directory

Require all granted

RewriteEngine On

# redirects hello/world to hello/world.html (if hello/world does not exists)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

But when Rewrite* is present in .htaccess, an error appears ๐Ÿ˜•
image

please, can you help me @celsocelante, @Keirodev or someone else?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.