GithubHelp home page GithubHelp logo

nanoninja / docker-nginx-php-mysql Goto Github PK

View Code? Open in Web Editor NEW
1.8K 71.0 865.0 4.08 MB

Docker running Nginx, PHP-FPM, MySQL & PHPMyAdmin

Shell 9.06% PHP 23.23% Makefile 67.71%
docker docker-compose nginx php-fpm-7 composer mysql phpmyadmin lemp

docker-nginx-php-mysql's Issues

Use Apache instead of Nginx

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

[ERROR] Installing package with composer

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.

Laravel dev environment

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.

  1. github clone https://github.com/laravel/laravel.git to /web/app and /web/public directory.

  2. 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 ./"

image

This seems to install the laravel package via composer but doesn't shows up in the /web directory.

mysql 5.6 can not use

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?

Add in WordPress

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".

New library

Hi, I am trying to get the library SOAP into php, can you help me to do that? Thanks in advance

Raspberry pi 4

I have tried installing this project on raspberry pi, but some packages are not supported in arm.

  • mysql --> jsurf/rpi-mariadb

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

PHP Shell_Exec cannot work in browser

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?

Write permissions for docker process on "web" directory?

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!

Problem: the requested PHP extension gd is missing from your system

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:

composer/composer#5749

Do you guys have any suggestion how to fix this issue in this docker???

I can't install memcached

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!

Mounting Error using Docker Toolbox

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.

date() function Error

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

Cannot work CentOS, but Ubuntu work fine

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.

Unable to get SSL

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

Multiple instances serving wrong content

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!

I want to create multiple virtual hosts for nginx. Please help me.

@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.

Feature Request Add .env to php

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

PMA doesnt connect to mysql

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?

virtual domain

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 .

How to update the mysql root password

@nanoninja

I have updated the root password from the main .env file and after update password executed following commands.

  1. docker-compose down -v
  2. docker-compose up -d

But still phpmyadmin accepting the old password "root".

Please help if I am missing some steps. Thank you.

Reports PHPUnit Code Coverage

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?

Testing php + mysql

Hi nanoninja,
Can you add simple code to give example connection from php to mysql is working?

Symfony

How to create route using your docker?

Thankful

;D

Where is there PHP executable in this docker?

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.

  1. Where is there PHP executable in this docker for CodeLite IDE?
  2. How do I run PHP script in command line in this docker?

session expires

Why does the session expires quickly, how can I can control over it

No such file or directory

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:

  • Windows 10 pro + HyperV
  • Docker version 17.09.0-ce
  • docker-compose version 1.16.1

"$_POST"? "$_GET"?

I would love to have somehow "$_POST" and "$_GET" - is it possible? Or other variables with the same data.

phpMyAdmin -- Login Screen

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.

screen shot 2018-04-04 at 8 59 58 am

Remove sudo from install guide?

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...

Readme logging into mysql container

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:/# 

Deploy Strategies

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!

Add PHPMD Support

This can be a controversial request, since I know that some (most) PHP developers (still) love to;

  1. Bloat their code with a ton of nested foreach if/elseif/elseif/else foreach if/else statements
  2. Use underscores in method names
  3. Debate on the bracket issue

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;

  1. Update the 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
  1. Update composer with;
"phpmd/phpmd" : "@stable"
  1. Run the composer update.

  2. Use it with make phpmd.

Error during docker-compose up

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;

  1. Is this repo still active?
  2. Have others had this problem, if so how did they move forward?

SSL certificate generated successfully but the site is not accessible on https.

@nanoninja

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

Can't login in phpmyadmin

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?

composer error : ext-zip * -> the requested PHP extension zip is missing from your system.

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

  • Installation request for phpoffice/phpspreadsheet ^1.15 -> satisfiable by phpoffice/phpspreadsheet[1.15.0].
  • phpoffice/phpspreadsheet 1.15.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    Installation failed, deleting ./composer.json.

Anyone know how to fix this issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.