Docker nginx php mysql
Docker nginx php mysql
https://github.com/nanoninja/docker-nginx-php-mysql
Nginx PHP MySQL
Docker running Nginx, PHP-FPM, Composer, MySQL and PHPMyAdmin.
Overview
Before installing project make sure the following prerequisites have been met.
We’ll download the code from its repository on GitHub.
Configure Nginx With SSL Certificates [
Optional]We'll generate and configure SSL certificate for nginx before running server.
Configure Xdebug [
Optional]We'll configure Xdebug for IDE (PHPStorm or Netbeans).
By this point we’ll have all the project pieces in place.
Use Makefile [
Optional]When developing, you can use
Makefilefor doing recurrent operations.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:
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 :
Check Docker Compose compatibility :
The following is optional but makes life more enjoyable :
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.
Images to use
You should be careful when installing third party web servers such as MySQL or Nginx.
This project use the following ports :
MySQL
8989
PHPMyAdmin
8080
Nginx
8000
Nginx SSL
3000
Clone the project
To install Git, download it and install following the instructions :
Go to the project directory :
Project tree
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.
2. Configure Nginx
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.
2. Edit php file etc/php/php.ini and comment or uncomment the configuration as needed. 3.
Run the application
2. Start the application :
3.
4.
Use Makefile
When developing, you can use Makefile for doing the following operations :
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 :
Show help :
Use Docker commands
Installing package with composer
Updating PHP dependencies with composer
Generating PHP API documentation
Testing PHP application with PHPUnit
Fixing standard code with PSR2
Checking the standard code with PSR2
Analyzing source code with PHP Mess Detector
Checking installed PHP extensions
Handling database
MySQL shell access
and
Creating a backup of all databases
Restoring a backup of all databases
Creating a backup of single database
Notice: Replace "YOUR_DB_NAME" by your custom name.
Restoring a backup of single database
Connecting MySQL from PDO
Last updated