You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
801 B
Markdown

# NGINX 部署
> 前提 : docker 和 docker-compose 都已准备完成。
## 配置文件
启动容器
```shell
docker run -d --name nginx nginx
```
创建路径
```shell
mkdir -p /usr/local/nginx/{conf,html,logs}
```
拷贝配置
```shell
docker cp nginx:/etc/nginx/nginx.conf /usr/local/nginx/conf/nginx.conf
```
删除容器
```shell
docker rm -f nginx
```
## COMPOSE 文件
```shell
cat > /usr/local/nginx/docker-compose.yml <<'EOF'
version: '3'
services:
nginx:
restart: always
image: nginx
container_name: nginx
ports:
- 80:80
volumes:
- ./conf/nginx.conf:/etc/nginx/nginx.conf
- ./logs:/var/log/nginx
EOF
```
## 启动
```shell
cd /usr/local/nginx/ && docker-compose up -d
```
## 重载配置
```shell
docker exec nginx nginx -s reload
```