LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-12-2018, 12:35 PM   #1
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Rep: Reputation: 51
Question Possibly small problem in a server: why some dates are not in my timezone?


I have an account in a Debian GNU/Linux 9.4. I have no root access there.

In my server uses I have:

- date and time are correctly shown in SSH access

- ~/public_html/php.ini exists and contain a line to set my timezone ( the line is like date.timezone="Inside/Somewhere" )

I created a folder inside ~/public_html and put a few files there. Now I want to show these files and their dates to people. When I list that folder in SSH, the dates are correct. But when I open that folder in my browser (accessing the folder like anyone in the world can do), the time is in a different timezone.

Searching for the keypoint of my problem, I found nothing as clear as I need.

But this info may be useful for you:

Code:
$ ssh me@server
$ cat ~/public_html/folder/t.php
   <?php 
   phpinfo();
   ?>
$ # visiting that t.php file in the browser shows also this line:
$ # "Loaded Configuration File"  -> /etc/php/7.0/apache2/php.ini 

$ # Copying public_html/php.ini to p_html/folder does not change anything
$
What should I do to have the correct (or as I want) files' folders times?


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

A few hours later, I tried something different, but did not help. I thought about something else to try: .htaccess.

First, I created a file ~/public_html/folder/.htaccess. The key directives to play with are one of these two lines, changing the commented one:

Code:
#SetEnv TZ America/Brasilia
SetEnv TZ America/Sao_Paulo
I wrote there the usual timezone name I know (it uses the wrong city as reference for the timezone, but this problem is scattered almost anywhere). Reloaded the t.php from the browser, no change.

Second, I changed the timezone name to something I saw in the web, which had the correct city. "Great, this should be the problem!" - I thought. Reloaded the t.php tab, but also no change.

Then I tried to find a page listing the timezone names I could choose from. Could not. Can you point it to me?

The .htaccess file (also) should work! My web root folder has one, with a directive that surely work correctly. It changes the 404 errors everywhere to something I chose. I also tried the two timezone I tried before in the root .htaccess, no success.

If I am in the situation that needs root to do something, I would like to confirm the situation. I have no clue of what else to do. With that, I can contact the server admin and (possibly) ask for changes.

Waiting for replies.

Last edited by dedec0; 05-15-2018 at 08:19 PM.
 
Old 05-12-2018, 07:49 PM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
The timezone is set by the client. It shows differently with ssh because you're logged into the server, so you see its time, not the client's time. But with browsers it shows the clients time zone.

Last edited by AwesomeMachine; 05-12-2018 at 07:52 PM.
 
Old 05-12-2018, 08:14 PM   #3
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by AwesomeMachine View Post
The timezone is set by the client. It shows differently with ssh because you're logged into the server, so you see its time, not the client's time. But with browsers it shows the clients time zone.
I am confused with that. The server time is *not* in my timezone. Although the times I see for my files there are shown in my timezone. This is consequence of my user environment, I think:

Code:
$ ssh me@server
$ # my shell is Bash
$ set | grep TZ
  TZ=America/Sao_Paulo
My timezone is that one, America/Brasilia (which is the correct name for the common America/Sao_Paulo). I have tried both values in the steps I described in the first message.

