Docker下部署NMP 三、部署Nginx 2021-01-30 # S1. 安装 ```bash # 下拉镜像 -- 这里选择的版本为7.3.26,使用fpm即可 docker pull nginx:1.19 # 安装 docker run -d --name [container name] -P [container port]:[host port] -v [host www]/www:/www [host conf]/conf:/etc/nginx/conf [host cache]/cache:/cache [host log]/log:/var/log/nginx -d nginx:1.19 ``` - [host www] 项目运行目录 - [host conf] conf文件目录 - [host log] log文件目录 # S2. 配置 **修改conf的文件目录** nginx.conf修改如下: ``` user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf/*.conf; } ``` 将其复制回容器的`/etc/ngnix`目录下 **增加一个网站示例** 在本地的[host conf]目录下增加文件,暂且命名为```phpinfo.test.conf``` ``` server { listen 80; server_name phpinfo.test; index index.php index.html index.htm default.php default.htm default.html; root [project root dir]; #access_log /var/log/nginx/host.access.log main; #error_page 404 /404.html; #PHP-INFO-START PHP引用配置 location ~ \.php$ { fastcgi_index index.php; fastcgi_pass [php container ip]:[your php host port]; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } #PHP-INFO-END # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } ``` 本文作者: koali 原文链接: Docker下部署NMP 三、部署Nginx 版权声明: 本站所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处! 免责声明: 文中如涉及第三方资源,均来自互联网,仅供学习研究,禁止商业使用,如有侵权,联系我们24小时内删除! 部署Docker « 上一篇Docker下部署NMP 二、安装MySQL 下一篇 »Docker安装rabbitmq并添加延时队列
评论0
暂时没有评论