All Projects โ†’ nanoninja โ†’ Docker Nginx Php Mysql

nanoninja / Docker Nginx Php Mysql

Docker running Nginx, PHP-FPM, MySQL & PHPMyAdmin

Projects that are alternatives of or similar to Docker Nginx Php Mysql

Docker Laravel
๐Ÿณ Build a simple laravel development environment with docker-compose.
Stars: โœญ 415 (-68.61%)
Mutual labels:  makefile, mysql, composer, docker-compose, nginx
Devilbox
A modern Docker LAMP stack and MEAN stack for local development
Stars: โœญ 3,598 (+172.16%)
Mutual labels:  mysql, lemp, docker-compose, nginx
Oneinstack
OneinStack - A PHP/JAVA Deployment Tool
Stars: โœญ 1,983 (+50%)
Mutual labels:  phpmyadmin, mysql, lemp, nginx
Kickoff Docker Php
๐Ÿณ ๐Ÿ˜ ๐Ÿš€ Easily setup a PHP project with Docker
Stars: โœญ 213 (-83.89%)
Mutual labels:  phpmyadmin, mysql, docker-compose, nginx
Webinoly
Optimized LEMP Web Server to manage your WordPress, PHP, or simple HTML sites running on a powerful NGINX setup.
Stars: โœญ 254 (-80.79%)
Mutual labels:  mysql, lemp, nginx
Docker Lnmp
๐Ÿ‹Docker-compose(Linux,Nginx,MySQL,PHP7,Redis)
Stars: โœญ 244 (-81.54%)
Mutual labels:  mysql, docker-compose, nginx
Slickstack
SlickStack is a free LEMP stack automation script written in Bash designed to enhance and simplify WordPress provisioning, performance, and security.
Stars: โœญ 311 (-76.48%)
Mutual labels:  mysql, lemp, nginx
Stacker
Stacker - The environment for local web development, ready for use.
Stars: โœญ 356 (-73.07%)
Mutual labels:  mysql, docker-compose, nginx
Docker Laravel
Laravel 5 with Dockerized Gulp, PHP-FPM, MySQL and nginx using docker-compose
Stars: โœญ 85 (-93.57%)
Mutual labels:  mysql, composer, nginx
Docker Lemp
๐Ÿณ Docker ๅฟซ้€Ÿๆญๅปบ LEMP ๅผ€ๅ‘็Žฏๅขƒ
Stars: โœญ 87 (-93.42%)
Mutual labels:  mysql, lemp, nginx
Docker Skeleton Php
A simple Docker PHP development environment
Stars: โœญ 40 (-96.97%)
Mutual labels:  mysql, composer, nginx
Wordpress Nginx Docker Compose
Run WordPress with nginx using Docker Compose.
Stars: โœญ 460 (-65.2%)
Mutual labels:  phpmyadmin, docker-compose, nginx
Docker Compose Lamp
A basic LAMP stack environment built using Docker Compose.
Stars: โœญ 1,284 (-2.87%)
Mutual labels:  phpmyadmin, mysql, docker-compose
Docker Lamp
Docker with Apache, MySql, PhpMyAdmin and Php
Stars: โœญ 276 (-79.12%)
Mutual labels:  phpmyadmin, mysql, docker-compose
Lnmp
LEMP stack/LAMP stack/LNMP stack installation scripts for CentOS/Redhat Debian and Ubuntu
Stars: โœญ 2,488 (+88.2%)
Mutual labels:  mysql, lemp, nginx
Lnmp
LNMPไธ€้”ฎๅฎ‰่ฃ…ๅŒ…ๆ˜ฏไธ€ไธช็”จLinux Shell็ผ–ๅ†™็š„ๅฏไปฅไธบCentOS/RHEL/Fedora/Aliyun/Amazonใ€Debian/Ubuntu/Raspbian/Deepin/Mint Linux VPSๆˆ–็‹ฌ็ซ‹ไธปๆœบๅฎ‰่ฃ…LNMP(Nginx/MySQL/PHP)ใ€LNMPA(Nginx/MySQL/PHP/Apache)ใ€LAMP(Apache/MySQL/PHP)็”Ÿไบง็Žฏๅขƒ็š„Shell็จ‹ๅบใ€‚
Stars: โœญ 2,119 (+60.29%)
Mutual labels:  mysql, lemp, nginx
Docker Laravel
๐Ÿณ Docker Images for Laravel development
Stars: โœญ 101 (-92.36%)
Mutual labels:  mysql, docker-compose, nginx
Symfony 4 Docker Env
Docker Environment for Symfony. PHP-FPM, NGINX SSL Proxy, MySQL, LEMP
Stars: โœญ 119 (-91%)
Mutual labels:  mysql, docker-compose, nginx
Docker Symfony
๐Ÿณ A docker multicontainer with NGINX, PHP7-FPM, MySQL and ELK (Elasticsearch Logstash and Kibana)
Stars: โœญ 1,305 (-1.29%)
Mutual labels:  mysql, docker-compose, nginx
Phalcon Vm
Vagrant configuration for PHP7, Phalcon 3.x and Zephir development.
Stars: โœญ 43 (-96.75%)
Mutual labels:  phpmyadmin, mysql, nginx

