I am "managing" some file's version by setting their last modified date manually when serving them with apache, like so
<Directory />
(...)
Header set Last-modified "Tue, 01 Jan 2013 00:00:00 GMT"
(...)
</Directory>
This already works fine.
If the client honors the cache standard, it should send me the If-Modified-Since header in the next request, where I'd return 304 instead of 200.
Is there any way to accomplish the following without too much hassle? (I don't need fancy processing or anything, the most hardcoded way will work ok for me)
I need something like this (it's obviously in pseudo code):
<HeaderMatch If-Modified-Since>
(...)
If Equals "Tue, 01 Jan 2013 00:00:00 GMT"
Header set Code 304
Else
// Process Directory section
</HeaderMatch>
Any ideas/workarounds?
Well, it was easy.
Using mod_rewrite, I ended up with this
RewriteEngine on
RewriteCond %{HTTP:if-modified-since} "Tue, 01 Jan 2013 00:00:00 GMT" [NC]
RewriteRule .* . [R=304,L]
Related
I started saving redis-db snapshot by calling BGSAVE command in redis-cli.
It has started running but I keep getting these errors in the logs
[30853] 27 Jan 07:18:41.129 # Background saving error
[30853] 27 Jan 07:18:47.043 * 1 changes in 900 seconds. Saving...
[30853] 27 Jan 07:18:47.058 * Background saving started by pid 13204
[13204] 27 Jan 07:18:47.058 # Failed opening .rdb for saving: Permission denied
[30853] 27 Jan 07:18:47.158 # Background saving error
[30853] 27 Jan 07:18:53.070 * 1 changes in 900 seconds. Saving...
[30853] 27 Jan 07:18:53.085 * Background saving started by pid 13207
[13207] 27 Jan 07:18:53.085 # Failed opening .rdb for saving: Permission denied
[30853] 27 Jan 07:18:53.186 # Background saving error
[30853] 27 Jan 07:18:59.098 * 1 changes in 900 seconds. Saving...
[30853] 27 Jan 07:18:59.113 * Background saving started by pid 13210
[13210] 27 Jan 07:18:59.114 # Failed opening .rdb for saving: Permission denied
[30853] 27 Jan 07:18:59.213 # Background saving error
looks like the redis BGSAVE command is running indefinitely. How to stop this.
Also I tried checking for process pid by ps -aux| grep redis command.
13196 pts/11 S+ 0:00 grep --color=auto redis
30853 ? Ssl 1292:57 /usr/bin/redis-server *:6379
There is no process to kill.
EDIT: These are the permissions to redis folder and dump.rdb file
f: /var/lib/redis
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root lib
drwxr-xr-x redis redis redis
f: /var/lib/redis/dump.rdb
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root lib
drwxr-xr-x redis redis redis
-rw-rw-rw- redis redis dump.rdb
EDIT2: Got the answer. The problem was somehow the config parameters are changed. The dbfilename and dir values are changed.
Set these values to original through CONFIG SET command and now its working fine. Adding in-case somebody has same problem.
But the question is how did they change. Did this happen to anybody else?
Help me
Thanks
You can either try and fix the file permissions error (does the default save location exist and does redis have permission to write to it?) or you can disable saving with:
config set save ""
I have a script that I run manually every hour in my Laravel that's under this path:
/var/www/name/storage/scripts/getListOfClassesFromSubjects.pl
What I normally do is, I cd to /scripts/, and I manually run:
./getListOfClassesFromSubjects.pl
And the script works fine.
Today, I setup a crontab to automate this (obviously).
0,30 * * * * /var/www/name/storage/scripts/getListOfClassesFromSubjects.pl >> /var/www/name/storage/logs/schedulizer.log 2>&1
Within my logs are this:
DBD::SQLite::db prepare failed: no such table: subject_urls at /var/www/loop/storage/scripts/getListOfClassesFromSubjects.pl line 56.
Which is an anomaly because when I run the script manually, it's fine.
This is my database's permissions:
-rw-r--r-- 1 root root 11750400 Aug 4 12:30 database.sqlite
So I'm thinking this is the issue with the rwx permissions, so I changed the DB to 755:
-rwxr-xr-x 1 root root 11750400 Aug 4 12:30 database.sqlite
Still the same issue
For the path to the database, your code uses a relative path that assumes the current directory is the directory in which the script resides. It is not.
Instead of
"../database.sqlite"
use
use FindBin qw( $RealBin );
"$RealBin/../database.sqlite"
or
use FindBin qw( $RealBin );
chdir($RealBin);
"../database.sqlite"
after opening http 127.0.0.1 in the browser it displays info:
It works! This is the default web page for this server. The web server
software is running but no content has been added, yet.
The point is I have added files to the DocumentRoot catalog
Things i changed:
/etc/apache2/envvars
from
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
to
export APACHE_RUN_USER=chiny
export APACHE_RUN_GROUP=chiny
file /etc/apache2/sites-enabled/000-default.conf looks:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/chiny/Pulpit/lab
<Directory /home/chiny/Pulpit/lab/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
Allow from all
</Directory>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
my DocumentRoot where i have my html files
root#chiny-HP-Compaq-dc7100-CMT-DX438AV:/home/chiny/Pulpit/lab# ls -l /home/chiny/Pulpit/lab
razem 60
-rwxrwxr-x 1 chiny chiny 3096 sty 18 2013 10.html
-rwxrwxr-x 1 chiny chiny 2562 sty 18 2013 11.html
-rwxrwxr-x 1 chiny chiny 3010 sty 18 2013 12.html
-rwxrwxr-x 1 chiny chiny 3045 sty 18 2013 1.html
-rwxrwxr-x 1 chiny chiny 3016 sty 18 2013 2.html
-rwxrwxr-x 1 chiny chiny 2772 sty 18 2013 3.html
-rwxrwxr-x 1 chiny chiny 2814 sty 18 2013 4.html
-rwxrwxr-x 1 chiny chiny 2638 sty 18 2013 5.html
-rwxrwxr-x 1 chiny chiny 2794 sty 18 2013 6.html
-rwxrwxr-x 1 chiny chiny 2722 sty 18 2013 7.html
-rwxrwxr-x 1 chiny chiny 2591 sty 18 2013 8.html
-rwxrwxr-x 1 chiny chiny 2620 sty 18 2013 9.html
-rw-r--r-- 1 chiny chiny 177 sty 18 18:37 index.html
-rwxrwxr-x 1 chiny chiny 0 sty 18 14:43 plik
-rwxrwxr-x 1 chiny chiny 1711 sty 17 2013 styles.css
-rwxrwxr-x 1 chiny chiny 3181 sty 17 2013 w3schoolslogo.gif
also /home/chiny/Pulpit/lab is owned and group by chiny
drwxrwsr-x 2 chiny chiny 4096 sty 18 18:37 lab
nothing changed in apache2.conf
after restarting apache this info:
root#chiny-HP-Compaq-dc7100-CMT-DX438AV:/home/chiny/Pulpit# /etc/init.d/apache2 restart
* Restarting web server apache2 AH00557: apache2: apr_sockaddr_info_get() failed for chiny-HP-Compaq-dc7100-CMT-DX438AV
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
it appeared that index.html was a orginal file from var/www that i copied to my documentroot. and content of this file is exactly this message:"It works! This is the default web page for this server. The web server software is running but no content has been added, yet."
I have changed a CSS file, then committed it. Then updated it on another server. But the time of the updated file is time of the SVN update.
Is it possible to get the "Real" time - the one when the file change was saved on the first server?
Output of stat:
stat myfile.css
File: `myfile.css'
Size: 29731 Blocks: 64 IO Block: 4096 regular file
Device: fe11h/65041d Inode: 4411064 Links: 1
Access: (0660/-rw-rw----) Uid: ( 1118/ valk) Gid: ( 1010/developers)
Access: 2012-02-19 18:04:50.000000000 +0200
Modify: 2012-02-19 18:04:50.000000000 +0200
Change: 2012-02-19 18:04:50.000000000 +0200
Thanks
You can also configure Subversion to use commit-times by editing the
Subversions config file located at ~/.subversion/config (UNIX, Linux) respectively
%APPDATA%\subversion(Windows)
There are these lines (around line 100 in unmodified file):
### Set use-commit-times to make checkout/update/switch/revert
### put last-committed timestamps on every file touched.
# use-commit-times = yes
Just remove the "#" from the last displayed line.
Note this setting is active for all your workingcopies on this machine
Use svn info. It will give you something like:
Path: /XXXXX/myfile.css
Name: myfile.css
URL: svn+ssh://XXXXX/current/myfile.css
Repository Root: svn+ssh://XXXXX
Repository UUID: ed4dba2c-4d18-0410-83c2-a4e2ddc248c7
Revision: 3697
Node Kind: file
Schedule: normal
Last Changed Author: ocharlesworth
Last Changed Rev: 3654
Last Changed Date: 2011-11-22 00:08:53 +0000 (Tue, 22 Nov 2011)
Text Last Updated: 2011-12-15 11:39:55 +0000 (Thu, 15 Dec 2011)
Checksum: 395d2b79f528cccb58017a87a76f2e50
I am trying to streamline a server of a clients. After downloading the access_log files, I noticed that there were an awful lot of entries that looked like:
::1 - - [11/May/2009:23:21:16 +0100] "GET / HTTP/1.0" 403 5043 "-" "Apache/2.2.3 (CentOS) (internal dummy connection)"
I have also checked the httpd.conf file, and I have seen the following settings:
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers 8
MinSpareServers 8
MaxSpareServers 13
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 50
</IfModule>
# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
I've been reading that I need to set MaxSpareServes to a value greater than MinSpareServers. Opinions are greatly appreciated.
Kindest Regards.
Tom
As far as I know it's nothing to worry about, you can just stop them getting into the log if you want by using the info from the link given already by Andri...
If you wish to exclude them from your
log, you can use normal
conditional-logging techniques. For
example, to omit all requests from the
loopback interface from your logs, you
can use
SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
and then add env=!loopback to
the end of your CustomLog directive.