I am experimenting with setting up an Apache server and running some perl scripts on it, but I'm running into some issues with my Apache and Perl config.
Initially, I was getting a 500 server error when trying to run a cgi script, and the error log showed that Apache was looking in the wrong #INC for a module I was running.
So, in httpd.conf, I added this line:
SetEnv PERL5LIB /Users/rasha/.plenv/versions/5.34.0/lib/perl5/site_perl/5.34.0/darwin-2level:/Users/rasha/.plenv/versions/5.34.0/lib/perl5/site_perl/5.34.0:/Users/rasha/.plenv/versions/5.34.0/lib/perl5/5.34.0/darwin-2level:/Users/rasha/.plenv/versions/5.34.0/lib/perl5/5.34.0
which I got by running: perl -e 'print join "\n", #INC;'
Now I am still getting a 500 server error, but with a different error message:
[Tue Feb 22 14:24:32.919661 2022] [cgi:error] [pid 35434] [client 127.0.0.1:55187] AH01215: Can't load '/Users/rasha/.plenv/versions/5.34.0/lib/perl5/site_perl/5.34.0/darwin-2level/auto/List/Util/Util.bundle' for module List::Util: dlopen(/Users/rasha/.plenv/versions/5.34.0/lib/perl5/site_perl/5.34.0/darwin-2level/auto/List/Util/Util.bundle, 0x0001): symbol not found in flat namespace '_PL_DBsub' at /Users/rasha/.plenv/versions/5.34.0/lib/perl5/5.34.0/XSLoader.pm line 96.: /usr/local/var/www/cgi-bin/test
The test script I am trying to run:
#!/usr/bin/env perl
use strict;
use warnings;
use DBI;
use CGI qw(:standard);
my ($dbh, $sth, $count);
$dbh = DBI->connect("DBI:mysql:host=localhost;database=xxxx",
"xxxx", "xxxx",
{PrintError => 0, RaiseError => 1});
$sth = $dbh->prepare("Select name, wins, losses from teams");
$sth->execute;
print header, start_html("team data");
$count = 0;
while (my #val = $sth->fetchrow_array) {
print p (sprintf ("name = %s, wins = %d, losses = %d\n", $val[0], $val[1], $val[2]));
$count++;
};
print p("$count rows total"), end_html;
$sth->finish;
$dbh->disconnect;
Does anyone have any ideas what the issue might be?
Trying to implement fail2ban on a Linux Mint 17.1 and cant seem to get it to ban me after multiple login attempts against apache-auth.
I followed this guide to get started.
I think its a problem with the apache-auth regex but cant get it right.
jail.local
[apache]
enabled = true
port = 80,443
filter = apache-auth
logpath = /var/log/apache2/*error.log
maxretry = 3
bantime = 600
##ignoreip = 192.168.3.70
##To block the remote host that is trying to request suspicious URLs, use the below jail.
[apache-overflows]
enabled = true
port = http,https
filter = apache-overflows
logpath = /var/log/apache2/*error.log
maxretry = 3
bantime = 600
ignoreip = 192.168.3.70
##To block the remote host that is trying to search for scripts on the website to execute, use the below jail.
[apache-noscript]
enabled = true
port = http,https
filter = apache-noscript
logpath = /var/log/apache2/*error.log
maxretry = 3
bantime = 600
ignoreip = 192.168.3.70
##To block the remote host that is trying to request malicious bot, use below jail.
[apache-badbots]
enabled = true
port = http,https
filter = apache-badbots
logpath = /var/log/apache2/*error.log
maxretry = 3
bantime = 600
ignoreip = 192.168.3.70
##To stop DOS attack from remote host.
[http-get-dos]
enabled = true
port = http,https
filter = http-get-dos
logpath = /var/log/apache*/access.log
maxretry = 400
findtime = 400
bantime = 200
##ignoreip = 192.168.3.70
action = iptables[name=HTTP, port=http, protocol=tcp]
apache-auth.conf
[INCLUDES]
before = apache-common.conf
[Definition]
failregex = ^%(_apache_error_client)s (AH01797: )?client denied by server configuration: (uri )?\S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01617: )?user .*? authentication failure for "\S*": Password Mismatch(, referer: \S+)?$
^%(_apache_error_client)s (AH01618: )?user .*? not found(: )?\S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01614: )?client used wrong authentication scheme: \S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH\d+: )?Authorization of user \S+ to access \S* failed, reason: .*$
^%(_apache_error_client)s (AH0179[24]: )?(Digest: )?user .*?: password mismatch: \S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH0179[01]: |Digest: )user `.*?' in realm `.+' (not found|denied by provider): \S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01631: )?user .*?: authorization failure for "\S*":(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01775: )?(Digest: )?invalid nonce .* received - length is not \S+(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01788: )?(Digest: )?realm mismatch - got `.*?' but expected `.+'(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01789: )?(Digest: )?unknown algorithm `.*?' received: \S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01793: )?invalid qop `.*?' received: \S*(, referer: \S+)?\s*$
^%(_apache_error_client)s (AH01777: )?(Digest: )?invalid nonce .*? received - user attempted time travel(, referer: \S+)?\s*$
apache-common.conf
_apache_error_client = \[[^]]*\] \[(error|\S+:\S+)\]( \[pid \d+:\S+\d+\])? \[client <HOST>(:\d{1,5})?\]
/var/log/apache2/error.log
[Thu Aug 02 23:03:42.143209 2018] [auth_basic:error] [pid 8025] [client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:43.216097 2018] [auth_basic:error] [pid 8025] [client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:44.124570 2018] [auth_basic:error] [pid 8025][client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:45.104747 2018] [auth_basic:error] [pid 8025][client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:46.001161 2018] [auth_basic:error] [pid 8025][client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:46.871802 2018] [auth_basic:error] [pid 8025][client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
[Thu Aug 02 23:03:47.843740 2018] [auth_basic:error] [pid 8025][client 192.168.3.60:54788] AH01618: user aaa not found: /SEC/test.php
As I said I think the problem is in the regex, since the http-get-dos jail worked fine. The regex for apache-common.conf doesn't look right since my log files seem to follow a different standard, BUT I'm not sure if that's true or how to properly format the regex.
ANy help is appreciated.
Found my problem
I had to change the line in apache-common.conf to the following;
_apache_error_client = \[[^]]*\] \[(error|\S+:\S+)\]( \[pid \d+\])? \[client <HOST>(:\d{1,5})?\]
The difference being in the PID section. I used Regex101 to work the expression until it matched.
I have problems wsgi module and do not understand why.
I installed Apache, remove MAMP because it gave me too many problems.
I have configured the port and my page loads fine.
Install MYSQL load my script and all is well.
Install the Python-MySQL connector and make the connection and actually connects.
but when I access the site and I want to register strip mistake, nose if it reaches the database or not.
Someone help me understand what happens.
Attached codes.
httpd.conf
ServerRoot "/usr/local/apache2"
Listen 8080
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule unixd_module modules/mod_unixd.so
#LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule alias_module modules/mod_alias.so
LoadModule wsgi_module modules/mod_wsgi.so
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin usuario#usuario.com
ServerName localhost:8080
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/Users/usuario/Sites/usuariocloud/client"
<Directory "/Users/usuario/Sites/usuariocloud/client">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/Users/usuario/Sites/usuariocloud/server/"
</IfModule>
<IfModule cgid_module>
</IfModule>
Alias /cgi-bin /Users/usuario/Sites/usuariocloud/server/
<Location /cgi-bin>
SetHandler wsgi-script
Options +ExecCGI
</Location>
#WSGIScriptAlias /cgi-bin /Users/usuario/Sites/usuariocloud/server/
<Directory "/Users/usuario/Sites/usuariocloud/server/">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
</IfModule>
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
Include conf/extra/httpd-ssl.conf
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
controller.wsgi
# Library Imports
import json, cgi, sys, os
path = os.path.dirname(__file__)
if path not in sys.path:
sys.path.append(path)
# Own Libraries
from petition_solver.solver import Solver
def application(env, resp):
response = { "response": "fail",
"error" : """Expecting ?Json=
{
"function":"functionName",
"entity":"entityName",
"params":
{
"param1":"value1",
"param2":"value2",
"paramn":"value n"
}
}""".replace('\r', ' ').replace('\n', ' ').replace('\t', '')
}
# Read Params
form = cgi.FieldStorage(fp=env['wsgi.input'], environ=env)
if form:
userAgent = env["HTTP_USER_AGENT"] if "HTTP_USER_AGENT" in env else ""
param_json = form['json'].value
petition = json.loads(param_json)
if('file' in form and "params" in petition):
param_file = form['file']
if(isinstance(param_file, list)):
petition['params']['files'] = []
for f in param_file:
filename = unicode(f.filename, 'utf-8')
petition['params']['files'].append({"originalName" : filename, "file" : f.file.read()})
else:
petition['params']['file'] = param_file.file.read()
filename = unicode(param_file.filename, 'utf-8')
petition['params']['originalName'] = filename
solver = Solver()
response = solver.solvePetition(petition, userAgent=userAgent)
if (response and "download" in response and response["download"]):
detail = response["file"]["storage"]
mime = detail["mime"].decode('utf-8')
name = detail["originalName"].encode("ascii", 'replace')
data = detail["file"]
resp('200 OK',[('Content-type', '{0}'.format(mime)),('Content-disposition', 'attachment; filename*=UTF-8''{0}; filename={0}'.format(name))])
yield data
else:
resp('200 OK',[('Content-type', 'text/html;charset=utf-8')])
yield json.dumps(response)
solver.py
#solver module
#class Solver
from log import Log
from error import NotValidPetitionError
class Solver:
userId = -1
def solvePetition(self, petition, petitionId=0, userAgent=None):
lg = Log.Instance()
if("function" not in petition or "entity" not in petition):
response = {"response":"fail", "error" : "{0}".format(NotValidPetitionError())}
lg.logError("Not a valid petition found", lg.SOLVER_LEVEL)
return response
innerPetition = self._getCopy(petition)
function = innerPetition["function"]
entityName = innerPetition["entity"]
params = innerPetition["params"] if "params" in innerPetition else {}
key = innerPetition["key"] if "key" in innerPetition else ""
#petitionId = petitionId if petitionId else self._getPetitionId()
#lg.logDebug("Received petition {0} ".format(self._getJsonRepr(petition)), lg.SOLVER_LEVEL, petitionId)
entity = None
entityType = None
if(entityName == "user"):
from entities.user import User
entityType = User
params["userAgent"] = userAgent
elif(entityName == "group"):
from entities.group import Group
entityType = Group
elif(entityName == "tag"):
from entities.tag import Tag
entityType = Tag
elif(entityName == "attribute"):
from entities.attribute import Attribute
entityType = Attribute
elif(entityName == "template"):
from entities.template import Template
entityType = Template
elif(entityName == "directory"):
from entities.directory import Directory
entityType = Directory
elif(entityName == "staticCatalog"):
from entities.staticCatalog import StaticCatalog
entityType = StaticCatalog
elif(entityName == "dynamicCatalog"):
from entities.dynamicCatalog import DynamicCatalog
entityType = DynamicCatalog
elif(entityName == "document"):
from entities.document import Document
entityType = Document
elif(entityName == "file"):
from entities.file import File
entityType = File
elif(entityName == "inbox"):
from entities.inbox import Inbox
entityType = Inbox
elif(entityName == "storageFile"):
from entities.storageFile import StorageFile
entityType = StorageFile
elif(entityName == "structure"):
from entities.structure import Structure
entityType = Structure
elif(entityName == "dictionaryCatalog"):
from entities.dictionaryCatalog import DictionaryCatalog
entityType = DictionaryCatalog
elif(entityName == "patternTemplate"):
from entities.patternTemplate import PatternTemplate
entityType = PatternTemplate
if petitionId:
petitionId = petitionId
valueReturned = self._operationsManager(params, petitionId, key, entityType, entityName, function, False, petition)
else:
petitionId = self._getPetitionId()
valueReturned = self._operationsManager(params, petitionId, key, entityType, entityName, function, True, petition)
lg.logDebug("Received petition {0} ".format(self._getJsonRepr(petition)), lg.SOLVER_LEVEL, petitionId)
try:
entity = entityType(params, key, petitionId)
response = entity.process(function)
pet_id = self._getPetition(entity, petitionId)
queryUpdate = self._getDBTemplate("UPDATE_OPERATION_STATUS").format(pet_id)
newId = entity._resolveUpdate(queryUpdate, audit=False)
if newId > 0:
lg.logDebug("UPDATE_PETITION_ID: {0} ".format(pet_id), lg.SOLVER_LEVEL, petitionId)
except Exception as e:
response = self._manageError(e, petition, petitionId)
finally:
del (entity)
del (innerPetition)
lg.logDebug("Response to petition is {0}".format(self._getJsonRepr(response)), lg.SOLVER_LEVEL, petitionId)
response["petition"] = self._getJsonWOFile(petition)
return response
def _getJsonRepr(self, json):
j = self._getJsonWOFile(json["file"]) if "file" in json else self._getJsonWOFile(json)
return "{0}".format(j)
def _getJsonWOFile(self, json):
needsCopy = json and "file" in json or (
"params" in json and json["params"] and (
"file" in json["params"] or "files" in json["params"]
)
) or "storage" in json
if needsCopy:
copy = self._getCopy(json)
if ("file" in copy):
copy["file"] = "FILE DATA OMITTED" if copy["file"] else "EMPTY FILE"
if ("storage" in copy):
if ("file" in copy["storage"]):
copy["storage"]["file"] = "FILE DATA OMITTED" if copy["storage"]["file"] else "EMPTY FILE"
if("params" in copy):
if("files" in copy["params"]):
for f in copy['params']["files"]:
f["file"] = "FILE DATA OMITTED" if f["file"] else "EMPTY FILE"
if("file" in copy["params"]):
copy["params"]["file"] = "FILE DATA OMITTED" if copy["params"]["file"] else "EMPTY FILE"
return copy
else:
return json
def _getCopy(self, json):
import copy
copy = copy.deepcopy(json)
return copy
def _manageError(self, err, petition, petitionId):
from error import usuarioError
innerError = err if isinstance(err, usuarioError) else usuarioError()
lg = Log.Instance()
lgMethod = lg.logWarning if innerError.code < 400 else lg.logError
lgMethod("{0} found while resolving petition {1}".format( str(innerError) , petitionId), lg.SOLVER_LEVEL, petitionId)
response = {
"response":"fail",
"error" : {
"code" : "{0}".format(innerError.code),
"message" : str(innerError)
}
}
return response
def _getPetitionId(self):
import uuid
uuidObj = uuid.uuid4()
return uuidObj.hex
def _getDBTemplate(self, templateName):
dbTemplateProvider = None
if not dbTemplateProvider:
from db_template_provider import DBTemplateProvider
dbTemplateProvider = DBTemplateProvider.Instance()
return dbTemplateProvider.getDBTemplate(templateName)
def _findFunction(self, functionName, entityType):
queryFunction = self._getDBTemplate("FIND_FUNCTION_ID").format(functionName)
rows = entityType._resolveQuery(queryFunction, function=functionName, audit=False)
if rows:
functionId = rows[0]
fcId = functionId[0]
return fcId
return 0
def _findEntity(self, entityName, entityType):
queryEntity = self._getDBTemplate("FIND_ENTITY_ID").format(entityName)
rows = entityType._resolveQuery(queryEntity, audit=False)
if rows:
entityId = rows[0]
entId = entityId[0]
return entId
return 0
def _addOperation(self, function, entityName, entity, newId, typeOper, petitionId):
lg = Log.Instance()
functionId = self._findFunction(function, entity)
entityId = self._findEntity(entityName, entity)
queryOperation = ""
if typeOper:
queryOperation = self._getDBTemplate("CREATE_OPERATIONS").format(newId, functionId, entityId, 0, 2)
else:
queryOperation = self._getDBTemplate("CREATE_OPERATIONS").format(newId, functionId, entityId, 0, 1)
entity._resolveUpdate(queryOperation, False)
lg.logDebug("Operation Added: {0}".format(newId), lg.SOLVER_LEVEL, petitionId)
def _getPetition(self, entityType, petitionId):
queryPetition = self._getDBTemplate("FIND_PETITION_ID").format(petitionId)
required = []
rows = entityType._resolveQuery(queryPetition, audit=False)
if rows:
petId = rows[0]
petId_ = petId[0]
return petId_
return 0
def _operationsManager(self, params, petitionId, key, entityType, entityName, function, typeOper, petition):
entity = None
newId = 0
lg = Log.Instance()
try:
entity = entityType(params, key, petitionId)
if typeOper:
jsonStr = self._getJsonRepr(petition).replace("\'", "\\\'")
userName = self._findUserName(entity, key)
if self.userId != -1:
queryRegistry = self._getDBTemplate("CREATE_REGISTRY_PETITIONS").format(petitionId, jsonStr, "final", 0, self.userId, userName, 5)
lg.logDebug("REGISTRY QUERY: {0}".format(jsonStr), lg.SOLVER_LEVEL, petitionId)
newId = entity._resolveUpdate(queryRegistry, audit=False)
if newId > 0:
lg.logDebug("Petition Added: {0}".format(jsonStr), lg.SOLVER_LEVEL, petitionId)
self._addOperation(function, entityName, entity, newId, True, petitionId)
else:
return False
return True
else:
return False
else:
newId = self._getPetition(entity, petitionId)
self._addOperation(function, entityName, entity, newId, False, petitionId)
except Exception as e:
lg.logError(self._manageError(e, petition, petitionId), lg.SOLVER_LEVEL, petitionId)
return False
def _findUserName(self, entity, key):
userTemplate = self._getDBTemplate("QUERY_USER_BY_KEY").format(key)
rowsId = entity._resolveQuery(userTemplate)
if rowsId:
self.userId = rowsId[0][0]
nameTemplate = self._getDBTemplate("QUERY_USERNAME").format(self.userId)
rowsUsr = entity._resolveQuery(nameTemplate)
if rowsUsr:
userName = rowsUsr[0][0]
return userName
return None
and the error is
and the logs are the nexts
[Thu Jun 18 12:04:37.413641 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] mod_wsgi (pid=2048): Exception occurred processing WSGI script '/Users/usuario/Sites/usuariocloud/server/controller.wsgi'., referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413692 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] Traceback (most recent call last):, referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413719 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] File "/Users/usuario/Sites/usuariocloud/server/controller.wsgi", line 53, in application, referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413759 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] response = solver.solvePetition(petition, userAgent=userAgent), referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413775 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] File "/Users/usuario/Sites/usuariocloud/server/petition_solver/solver.py", line 13, in solvePetition, referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413795 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] lg = Log.Instance(), referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413805 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] File "/Users/usuario/Sites/usuariocloud/server/petition_solver/singleton.py", line 34, in Instance, referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413823 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] self._instance = self._decorated(), referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413833 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] File "/Users/usuario/Sites/usuariocloud/server/petition_solver/log.py", line 24, in __init__, referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413849 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] os.makedirs(directory), referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413859 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs, referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413878 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] mkdir(name, mode), referer: http://localhost:8080/\
[Thu Jun 18 12:04:37.413897 2015] [wsgi:error] [pid 2048:tid 4367495168] [client ::1:49302] OSError: [Errno 13] Permission denied: '//logs', referer: http://localhost:8080/\
[Thu Jun 18 12:54:13.192665 2015] [mpm_worker:notice] [pid 2046:tid 140735125234432] AH00295: caught SIGTERM, shutting down\
Your code is trying to write to a log file using a relative path. You cannot do that as the current working directory of the process will be '/' and not where your code is. See:
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Application_Working_Directory
Use an absolute path explicitly, or calculate it relative to the code location by using os.path.dirname(__file__) as a base.
I worked with Phalcon and Volt under WAMP. Recently we moved to another dev environment (CentOS) and there I have PHP 5.5.17 with latest Phalcon build (I compiled and tested 2 versions lower as well).
Now, when Volt tries to compile template with custom function, it crashes (PHP process). The same is
about custom filters.
Error log of Apache
[Tue Sep 30 06:06:24.809476 2014] [proxy_fcgi:error] [pid 31199:tid 140596014397184] (104)Connection reset by peer: [client 10.0.2.2:53931] AH01075: Error dispatching request to :3080:
[Tue Sep 30 06:06:27.216226 2014] [proxy_fcgi:error] [pid 31200:tid 140596161255168] [client 10.0.2.2:53941] AH01067: Failed to read FastCGI header
[Tue Sep 30 06:06:27.216249 2014] [proxy_fcgi:error] [pid 31200:tid 140596161255168] (104)Connection reset by peer: [client 10.0.2.2:53941] AH01075: Error dispatching request to :3080:
PHP error log
[30-Sep-2014 06:06:27] WARNING: [pool www] child 32519 exited on signal 11 (SIGSEGV - core dumped) after 204.725812 seconds from start
[30-Sep-2014 06:06:27] NOTICE: [pool www] child 32529 started
PHP code looks like
$di->set('view', function () use ($config) {
$view = new View();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(
'.volt' => function ($view, $di) use ($config) {
$volt = new VoltEngine($view, $di);
$volt->setOptions(array(
'compiledPath' => $config->application->cacheDir,
'compiledSeparator' => '_',
'compileAlways' => $config->application->debug
));
$compiler = $volt->getCompiler();
$compiler->addFunction(
'last',
function ($resolvedArgs) use ($compiler) {
return 'array_pop('. $resolvedArgs .')';
}
);
return $volt;
}
));
return $view;
}, true);
And in Volt for example
{{ last(['1', '2', '3']) }}
And I really stuck on this problem, because I have pretty a lot of custom functions and I do need them. Tried to debug it, but, as soon as volt tried to parse line with custom function, process die.
Phalcon bug submitted. Solution: totally disable xdebug for current build. More here: https://github.com/xdebug/xdebug/pull/120
I have a live website and staging version set up on the same virtual server. The live site uses Varnish and no authentication, the staging site bypasses Varnish but uses digest authentication. In my VCL file I have this:
sub vcl_recv {
if (req.http.Authorization || req.http.Authenticate) {
return(pass);
}
if (req.http.host != "live.site.com") {
return(pass);
}
I'm seeing a problem on the staging site, whereby resources with any querystring are not being served - in Firebug I see '400 Bad request' and in the Apache logs this:
[Fri Sep 19 11:13:03 2014] [error] [client 127.0.0.1] Digest: uri mismatch -
</wp-content/plugins/jetpack/modules/wpgroho.js?ver=3.9.2> does not match
request-uri </wp-content/plugins/jetpack/modules/wpgroho.js>, referer:
http://stage.site.com/
What have I done wrong, does anyone know how to fix this?
Thanks,
Toby
Ok, found it, here's what I found (in case it helps anyone else):
I do, of course, have a section in my Varnish VCL that removes querystrings from static files, to aid caching:
if (req.request ~ "^(GET|HEAD)$" && req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)(\?.*)?$") {
if (req.url ~ "nocache") {
return(pass);
}
set req.url = regsub(req.url, "\?.*$", "");
unset req.http.Cookie;
set req.grace = 2m;
return(lookup);
}
This clearly conflicts with digest authentication, so I will have to revisit that part of the VCL.
UPDATE I just changed the second conditional to:
if (req.http.Authorization || req.http.Authenticate ||
req.url ~ "nocache") {
return(pass);
}