Nginx PHP MySQL Build Status GitHub version

Docker running Nginx, PHP-FPM, Composer, MySQL and PHPMyAdmin.

Overview

  1. Install prerequisites

    Before installing project make sure the following prerequisites have been met.

  2. Clone the project

    Weโ€™ll download the code from its repository on GitHub.

  3. Configure Nginx With SSL Certificates [Optional]

    We'll generate and configure SSL certificate for nginx before running server.

  4. Configure Xdebug [Optional]

    We'll configure Xdebug for IDE (PHPStorm or Netbeans).

  5. Run the application

    By this point weโ€™ll have all the project pieces in place.

  6. Use Makefile [Optional]

    When developing, you can use Makefile for doing recurrent operations.

  7. Use Docker Commands

    When running, you can use docker commands for doing recurrent operations.


Install prerequisites

To run the docker commands without using sudo you must add the docker group to your-user:

sudo usermod -aG docker your-user

For now, this project has been mainly created for Unix (Linux/MacOS). Perhaps it could work on Windows.

All requisites should be available for your distribution. The most important are :

Check if docker-compose is already installed by entering the following command :

which docker-compose

Check Docker Compose compatibility :

The following is optional but makes life more enjoyable :

which make

On Ubuntu and Debian these are available in the meta-package build-essential. On other distributions, you may need to install the GNU C++ compiler separately.

sudo apt install build-essential

Images to use

You should be careful when installing third party web servers such as MySQL or Nginx.

This project use the following ports :

Server Port
MySQL 8989
PHPMyAdmin 8080
Nginx 8000
Nginx SSL 3000

Clone the project

To install Git, download it and install following the instructions :

git clone https://github.com/nanoninja/docker-nginx-php-mysql.git

Go to the project directory :

cd docker-nginx-php-mysql

Project tree

.
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ data
โ”‚   โ””โ”€โ”€ db
โ”‚       โ”œโ”€โ”€ dumps
โ”‚       โ””โ”€โ”€ mysql
โ”œโ”€โ”€ doc
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ etc
โ”‚   โ”œโ”€โ”€ nginx
โ”‚   โ”‚   โ”œโ”€โ”€ default.conf
โ”‚   โ”‚   โ””โ”€โ”€ default.template.conf
โ”‚   โ”œโ”€โ”€ php
โ”‚   โ”‚   โ””โ”€โ”€ php.ini
โ”‚   โ””โ”€โ”€ ssl
โ””โ”€โ”€ web
    โ”œโ”€โ”€ app
    โ”‚   โ”œโ”€โ”€ composer.json.dist
    โ”‚   โ”œโ”€โ”€ phpunit.xml.dist
    โ”‚   โ”œโ”€โ”€ src
    โ”‚   โ”‚   โ””โ”€โ”€ Foo.php
    โ”‚   โ””โ”€โ”€ test
    โ”‚       โ”œโ”€โ”€ FooTest.php
    โ”‚       โ””โ”€โ”€ bootstrap.php
    โ””โ”€โ”€ public
        โ””โ”€โ”€ index.php

Configure Nginx With SSL Certificates

You can change the host name by editing the .env file.