If the files seen through the web server (for example: http://me.server.net/folder/ ) were shown in my timezone, that would be exactly what I want - but
this does not happen.

Last edited by dedec0; 05-13-2018 at 10:41 AM.
 
Old 05-13-2018, 12:47 PM   #4
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
OK, I understand. If you're just looking at a file path in a browser--nothing in html--it will probably not adjust the file metadata according to the client's TZ. That would be chaos. I'm not sure if I'm understanding this correctly.

When you ssh into the server the file metadata is different than if you point a browser to the same files?
 
Old 05-13-2018, 02:53 PM   #5
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by AwesomeMachine View Post
OK, I understand. If you're just looking at a file path in a browser--nothing in html--it will probably not adjust the file metadata according to the client's TZ. That would be chaos. I'm not sure if I'm understanding this correctly.
Yes, it would be chaos, of course. Browsers would need to know which timezone each remote page is, which is a very strange idea. So they do not change anything the remote server sends (through sites).

Quote:
Originally Posted by AwesomeMachine View Post
When you ssh into the server the file metadata is different than if you point a browser to the same files?
The answer is close to "yes and no". The metadata of the files are just one, the server's filesystem date for the files I uploaded. But they are shown with different values depending on how I list them.

I may I want to set my site's (of my account in that server) timezone to a specific value, to coincide with my timezone. My bash environment has it set, as I discovered.

Now, my steps can be summarized in:

1. I created a few local files (where they have time creation metadata, which does not matter)

2. I uploaded those files to server using scp (where they got similar metadata, with just a few minutes difference)

3. I created a new folder in my server. This folder path *there* is ~/public_html/nf/ (nf = short for "new folder")

4. I moved the uploaded files to that folder

5. I listed (from there) the folder contents, using my common 'ssh me@server' access. Their times are shown in my timezone (their creation date is the time I uploaded them, which is correct). I see the right time here as consequence of my TZ var in environment there (I imagine).

6. In my local browser (here), I open the page http://me.server.fi/nf/, which present me with a list of the files I moved in step 4. But their metadata time is not correctly shown! They are different. They are in a different timezone (my statement!), comparing with the times seen with 'ls -l' I did through ssh.

Do not forget the ways I tried to fix the shown time:

- add a new "~/public_html/php.ini" directive

- a new "php.ini" file put in nf remote folder, with the same directive

- checked which config PHP use, with "phpinfo()" function, but I am far from sure that I interpreted it right (it did not say to read my .ini file, which I am pretty sure it does)

- remotely listing my files with ssh needed no change, as said

- added a new ~/public_html/.htaccess (remote file) directive, but it did not work. The .htaccess existed, and has directives that clearly work

- created a new remote file ~/public_html/nt/.htaccess with the timezone directive, but it also did not work

Is it better now? Clearer?
 
Old 05-13-2018, 03:10 PM   #6
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I am not sure to understand how files dates (last modified dates?) relate to timezone...
I mean I don't get why file dates are different in ssh session and in apache directory listing

I don't see any setting allowing to change date zone for apache directory indexing
http://httpd.apache.org/docs/current/mod/mod_dir.html

Could you show some example of different file dates you see (from ssh and from http)?

Last edited by keefaz; 05-13-2018 at 03:22 PM.
 
Old 05-13-2018, 04:07 PM   #7
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by keefaz View Post
I am not sure to understand how files dates (last modified dates?) relate to timezone...
I mean I don't get why file dates are different in ssh session and in apache directory listing
My guess of my shell environment adjusting them in ssh session is not true?

Quote:
Originally Posted by keefaz View Post
I don't see any setting allowing to change date zone for apache directory indexing
http://httpd.apache.org/docs/current/mod/mod_dir.html
Thank you for that pointer! I could not find it. Unusual reading for me.


Quote:
Originally Posted by keefaz View Post
Could you show some example of different file dates you see (from ssh and from http)?
Yes, sure I can!

ssh session below. Note that my PS1 has two lines! It shows time, "user@server", folder and the common "$" in the second line.

Code:
$ ssh me@server

...
# login lines, which do not matter here, removed
...

17:36:35 me@server:~
$ 'ls' -l public_html/nf/
total 608
-rw-r--r-- 1 me me 127311 May 12 13:43 289.jpg
-rw-r--r-- 1 me me 151157 May 12 13:43 295.jpg
-rw-r--r-- 1 me me 152416 May 12 13:43 297.jpg
-rw-r--r-- 1 me me 175432 May 12 13:43 298.jpg
-rw-rw---- 1 me me    646 May 12 14:20 php.ini
-rw-rw---- 1 me me     23 May 12 14:18 t.php
17:36:55 me@server:~
$ # ls between single quotes is to avoid my
  # alias: ls='ls -sh --color=auto'
17:39:47 me@server:~
$ # Right now my local time is ~17:40,
  # as I write this post
Note that 13:43 is the correct localtime (for me) when I created and uploaded those files.

Now a screenshot of that I see in the browser, which (should not matter) is Firefox 52 ESR. The times shown here are exactly 5 hours different, which seems correct for my timezone difference idea.

imgbox.com/wPBQYfl9

I do not show a browser window because I can take screenshots of all pages parts, even unshown ones, with the "Abduction!" Firefox extension. The address of that shot was said before: http://me.server.fi/nf/ (actually, the real server is .nl, if you wonder).

Last edited by dedec0; 05-16-2018 at 07:13 PM.
 
Old 05-13-2018, 04:53 PM   #8
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Maybe try to edit your .haccess file and add timezone environment with this line
Code:
SetEnv TZ Europe/Amsterdam
Not sure it will work, it needs mod_env apache module loaded
 
1 members found this post helpful.
Old 05-13-2018, 07:09 PM   #9
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Question

Quote:
Originally Posted by keefaz View Post
Maybe try to edit your .haccess file and add timezone environment with this line
Code:
SetEnv TZ Europe/Amsterdam
Not sure it will work, it needs mod_env apache module loaded
That kind of line is exactly what I have tried before, with .htaccess (both in my HTML root and in nf folder).

Trying to find if the module is loaded, I found an SO thread that points to the apachectl command. But that command does not exist on my server:

Code:
# in SSH session:
20:27:23 me@server:~/public_html/nf
$  vim .htaccess 
20:53:12 me@server:~/public_html/nf
$ set|grep TZ
 TZ=America/Sao_Paulo
20:53:16 me@server:~/public_html/nf
$ apachectl -M
 -bash: apachectl: command not found
20:55:53 me@server:~/public_html/nf
$
There seems to be a better SO thread for debianish distros. Indeed, the second paragraph in the first answer has this:

Quote:
Debian/Ubuntu butcher the apache configuration into a large number of files, where directories of mods and sites enabled are symlinked to other snippets of configuration files. The a2enmod/a2ensite scripts just manipulate these symlinks.
Which made me try one command in my ssh session:

Code:
20:55:53 me@server:~/public_html/nf
$  ls /etc/apache2/mods-enabled/
total 0
0 access_compat.load    0 deflate.conf      0 proxy.conf
0 alias.conf            0 deflate.load      0 proxy_connect.load
0 alias.load            0 dir.conf          0 proxy_html.conf
0 auth_basic.load       0 dir.load          0 proxy_html.load
0 authn_core.load       0 env.load          0 proxy_http.load
0 authn_file.load       0 expires.load      0 proxy.load
0 authnz_external.load  0 filter.load       0 qos.conf
0 authnz_pam.conf       0 headers.load      0 qos.load
0 authnz_pam.load       0 mime.conf         0 reqtimeout.conf
0 authz_core.load       0 mime.load         0 reqtimeout.load
0 authz_groupfile.load  0 mpm_itk.load      0 rewrite.load
0 authz_host.load       0 mpm_prefork.conf  0 setenvif.conf
0 authz_user.load       0 mpm_prefork.load  0 setenvif.load
0 autoindex.conf        0 negotiation.conf  0 socache_shmcb.load
0 autoindex.load        0 negotiation.load  0 ssl.conf
0 bw.load               0 pagespeed.conf    0 ssl.load
0 cache_disk.conf       0 pagespeed.load    0 status.conf
0 cache_disk.load       0 passenger.conf    0 status.load
0 cache.load            0 passenger.load    0 substitute.load
0 cgi.load              0 php7.0.conf       0 xml2enc.load
0 dav.load              0 php7.0.load       0 xsendfile.load
21:09:49 me@server:~/public_html/nf
$
That "env.load" is the env module I am trying to use? It points to "../mods-available/env.load"

Now I am trying to find if I can enable the env module for my user. If I cannot, I will ask that for the server admin. Any ideas that can be added to that message? Comments are welcome!

Last edited by dedec0; 05-13-2018 at 07:17 PM.
 
Old 05-13-2018, 07:18 PM   #10
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
...

Last edited by dedec0; 05-13-2018 at 08:24 PM.
 
Old 05-13-2018, 08:27 PM   #11
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Question

Quote:
Originally Posted by keefaz View Post
Maybe try to edit your .haccess file and add timezone environment with this line
Code:
SetEnv TZ Europe/Amsterdam
Not sure it will work, it needs mod_env apache module loaded
Forgot to say in #9: in my server, the only command started with a2 is a2ping. There are no a2enmod and a2ensite, as the paragraph I quoted points. Should I ask for those commands for normal users, like me? Or everything done with these commands must be done by root?

Last edited by dedec0; 05-14-2018 at 06:39 AM.
 
Old 05-14-2018, 11:05 AM   #12
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
I didn't read you used SetEnv in .htaccess in your previous posts, sorry...

Put these lines at top of .htaccess
Code:
SetEnv DUMMY bla
SetEnv TZ America/Sao_Paulo
Save it, then create a infos.php file in your ~/public_html directory with content:
PHP Code:
<?php phpinfo(); ?>
Save it

No go to your url: http://blabla.insomnia247.nl/infos.php
Do you see the 2 variables you set in .htaccess at Apache Environment table?

Last edited by keefaz; 05-14-2018 at 04:07 PM.
 
1 members found this post helpful.
Old 05-15-2018, 07:01 PM   #13
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Question

Quote:
Originally Posted by keefaz View Post
I didn't read you used SetEnv in .htaccess in your previous posts, sorry...

Put these lines at top of .htaccess
Code:
SetEnv DUMMY bla
SetEnv TZ America/Sao_Paulo
Save it, then create a infos.php file in your ~/public_html directory with content:
PHP Code:
<?php phpinfo(); ?>
Save it

No go to your url: http://blabla.insomnia247.nl/infos.php
Do you see the 2 variables you set in .htaccess at Apache Environment table?
Thank you for these detailed instructions. Sometimes there are important details we may be missing.

Before, I did use SetEnv in .htaccess changes. Now I will edit one of my previous posts with that detail. I thought it was not important to say that, so I kept for me, assuming it would be the only way to use .htaccess for what I wanted.

I just did those steps, and now I have the following situations in 3 windows:

- window 1: an open browser tab, with my infos.php loaded

- window 2: another open browser tab, showing my remote nf folder loaded

- window 3: an ssh me@server session open in a terminal, where I just did the command 'ls -l public_html/nf'

These windows have: the shown enviromanet variables are shown with the variables we set in .htaccess; the "Last modified" dates are correct, but times are incremented 5 hours; the dates and times shown in terminal are correct - which is different from what is shown in the browser. I made sure to reload the browser windows, in a way to avoid using any local cache of previous situations.

What (or where) is the problem, then?

Last edited by dedec0; 05-15-2018 at 08:07 PM.
 
Old 05-15-2018, 07:38 PM   #14
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Yes, no matter how you change the timezone variable environment, apache seems to stick with the system timezone...

Maybe a workaround would be to "fake" the apache directory listing page for your images using php and mimic the default page visual...
Then you could set any timezone value you want to display the last modification dates
 
Old 05-15-2018, 08:05 PM   #15
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by keefaz View Post
Yes, no matter how you change the timezone variable environment, apache seems to stick with the system timezone...
Yes. Pretty much that. Do you (and others reading this thread) think that all of the facts, in the context we worked and tested, are reasons to submit a bug in Apache? I even wonder why that did not already happened.

Quote:
Originally Posted by keefaz View Post
Maybe a workaround would be to "fake" the apache directory listing page for your images using php and mimic the default page visual...
Then you could set any timezone value you want to display the last modification dates
Yes. That is easy. I would simply save the rendered page, edit and upload it as index.html, so it is not necessarily visible for who opens that folder's page.

For the same idea, if someone knows a simple and easy to use (enough to what I want!) PHP script for listing files, please point. I imagine there should be a lot of those. But searching, examining and chosing, may take more time than making a (possibly) "fake solution", like we said.

Last edited by dedec0; 05-16-2018 at 07:21 AM.
 
  


Reply

Tags
apache php php.ini



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
TimeZone Problem shipon_97 Linux - Newbie 10 05-13-2015 09:35 AM
[SOLVED] Possibly a small bug in gvfs slackbuild I found... yars Slackware 2 11-21-2014 12:51 AM
is changing my server's timezone really this difficult? sneakyimp Linux - Server 2 11-02-2012 02:27 AM
TimeZone problem MikeyCarter Fedora 2 03-26-2007 03:16 PM
timezone problem Lord Zoltar Linux - General 5 09-13-2004 10:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration