Sign inSign up

dalexander2israel/php

By dalexander2israel

•Updated over 5 years ago

7.2-apache-mysqli

Image
0

223

dalexander2israel/php repository overview

⁠This image has been modified adding the pdo and mysqli modules for connecting to MySQL database. The easiest was to connect to the database, if you are running it from another container is to create a config.php or login.php file with the below information. This file can be referenced in your php pages:
    $DB_SERVER = ':';                          // The server address/name/location and port; this field is required 
$DB_USERNAME = ''; // The username of your database server if applicable, usually 'root'; leave blank ('') if none
$DB_PASSWORD = ''; // The password of your database server if applicable; leave blank ('') if none
$DB_DATABASE = ''; // The name of your database; this field is required
// The boolean value returned from the connection attempt
$conn = mysqli_connect($DB_SERVER, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE);
⁠The below compose field hosts two web servers and both connected to the same backend database. The persisted volumes were created separately using "--driver local-persist and labeled as external". See Below Sample compose file reference:
# This is a simple implementation of Oracle Database EE.
# The default password to connect to the database with "sys" user is "Oradoc_db1".
version: "3.7"  
services:  
################################# MYSQL ##################################
  mysql_5-7:
    image: dalexander2israel/mysql:5.7.27
    init: true
    container_name: mysql-db
    environment:
      # Name of the database
      MYSQL_DATABASE: 'WP_Database'
      # MySQL Host 
      MYSQL_HOST: 'mysql-db-1'
      # So you don't have to use root, but you can if you like
      MYSQL_USER: 'developer'
      # You can use whatever password you like
      MYSQL_PASSWORD: 'developer'
      # Password for root access
      MYSQL_ROOT_PASSWORD: 'developer'      
    volumes:
      - wp_db_data:/var/lib/mysql
      - wp_db_logs:/var/log
## using restart: on-failure policy but you may use any of the four policies ###########
    #restart: "no"
    #restart: always
    restart: on-failure
    #restart: unless-stopped    
######################################################################
    expose: 
    - "3306"
    ports:
      - 55651:3306
    networks: 
      - lamp-network  
################################## PHP ###################################   
  php:
    image: dalexander2israel/php:7.2-apache-mysqli
    #init: true
    container_name: php7.2-apache-mysqli
    environment:
      APACHE_RUN_DIR: /var/www/html
      APACHE_LOG_DIR: /var/log
      PATH: $PATH:/etc/apache2
      #PHP_INI_DIR: /usr/local/etc/php/conf.d      
    volumes:
      # Website directory volume
      - wp-www:/var/www/html
      - wp-www-logs:/var/log
      # Directory of apache2.conf configuration file
      #- lamp-apache2-conf:/etc/apache2
      # Directory for php.ini.development or php.ini.production config files
      #-  php-ini:/usr/local/etc/php/conf.d
## using restart: on-failure policy but you may use any of the four policies ###########
    #restart: "no"
    #restart: always
    restart: on-failure
    #restart: unless-stopped
######################################################################
    ports: 
      - 55642:80
    networks:
      - lamp-network         
    links: 
      - mysql_5-7
    depends_on: 
      - mysql_5-7           
################################ Nginx ###################################   
  nginx:
    image: nginx:1.17.5
    #init: true
    container_name: my-nginx
    environment:
      NGINX_PORT: '80'
    volumes:
      # Website directory volume
      - wp-docs:/usr/share/nginx/html
    working_dir: /usr/share/nginx/html
## using restart: on-failure policy but you may use any of the four policies ###########
    #restart: "no"
    #restart: always
    restart: on-failure  
    #restart: unless-stopped   
######################################################################
    ports: 
      - 55666:80
    networks:
      - lamp-network         
    links: 
      - mysql_5-7:database
    depends_on: 
      - mysql_5-7   
################################# volumes ################################
volumes:  
  wp-docs:
    external: true
  wp-docs-logs:
    external: true
  wp-www:
    external: true
  wp-www-logs:
    external: true
  lamp-apache2-conf:
    external: true
  wp_db_data:
    external: true
  wp_db_logs:
    external: true
  php-ini:
    external: true
################################ NETWORK #################################  
networks:
  lamp-network: 

Tag summary

Content type

Image

Digest

Size

133.3 MB

Last updated

over 5 years ago

docker pull dalexander2israel/php:8.0.3-apache-buster-arm64v8