代码之家  ›  专栏  ›  技术社区  ›  Milano

Nginx显示错误的时间/时区

  •  1
  • Milano  · 技术社区  · 7 年前

    如何修复 Nginx 时区?我已经配置好了 nginx 提供一个目录,但创建的日期时间是我的实时时间后一小时。

    /etc/init.d/nginx

    export TZ='Europe/Bratislava'
    

    然后

    sudo service nginx reload
    sudo service nginx restart
    

    试图改变 Ubuntu 默认时区,但日期时间不变。

    sudo dpkg-reconfigure tzdata
    

    enter image description here

    2 回复  |  直到 7 年前
        1
  •  10
  •   gpgekko    7 年前

    autoindex_localtime 指示打开。

    autoindex_localtime on
    
        2
  •  2
  •   SherylHohman David    7 年前

    要更改时区,可以在实例中运行以下命令:

    sudo dpkg-reconfigure tzdata
    

    然后选择你喜欢的时区。

        3
  •  1
  •   gman    5 年前

    首先,您需要设置您的系统时区。你可以用 timedatectl list-timezones

    sudo timedatectl set-timezone Europe/Moscow
    

    autoindex_localtime autoindex_localtime on; 例如,在您站点的nginx配置文件中 /etc/nginx/sites-avaliable/default . 把指令放在 autoindex on;

    server {
            listen 80;
            listen [::]:80;
    
            root /var/www/dir;
    
            index index.html index.htm index.nginx-debian.html;
    
            server_name _;
    
            location / {
                    try_files $uri $uri/ =404;
            }
    
            autoindex_localtime on;
            autoindex on;
    }
    
        4
  •  0
  •   Vitalicus    6 年前

    php.ini . 如果使用php,请在中更改时区 [Date]

        5
  •  -1
  •   Ajay    7 年前