nanoninja / docker-nginx-php-mysql Goto Github PK
View Code? Open in Web Editor NEWDocker running Nginx, PHP-FPM, MySQL & PHPMyAdmin
Docker running Nginx, PHP-FPM, MySQL & PHPMyAdmin
Hi,
I really like this repository which is very complete but being used to using Apache, I would like to replace Nginx with Apache but I am afraid of doing wrong. How can I do it please? Which lines of which files should I change?
Thank you in advance
HI @nanoninja,
At first, I'm sorry that not good at English well.
I tried to install composer. But I faced with Error.
What can I do?
jerryui-MacBook-Pro:docker-nginx-php-mysql jerry$ sudo docker run --rm -v /Users/jerry/Dev/docker-nginx-php-mysql/web/app:/app composer require symfony/yaml
Password:
Using version ^4.0 for symfony/yaml
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: don't install symfony/yaml v4.0.1
- Conclusion: don't install symfony/yaml v4.0.0
- Conclusion: don't install symfony/yaml v4.0.0-RC2
- Conclusion: don't install symfony/yaml v4.0.0-RC1
- Conclusion: don't install symfony/yaml v4.0.0-BETA4
- Conclusion: don't install symfony/yaml v4.0.0-BETA3
- Conclusion: don't install symfony/yaml v4.0.0-BETA2
- Installation request for apigen/apigen dev-master -> satisfiable by apigen/apigen[dev-master].
- Conclusion: don't install symfony/yaml v4.0.0-BETA1
- Conclusion: don't install symfony/yaml 4.1.x-dev
- apigen/apigen dev-master requires symfony/yaml ^3.3 -> satisfiable by symfony/yaml[3.3.x-dev, 3.4.x-dev].
- Can only install one of: symfony/yaml[4.0.x-dev, 3.3.x-dev].
- Can only install one of: symfony/yaml[4.0.x-dev, 3.4.x-dev].
- Installation request for symfony/yaml ^4.0 -> satisfiable by symfony/yaml[4.0.x-dev, 4.1.x-dev, v4.0.0, v4.0.0-BETA1, v4.0.0-BETA2, v4.0.0-BETA3, v4.0.0-BETA4, v4.0.0-RC1, v4.0.0-RC2, v4.0.1].
Installation failed, reverting ./composer.json to its original content.
I have been trying to get laravel working with this docker stack for past few days but nothing seems to working.
Things i've already tried.
github clone https://github.com/laravel/laravel.git to /web/app and /web/public directory.
Tried installing via composer to /web with this command in cmder "docker run --rm -v $(pwd)/web:/web composer create-project --prefer-dist laravel/laravel ./"
This seems to install the laravel package via composer but doesn't shows up in the /web directory.
hello ,
when I use the default env file,mysql is ok. then i modify the env file, use 5.6 version, the mysql container can not login, is there a problem, or only 5.7 support?
Great post/repository, fantastic instructions. Am hoping to request adding Wordpress into the mix as a docker container if that's of interest to others (am trying, initially am getting port conflicts and suspect that is the tip of the iceberg). Thx for giving it "a think".
Hi, I am trying to get the library SOAP into php, can you help me to do that? Thanks in advance
I have tried installing this project on raspberry pi, but some packages are not supported in arm.
If you change some packages it can start, but it causes errors
php_1 | standard_init_linux.go:219: exec user process caused: exec format error
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a0b8c070c084 phpmyadmin/phpmyadmin "/docker-entrypoint.…" 56 minutes ago Restarting (1) 52 seconds ago phpmyadmin
41b219861b46 nginx:alpine "/docker-entrypoint.…" 56 minutes ago Up 35 minutes 0.0.0.0:8000->80/tcp, 0.0.0.0:3000->443/tcp docker-nginx-php-mysql_web_1
5fd9e08ad06b jsurf/rpi-mariadb "docker-entrypoint.s…" 56 minutes ago Up 35 minutes 0.0.0.0:8989->3306/tcp mysql
0f5b3ca4314c nanoninja/php-fpm:latest "docker-php-entrypoi…" 56 minutes ago Restarting (1) About a minute ago docker-nginx-php-mysql_php_1
I'm using nanoninjia for a while. Recently I do a comment "shell_exec" in my php file, but it's failed.
to reproduce it, quite easy. Make a test.php file as following content:
<?php
echo shell_exec('/usr/bin/docker 2>&1');
exit();
?>
Then, use browser with url "http://35.185.xxx.xxx/test.php". I got "sh: 1: /usr/bin/docker: not found" on browser. I did have $PATH include /usr/bin for sure.
if I change "echo shell_exec('/usr/bin/docker 2>&1');" to "echo shell_exec('ls 2>&1');". It works and list the files of directory.
I studied a lot of discussion on web but cannot find an answer. Most of people mentions need a absolute path. I did as above "/usr/bin/docker" but still unsuccessful.
I start suspect whether it's something wrong in nanoninjia ?? or sorry because of my poor knowledge on docker and nginx?
Is anyone seeing same problem?
Take a look at the comments in issue 102:
laradock/laradock#102
I am having trouble getting xdebug remote debug working.
expose:
- "9000"
Hi!
Awesome project! I used vagrant and want to switch to docker. I will probably migrate many projects.
First though I need to find out why docker-php can't write to the "web" folder.
Are there extra steps I need to do apart from your guide, or does the docker process need some special access rights? (I am on linux)
Thank you!
Hi~
I want to use the follow project to create my project.Do you know how to use it?
https://github.com/overtrue/package-builder
Thank you~
A fresh Installation by default installs php v 7.1.33 depsite using the "latest" label.
when I go to loclahost:8080 I can access phpmyadmin, how can I access my web/html/public/ files?
I'm using this docker to build a website in laravel framework and I need to use dompdf library to install by composer.
I run this command:
sudo docker run --rm -v $(pwd)/web/app:/app composer require barryvdh/laravel-dompdf
and having the error:
dompdf/dompdf v0.8.2 requires ext-gd * -> the requested PHP extension gd is missing from your system.
.....
I have checked the docker which includes GD library but I have no idea why this error comes out.
I googled a lot and found this guy was having the same problem in here:
Do you guys have any suggestion how to fix this issue in this docker???
I'm traying to integrate memcached to php container witouth success.
My commands are:
apt install memcached -y
service memcached start
apt install php5-memcached -y
Regards!
If I want to use it in production, how should I modify it?
On Windows 10 Home using docker Toolbox and a stock clone of docker-nginx-php-mysql, the following error occurs when using the docker-compose up -d
command.
ERROR: for ninjacat_web_1 Cannot start service web: oci runtime error: container_linux.go:262: starting container process caused "process_linux.go:339: container init caused \"rootfs_linux.go:57: mounting \\\"/d/development/projects/ninjacat/etc/nginx/default.conf\\\" to rootfs \\\"/mnt/sda1/var/lib/docker/aufs/mnt/01f058ca3728ad3150eaa198b05a3fdc63914b0274dc03db873a8b11d475b0df\\\" at \\\"/mnt/sda1/var/lib/docker/aufs/mnt/01f058ca3728ad3150eaa198b05a3fdc63914b0274dc03db873a8b11d475b0df/etc/nginx/conf.d/default.conf\\\" caused \\\"not a directory\\\"\""
: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for web Cannot start service web: oci runtime error: container_linux.go:262: starting container process caused "process_linux.go:339: container init caused \"rootfs_linux.go:57: mounting \\\"/d/development/projects/ninjacat/etc/nginx/default.conf\\\" to rootfs \\\"/mnt/sda1/var/lib/docker/aufs/mnt/01f058ca3728ad3150eaa198b05a3fdc63914b0274dc03db873a8b11d475b0df\\\" at \\\"/mnt/sda1/var/lib/docker/aufs/mnt/01f058ca3728ad3150eaa198b05a3fdc63914b0274dc03db873a8b11d475b0df/etc/nginx/conf.d/default.conf\\\" caused \\\"not a directory\\\"\""
: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
php-nginx-compose/docker-compose.yml
php:
image: nanoninja/php-fpm:${PHP_VERSION}
restart: always
volumes:
- "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
- "./web:/var/www/html"
# 设置时区
environment:
- TZ=Asia/Shanghai
container_name: "compose-php-fpm"
php-nginx-compose/etc/php/php.ini
date.timezone = Asia/Shanghai
phpinfo
Default timezone = Asia/Shanghai
When I use the date('1533438556','Y-m-d H:i:s'),result is 8556-08-19 15:33:43
I have tried both CentOS 8 and Ubuntu 20.10.
It's quite simple, just able to make it work perfectly in Ubuntu 20.10.
But same docker-compose.yml cannot work in CentOS 8. I have tried many time re-installation of CentOS. Unfortunately just failed.
The docker compose is well completed. But when I visit 127.0.0.1:8000, it just feedback "502 Bad Gateway". Access 127.0.0.1:8080 for PhpMyAdmin, it appear the query of host/account/password. When I input the host/account/password, it gives message " mysqli::real_connect(): (HY000/2002): No route to host".
I tested the Ubuntu and CentOS back and forth twice on "same" machine. The Ubuntu can work everytime. The CentOS failed everytime.
ERR_SSL_SERVER_CERT_BAD_FORMAT
I have cloned your repo, next I run command to generate certificate but when I try to visit my page via ssl i'm still getting:
This site can’t provide a secure connection
mysite.dev doesn't adhere to security standards.
ERR_SSL_SERVER_CERT_BAD_FORMAT
While developing with SSL/HTTPs locally, it can be rather annoying to have the red "x", and browser flags that the cert is not approved.
Update the readme with the steps (currently specific to OS X) for adding the certs.
I have multiple instances of the containers in docker-compose.yml running in the same docker network (because I'm serving multiple applications by reverse proxying).
I noticed that, from the 2nd web
container instance onward, it will always reference the 1st php
FPM container and thus serve webpage 1.
I tried setting the port in ./etc/php/php.ini
and ./etc/nginx/default.template.conf
from 9000 to 9001, respectively, and exposed port 9001 on the php
container - to no avail.
How can I run multiple of these container networks without them interfering with each other? What's the best practice for running a reverse proxy like https://github.com/SteveLTN/https-portal with this repo?
Thanks in advance!
@nanoninja @ZengLeiPro @ghostal @makros @letvinz
I want to create multiple virtual hosts for the single application available in the web directory.
I want to create new conf file for the virtual host and want to move same as the default.conf.
Tried with the same commands and steps in the yml file, also created new host variable in .env but did not work.
Please guide me to achieve multiple virtual hosts with multiple config files.
Thanks in advance.
Would be great to have access to .env values in PHP to avoid having to connect to the database and reuse db_name, db_user etc etc
Im following readme instructions, not changing anything in the config, and out of the box PMA (or any other app for that matter) cannot connect to mysql.
I tried changing localhost to 127.0.0.1 - nothing
Tried logging with root, dev, custom creds i set - nothing
I can jump into the mysql container with root credentials from .env, but PMA just throws no matter what i do.
Cannot log in to the MySQL server
mysqli::real_connect(): (HY000/2002): Connection refused
Is there something not described that needs to be done for mysql to work?
how to setting virtual domain in here ? when i try it , it's not going to the domain . i already try to copied default.template.conf then rename it and change the server name and change root dir , and add hosts volume . but nothing happened .
I have updated the root password from the main .env file and after update password executed following commands.
But still phpmyadmin accepting the old password "root".
Please help if I am missing some steps. Thank you.
I noticed the generated "reports", and wanted to know if you have a utility for making them public, or planned on creating one?
Something along that lines that publishes them to the public folder, actually that might not be the best idea, was there any thought on mentioning them in the docs at least?
Hi nanoninja,
Can you add simple code to give example connection from php to mysql is working?
How to create route using your docker?
Thankful
;D
Hello!
I use Ubuntu 20.04.
Install completed. I set PHP 8.1. http://localhost:8000/ in Firefox is work.
I use CodeLite IDE. I run CodeLite - PHP Setting - General - PHP Executable.
How I can install custom extension like ioncube
?
Thank you.
Why does the session expires quickly, how can I can control over it
Hi @nanoninja and congrats for the code.
I'm trying to instance a PDO connection using the example you've wrote on readme. When trying to query I've got this error:
Warning: mysqli::__construct(): (HY000/2002): No such file or directory in
Problem is related with permissions over local directory ./data/db/mysql
but working with windows 10 Pro don't know what to solve permissiopns issue.
My technical specs:
MySQL was recently updated and phpmyadmin doesn't work with it.
Please, update phpmyadmin or set mysql version to 5.7 in docker-compose.yml.
Thanks!
I would love to have somehow "$_POST" and "$_GET" - is it possible? Or other variables with the same data.
On the phpMyAdmin login screen how is the "Server:" setting derived? Currently I can connect to the DB via PDO, but I cannot login via the pma screen.
I've recently adjusted the NGINX_HOST
, and configured the phpMyAdmin and MySQL containers as follows;
myadmin:
image: phpmyadmin/phpmyadmin
container_name: ${APP_NAME}_phpmyadmin
ports:
- "8080:80"
environment:
- PMA_ARBITRARY=1
- PMA_HOST=${APP_NAME}_${MYSQL_HOST}
restart: always
depends_on:
- mysqldb
mysqldb:
image: mysql
container_name: ${APP_NAME}_${MYSQL_HOST}
restart: always
env_file:
- ".env"
environment:
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
ports:
- "8989:3306"
volumes:
- "./database/data/db/mysql:/var/lib/mysql"
networks:
- esnet_new
I'm presuming my issue is something with the container_name
I've set.
It's certainly odd that you have to go out of your way to setup Docker on Linux so that it doesn't need sudo
. Nonetheless, it might be best to presume that user of this repo, whatever the OS, doesn't need sudo. Totally worth avoiding. If there are any malware problems in the associated Docker images...
I think readme is not correct when it comes to logging into mysql container.
I have to do docker ps and get sha of running container to get inside the container, the label doesnt work for some reason.
Neither mysql or mysqldb did not work.
docker-nginx-php-mysql|master⚡ ⇒ docker exec -it mysql bash
Error: No such container: mysql
docker-nginx-php-mysql|master⚡ ⇒ docker exec -it 89dcfc77a965 bash
root@89dcfc77a965:/#
Hi,
It's not an issue, but I'd like to know what are the best strategies do deploy an app with this repository.
Exemple: I'm using aws in some projects without docker and I need to access via ssh and run everything via terminal. But I'm planning to use multiple instances of nginx servers to optimize the performance of the app.
What you suggest? Thanks a lot!
This can be a controversial request, since I know that some (most) PHP developers (still) love to;
Personally I use PHPMD and do like (enjoy) it.
I've added support for this on my local branch, but have not submitted a pull request. Figured, I'd ask, and open a dialog first.
Steps to add support;
Makefile
with; (note, this will scan all your files in app/src
)phpmd:
@docker-compose exec -T php \
./app/vendor/bin/phpmd \
app/src/ \
text \
cleancode,codesize,controversial,design,naming,unusedcode
"phpmd/phpmd" : "@stable"
Run the composer update.
Use it with make phpmd
.
Hi Dear, Is possible to install it behind traefik?
thanks
Fabio
Following the read-me, I receive this error during the docker-compose up
, and I am unable to load any of the URLs listed in the readme:
The error I receive is:
sudo docker-compose up -d
WARNING: The Docker Engine you're using is running in swarm mode.
Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.
To deploy your application across the swarm, use `docker stack deploy`.
Pulling web (nginx:alpine)...
alpine: Pulling from library/nginx
ERROR: no matching manifest for linux/amd64 in the manifest list entries
Docker and Docker Compose versions:
docker -v
Docker version 17.09.1-ce, build 19e2cf6
docker-compose -v
docker-compose version 1.17.1, build 6d101fb
I would like to know;
Following document rump up docker then receive the following error
Get https://registry-1.docker.io/v2/nanoninja/php-fpm/manifests/latest: unauthorized: incorrect username or password
Hello,
Can you add Zend OPcache support?
Thank you.
Created SSL certificate successfully using the command as mentioned in the configuration section.
"source .env && sudo docker run --rm -v $(pwd)/etc/ssl:/certificates -e "SERVER=$NGINX_HOST" jacoelho/generate-certificate"
Also uncommented the SSL setting section from the "default.template.conf" file but https is not implementing on the application URL.
Just for try: Updated the "$NGINX_HOST" with my virtual machine IP (application address) and also with the created virtual host with no success.
Also did the docker-compose down -v and docker-compose up -d after update the configuration.
Please help me in this regard. Thanks
Firstly, thank you for the great work!
After start all the containers, phpmyadmin is reachable without problem.
But it is not possible to login. I can click on login, but something with the credentials (dev, dev) or the configuration on my site must be wrong. I used the repository out of the box, no changes. Ports on the server are open. Do you know, what the missing point is?
These should be added to the .gitignore
file.
New install appears to be fine. Except, I'm running into an error with php-fpm trying to install phpoffice/spreadsheets missing a dependency ext-zip
composer require phpoffice/phpspreadsheet
Using version ^1.15 for phpoffice/phpspreadsheet
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
Anyone know how to fix this issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.