ローカル環境におけるPHPの時刻がうまくいきません。
環境は以下で試しております。
Windows
CentOS6
Laravel
何度試して再起動しても現在時刻より30時間ほど前の時間を示しております。
原因はおそらくDefault timezone が「UTC」になっている事が原因かと思うのですが「Asia/Tokyo」に変更したく思います。
試したこと
1 php.iniの場所の確認
[vagrant@localhost ~]$ php -i | grep php.ini
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
2 etc/php.iniに
date.timezone = "Asia/Tokyo" の追加
3 PHPinfo();で
Loaded Configuration File
/etc/php.ini の確認
4 Laravelの
config/app.php で
'timezone' => 'UTC', ⇒ 'timezone' => 'Asia/Tokyo',
5 再起動
phpinfo();
Default timezone UTC のまま変化していない。
追加
6 /etc/httpd/conf/httpd.conf 書き換え後アパッチ再起動
ServerName localhost:80 //書き換え
vagrant@localhost ~]$ sudo service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
その後パソコンの再起動もしましたが時刻は変化しておりませんでした。
追加
7 vagrantの停止・再起動の方法が間違えていたようで「vagrant suspend」で試していたのですが方法を変更しました。「vagrant halt」⇒「vagrant reload」⇒「vagrant up」と試してみました。
現在時刻は 2020年1月23日16時31分
echo date("Y/m/d H:i:s");表示は 2020/01/22 22:32:06
でした。
時間は縮まった気がしますが
「Default timezone UTC」が以前のままでした。
8
$ date
Thu Jan 23 23:36:57 JST 2020
$ ntpq -p
-bash: ntpq: command not found
↓
ntpq導入
yum install ntp
Package ntp-4.2.6p5-15.el6.centos.x86_64 already installed and latest version
Nothing to do
↓
再起動
↓
sudo yum install ntp
$ date
Thu Jan 23 23:50:42 JST 2020
$ ntpq -p
ntpq: read: Connection refused
※vagrant立ち上げる際に
ーーー
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=500,gid=500 vagrant /vagrant
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
上記のような警告が出ていました。
何かおかしな事してしまったのかもしれません。
回答1件
あなたの回答
tips
プレビュー