我想将nginx.conf
和default.conf
挂载到运行nginx的容器中。
docker run --detach --tty --interactive --publish=8081:80
-v $(pwd)/app:/var/www/
-v $(pwd)/configurations/nginx.conf:/etc/nginx/nginx.conf
-v $(pwd)/configurations/default.conf:/etc/nginx/sites-enabled/default.conf
--name="my_container" my:dev
我遇到404错误,当我登录docker容器时,我发现app目录已挂载,但default.conf
是默认值。
这是default.conf文件:
server {
root /var/www;
index index.html index.htm index.php;
server_name localhost;
location / {
try_files $uri $uri/ /index.php?$query_string =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_read_timeout 240;
}
}