docker-compose.yml编排LNMP,php找不到文件,注意nginx配置文件
2018-09-10 16:45
986 查看
version: "3" services: mysql: container_name: dev-mysql image: mysql:latest command: --default-authentication-plugin=mysql_native_password environment: #变量 MYSQL_ROOT_PASSWORD: 123456 ports: - "3306:3306" expose: - "3306" restart: always volumes: - /var/mysql/3306:/var/lib/mysql:rw - /etc/mysql/3306:/etc/mysql/conf.d:ro deploy: replicas: 1 # 运行数量 networks: - lnmp redis: container_name: dev-redis image: redis:latest # ports: # - "6379:6379" expose: - "6379" volumes: - "/var/redis/6379:/data:rw" - "/etc/redis/6379.conf:/usr/local/etc/redis/redis.conf" deploy: replicas: 1 restart: always #重启 networks: - lnmp php: container_name: dev-php-fpm build: context: ./ dockerfile: Dockerfile image: dev-php-fpm:7.2.9 #给镜像起名加标签 # ports: # - "9000:9000" expose: - "9000" links: - mysql restart: always networks: - lnmp volumes: - /var/html:/var/www/html nginx: container_name: dev-nginx image: nginx:latest volumes: - /var/html:/usr/share/nginx/html:rw - /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro ports: - "80:80" - "443:443" restart: always links: - php deploy: replicas: 1 depends_on: - mysql - redis - php networks: - lnmp networks: lnmp: driver: bridge
php-7.2.9-fpm的Dockerfile
FROM php:7.2.9-fpm RUN apt-get update && apt-get install imagemagick libmagickwand-dev -y \ && pecl install redis-4.1.1 \ && pecl install imagick-3.4.3 \ && pecl install PDO_MYSQL-1.0.2 \ && docker-php-ext-install pdo_mysql \ && docker-php-ext-enable redis imagick
nginx的配置,(注意php部分的root和fastcgi_pass,)
#user nobody; worker_processes 2; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /var/www/html; fastcgi_pass php:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }
相关文章推荐
- Docker Compose 配置文件 Docker-Compose.yml 文件详解
- ubuntu LNMP nginx 隐藏index.php 配置文件
- centos7 安装LNMP(php7)之 nginx php-fpm yum安装以及配置文件修改
- docker-compose命令和yml文件配置
- LNMP环境下nginx、php-fpm的配置文件讲解
- docker-compose.yml 配置文件编写详解
- nginx配置文件nginx.conf详解,能够运行jsp和php的配置文件
- Docker部署WordPress LNMP(Nginx PHP MySQL)环境实践
- Docker部署WordPress LNMP(Nginx PHP MySQL)环境实践
- LNMP(linux+nginx+mysql+php)服务器环境配置
- LNMP(linux+nginx+mysql+php)服务器环境配置
- Centos中查看nginx、apache、php、mysql配置文件路径
- LNMP第二部分nginx、php配置(用户认证、域名重定向、日志、配置缓存、防盗链) 推荐
- LNMP环境问题--nginx不解析php文件
- SpringBoot开发详解(三)--SpringBoot配置文件YML注意事项
- lnmp 一键安装包 nginx配置tp5 phpinfo模式 隐藏index.php
- 【LNMP】Nginx防盗链、Nginx访问控制、Nginx解析php相关配置和Nginx代理
- 编写docker-compose.yml需要注意的问题
- 修改nginx配置文件,支持php的pathinfo
- linux中查看nginx、apache、php、mysql配置文件路径的方法