Docker nginx php mysql
Docker nginx php mysql
https://github.com/nanoninja/docker-nginx-php-mysql
Docker running Nginx, PHP-FPM, Composer, MySQL and PHPMyAdmin.
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
Makefile
for doing recurrent operations.When running, you can use docker commands for doing recurrent operations.
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.
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 |
To install Git, download it and install following the instructions :
Go to the project directory :
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
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.
2. Start the application :
3.
4.
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 |
Start the application :
Show help :
and
Notice:
Replace "YOUR_DB_NAME" by your custom name.
Last updated