centos php时间设置的方法


本文摘自PHP中文网,作者藏色散人,侵删。

centos php时间设置的方法:首先注释掉“ZONE="America/New_York"”;然后修改系统时区;接着在php.ini中进行时区设置,设置“date.timezone = PRC”;最后通过crontab将时间同步即可。

推荐:《PHP视频教程》《centos教程》

修改 linux 时区时间和 php 时区

问题:客户美国服务器时间不对

第一步,先修改硬件时区。

1

2

vim /etc/sysconfig/clock

将 ZONE="America/New_York" 注释,加多一行 ZONE="Asia/Shanghai"

第二步,修改系统时区

1

2

3

4

5

6

7

8

cp /etc/localtime /etc/localtime.bak

rm -rf /etc/localtime

ln -svf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

yum install ntpdate -y

ntpdate 0.centos.pool.ntp.org

date

clock -w         #将目前 Linux 的时间写到 BIOS 里面去!

clock -r         #检查 BIOS 里面的时间

第三步,修改 php.ini 的时区设置

1

date.timezone = PRC

第四步,写个 crontab 将时间同步(特殊情况下,加上这个)

1

2

#Ansible: Time synchronization

00 01 * * * /usr/sbin/ntpdate 0.centos.pool.ntp.org >/dev/null

怎样设置每次开机同步一次时间

1

2

3

4

vim /etc/rc.local

usr/sbin/ntpdate 0.centos.pool.ntp.org >/dev/null

  

--------------------------------------------------------------------------------------------------

上面是设置 centos6.5 的时区和时间的,下面说的是 centos7的

1

2

3

4

5

6

yum -y install ntp

systemctl enable ntpd

ntpdate -u cn.pool.ntp.org

systemctl start ntpd

#设置时区

timedatectl set-timezone Asia/Shanghai

以上就是centos php时间设置的方法的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

php如何与apache连接超时

CentOS7 忘记 root 密码的解决办法

CentOS6.8如何安装php

CentOS下ftp无法上传文件怎么办

lamp是什么意思

CentOS系统中无法使用ifconfig命令

CentOS怎么下载jdk

介绍CentOS彻底删除文件夹、文件命令

u盘安装CentOS后无法启动怎么办

CentOS怎么安装rpm软件

更多相关阅读请进入《CentOS》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...