nginx 初始配置文件

nginx.conf 配置文件

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/;

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.d/*.conf;

default.conf 配置文件

server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    #access_log  /var/log/nginx/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   /usr/share/nginx/html;

    # proxy the PHP scripts to Apache listening on
    #location ~ \.php$ {
    #    proxy_pass;

    # pass the PHP scripts to FastCGI server listening on
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$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;

Docker 安装部署教程

Docker logo

Docker 安装

curl -sSL | sh

Docker-Compose 安装并设置权限

curl -L`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

配置 Docker 镜像源

创建 daemon.json 文件

sudo mkdir -p /etc/docker


sudo tee /etc/docker/daemon.json <<-'EOF'
  "registry-mirrors": ["","",""]

赋予普通用户执行 Docker 命令

gpasswd -a username docker

重启 Docker 服务

sudo service docker restart

部署 MySQL 容器

docker run --name mysql --restart=always -d -p port:3306 -v $PWD/mysql/data:/var/lib/mysql -v $PWD/mysql/conf/conf.d:/etc/mysql/conf.d -v $PWD/mysql/log:/var/log/mysql -e MYSQL_ROOT_PASSWORD="××××××××××" mysql

部署 phpMyAdmin 容器

docker run --name phpmyadmin --restart=always -d --link mysql:db -p port:80 phpmyadmin/phpmyadmin

部署 WordPress 容器

docker run --name wordpress --restart=always -d -p port:80 --link mysql:db -v $PWD/wordpress:/var/www/html wordpress

部署 Nginx 容器

docker run -p port:80 -p port:443 --name nginx --restart=always -v $PWD/nginx/nginx.conf:/etc/nginx/nginx.conf -v $PWD/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf -v $PWD/nginx/log:/var/log/nginx -v $PWD/nginx/html:/usr/share/nginx/html -v $PWD/nginx/cert:/etc/nginx/cert -d nginx

Nginx 初始配置文件

Nginx 初始配置文件

部署 NextCloud 容器

docker run -d --name nextcloud --restart=always -p port:80 --link wordpress_mysql:db -v $PWD/nextcloud/:/var/www/html/ nextcloud

以 www-data 身份运行 crontab

crontab -u www-data -e
*/5 * * * * docker exec --user www-data ${container id} php cron.php