If you modify the host name, do not forget to add it to the /etc/hosts file.

  1. Generate SSL certificates

    source .env && docker run --rm -v $(pwd)/etc/ssl:/certificates -e "SERVER=$NGINX_HOST" jacoelho/generate-certificate
    
  2. Configure Nginx

    Do not modify the etc/nginx/default.conf file, it is overwritten by etc/nginx/default.template.conf

    Edit nginx file etc/nginx/default.template.conf and uncomment the SSL server section :

    # server {
    #     server_name ${NGINX_HOST};
    #
    #     listen 443 ssl;
    #     fastcgi_param HTTPS on;
    #     ...
    # }
    

Configure Xdebug

If you use another IDE than PHPStorm or Netbeans, go to the remote debugging section of Xdebug documentation.

For a better integration of Docker to PHPStorm, use the documentation.

  1. Get your own local IP address :

    sudo ifconfig
    
  2. Edit php file etc/php/php.ini and comment or uncomment the configuration as needed.

  3. Set the remote_host parameter with your IP :

    xdebug.remote_host=192.168.0.1 # your IP
    

Run the application

  1. Copying the composer configuration file :

    cp web/app/composer.json.dist web/app/composer.json
    
  2. Start the application :

    docker-compose up -d
    

    Please wait this might take a several minutes...

    docker-compose logs -f # Follow log output
    
  3. Open your favorite browser :

  4. Stop and clear services

    docker-compose down -v
    

Use Makefile

When developing, you can use Makefile for doing the following operations :

Name Description
apidoc Generate documentation of API
clean Clean directories for reset
code-sniff Check the API with PHP Code Sniffer (PSR2)
composer-up Update PHP dependencies with composer
docker-start Create and start containers
docker-stop Stop and clear all services
gen-certs Generate SSL certificates for nginx
logs Follow log output
mysql-dump Create backup of all databases
mysql-restore Restore backup of all databases
phpmd Analyse the API with PHP Mess Detector
test Test application with phpunit

Examples

Start the application :

make docker-start

Show help :

make help

Use Docker commands

Installing package with composer

docker run --rm -v $(pwd)/web/app:/app composer require symfony/yaml

Updating PHP dependencies with composer

docker run --rm -v $(pwd)/web/app:/app composer update

Generating PHP API documentation

docker run --rm -v $(pwd):/data phpdoc/phpdoc -i=vendor/ -d /data/web/app/src -t /data/web/app/doc

Testing PHP application with PHPUnit

docker-compose exec -T php ./app/vendor/bin/phpunit --colors=always --configuration ./app

Fixing standard code with PSR2

docker-compose exec -T php ./app/vendor/bin/phpcbf -v --standard=PSR2 ./app/src

Checking the standard code with PSR2

docker-compose exec -T php ./app/vendor/bin/phpcs -v --standard=PSR2 ./app/src

Analyzing source code with PHP Mess Detector

docker-compose exec -T php ./app/vendor/bin/phpmd ./app/src text cleancode,codesize,controversial,design,naming,unusedcode

Checking installed PHP extensions

docker-compose exec php php -m

Handling database

MySQL shell access

docker exec -it mysql bash

and

mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD"

Creating a backup of all databases

mkdir -p data/db/dumps
source .env && docker exec $(docker-compose ps -q mysqldb) mysqldump --all-databases -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" > "data/db/dumps/db.sql"

Restoring a backup of all databases

source .env && docker exec -i $(docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < "data/db/dumps/db.sql"

Creating a backup of single database

Notice: Replace "YOUR_DB_NAME" by your custom name.

source .env && docker exec $(docker-compose ps -q mysqldb) mysqldump -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" --databases YOUR_DB_NAME > "data/db/dumps/YOUR_DB_NAME_dump.sql"

Restoring a backup of single database

source .env && docker exec -i $(docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < "data/db/dumps/YOUR_DB_NAME_dump.sql"

Connecting MySQL from PDO

<?php
    try {
        $dsn = 'mysql:host=mysql;dbname=test;charset=utf8;port=3306';
        $pdo = new PDO($dsn, 'dev', 'dev');
    } catch (PDOException $e) {
        echo $e->getMessage();
    }
?>

Help us

Any thought, feedback or (hopefully not!)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].