我正在比较Node.js(0.5.1-pre)和Apache(2.2.17)的性能,这是一个非常简单的场景 - 提供文本文件.
这是我用于节点服务器的代码:
var http = require('http')
, fs = require('fs')
fs.readFile('/var/www/README.txt',
function(err, data) {
http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'})
res.end(data)
}).listen(8080, '127.0.0.1')
}
)
Run Code Online (Sandbox Code Playgroud)
对于Apache,我只使用Ubuntu 11.04的默认配置
使用针对Apache的以下参数运行Apache Bench时
ab -n10000 -c100 http://127.0.0.1/README.txt
Run Code Online (Sandbox Code Playgroud)
我得到以下运行时:
Time taken for tests: 1.083 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 27630000 bytes
HTML transferred: 24830000 bytes
Requests per second: 9229.38 [#/sec] (mean)
Time per request: 10.835 [ms] (mean)
Time per request: 0.108 [ms] (mean, across …Run Code Online (Sandbox Code Playgroud) 我在Ubuntu 10.04上使用Apache2完成了Phusion Passenger设置.每当我重新启动Apache服务器时,我收到以下错误消息,并且Rails应用程序未运行.
[error] *** Passenger could not be initialized because of this error: Unable to start the Phusion Passenger watchdog because its executable (/usr/lib/phusion-passenger/agents/PassengerWatchdog) does not exist. This probably means that your Phusion Passenger installation is broken or incomplete, or that your 'PassengerRoot' directive is set to the wrong value. Please reinstall Phusion Passenger or fix your 'PassengerRoot' directive, whichever is applicable.
Run Code Online (Sandbox Code Playgroud) 我在ubuntu中使用apache2为我的网页创建了一个保护.现在我用c ++创建一个应用程序,我希望它使用Apache2用于身份验证的相同文件,但我的问题是我不知道如何解密apache2生成的密码.(也许我需要一个用于加密的密钥).
谢谢.
我几乎可以肯定是一个新手问题.我希望在写这个问题时能找到问题,但我仍然陷入困境.
我想更改Apache的DocumentRoot,但我不断收到错误消息"DocumentRoot必须是一个目录".
情况:
在httpd.conf中
DocumentRoot "/home/stave/www"
Run Code Online (Sandbox Code Playgroud)
当我重新启动时,我收到消息
Starting httpd: Syntax error on line 292 of /etc/httpd/conf/httpd.conf:
DocumentRoot must be a directory
Run Code Online (Sandbox Code Playgroud)
迄今采取的步骤:
我确保目录存在:
ls -asl /home/stave
4 drwxrwxrwx. 2 stave stave 4096 Feb 9 09:08 www
It even has a file in it "index.html", so I am very sure that the directory exists
Run Code Online (Sandbox Code Playgroud)
我认为它可能是一个特权问题(这是一个与互联网隔离的虚拟开发机器,我正在排除故障,因此我不太担心安全性),因为你可以看到我将特权设置为777.
我甚至更改了apache正在运行的用户(并确认该更改与ps一起工作)以保证特权不应成为问题.
堆栈溢出
有一些堆栈溢出答案,但大多数人说"读取错误消息.它说该目录实际上并不存在".其他人暗示最后可能会有一个尾随的斜线,这将是糟糕的.
其他网站
我发现的最有用的是这个被通知
你可能得到"DocumentRoot必须是一个目录"错误,即使它实际上是一个目录,因为SELinux扩展.运行system-config-securitylevel(或redhat-config-securitylevel)以禁用httpd的SELinux或为该目录授予SELinux权限:chcon -R -h -t httpd_sys_content_t/path/to/directory*
我的linux版本不是安全增强型Linux,所以不理解我还是尝试了它:没有效果.
现在的情况
我已经没有想法尝试,所以任何诊断问题或建议将不胜感激
我目前正在尝试找到正确的php.ini文件来编辑它并重新启动apache以便进行更改并且我很难过.
我做了什么...
我找到了三个不同的php.ini文件(不知道为什么有三个)这是我发现文件sudo找到的方法/ -name php.ini它导致了以下....
/etc/php5/cli/php.ini
/etc/php5/apache2/php.ini
/etc/php5/cgi/php.ini
Run Code Online (Sandbox Code Playgroud)
我也做了....
sudo php -i | grep 'Configuration File'
Run Code Online (Sandbox Code Playgroud)
这表明....
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
Run Code Online (Sandbox Code Playgroud)
我将所有这些(只是为了确定)改为我想要的设置.
我重启apache使用
sudo service apache2 restart
Run Code Online (Sandbox Code Playgroud)
结果...
* Restarting web server apache2
Run Code Online (Sandbox Code Playgroud)
我重新加载页面,它显示php.ini文件没有更新.
我知道这是因为我用过
echo ini_get('post_max_size');
Run Code Online (Sandbox Code Playgroud)
这被认为是改为20M,但仍然只有2M
我尝试重新启动我的计算机,认为可能会合法地停止apache服务器并使用正确的设置重新加载php.ini文件,但唉,尝试也失败了.
是否有可能存在另一个可能干扰的php.ini文件?我很茫然,很想得到一些帮助.
任何和所有的帮助非常感谢!
刚刚更新到最新的Windows 10版本(build 14316),我立即开始使用WSL,Windows子系统Linux,它应该在Windows上运行Ubuntu安装.
也许我正在尝试在其上安装Apache,但是有人请解释我为什么这是不可能的.
无论如何,在安装过程中(sudo apt-get install apache2),我在下载并正确安装依赖项后收到以下错误消息:
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: No such file or directory
runlevel:/var/run/utmp: No such file or directory
* Starting web server apache2 *
* The apache2 configtest failed.
Output of config test was:
mktemp: failed to create directory via template '/var/lock/apache2.XXXXXXXXXX': No such file or directory
chmod: missing operand after '755'
Try 'chmod --help' for more information.
invoke-rc.d: initscript apache2, action "start" failed.
Setting up ssl-cert …Run Code Online (Sandbox Code Playgroud) 我在尝试使用时收到此错误apc_store().我google了它,发现这是APC timebomb bug,并看到一些修复建议添加apc.slam_defense = Off;到php.ini.
我需要知道是否由于编程错误而发生这种情况,如果是,则如何修复它.
这是代码段:
if ($data = apc_fetch("foo")) {
$an_array = $data;
} else {
/* couple of lines */
apc_store("circles", $an_array); // This is where I get the error
}
Run Code Online (Sandbox Code Playgroud)
将在我部署的系统中频繁调用此脚本.
我希望我提供了足够的信息
提前致谢
尝试在Windows 2003上使用Apache 2.2检出特定Subversion 1.4.x存储库中的文件的用户突然开始在使用TortoiseSVN 1.4结帐时在其日志窗口中收到错误消息:
Error REPORT request failed on '/[path_to_repo]/!svn/vcc/default'
Error REPORT of '/[path_to_repo]/!svn/vcc/default': 200 OK (http://[server_name])
Run Code Online (Sandbox Code Playgroud)
这是在服务器上发生hd崩溃并随后恢复大约10个subversion存储库之后开始的.尝试工作目录协调后,只有一个存储库出现此问题.通过修改/删除隐藏的.svn目录,repo所有者将其工作目录与存储库进行协调(尽管不建议这样做).
我无法找到代表我情况的互联网上的任何内容.已还原的服务器与原始服务器完全相同,此服务器上没有其他存储库会抛出错误.任何想法1)这个错误是什么和2)如何解决它?
我正在尝试使用CakePHP应用程序.为此,我设置了一个全新的Debian安装,更新了配置并将所有内容放在/ var/www中,其中包含以下内容:
app
cake
.htaccess
index.php
vendors
Run Code Online (Sandbox Code Playgroud)
.htaccess文件包含以下内容:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ /webroot/ [L]
RewriteRule (.*) /webroot/$1 [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
如果我访问我的虚拟主机(http:// myhost /),我会看到正确的页面.但即使加载的JavaScript src="/js/validate.js"失败(它位于其中/var/www/app/webroot/js/validate.js):
[Wed Aug 26 15:45:12 2009] [error] [client 10.7.10.52] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Aug 26 15:45:12 2009] [debug] core.c(3063): [client 10.7.10.52] r->uri = /webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/webroot/js/prototype.js
[Wed Aug …Run Code Online (Sandbox Code Playgroud) 我想限制登录用户只有一个活动会话,即如果用户使用新的sessionid登录,则应终止旧会话.我已经在SO上找到了很多帮助: 这里和这里
我实现了中间件解决方案,还有一些额外的检查......
class OnlyOneUserMiddleware(object):
"""
Middleware to ensure that a logged-in user only has one session active.
Will kick out any previous session.
"""
def process_request(self, request):
if request.user.is_authenticated():
try:
cur_session_key = request.user.get_profile().session_key
if cur_session_key and cur_session_key != request.session.session_key:
# Default handling... kick the old session...
Session.objects.get(session_key=cur_session_key).delete()
if not cur_session_key or cur_session_key != request.session.session_key:
p = request.user.get_profile()
p.session_key = request.session.session_key
p.save()
except ObjectDoesNotExist:
pass
Run Code Online (Sandbox Code Playgroud)
到目前为止,这么好......在Django开发服务器(manage.py runserver)上一切正常,它踢旧会话......
...但是当使用Apache(使用mod_wsgi)时,它不起作用!
我试图找到关于此的任何信息,但到目前为止没有运气......
我发现的最接近的是这个,但它是一种"相反"的问题......
任何帮助将非常感激.
编辑:我在删除Session之前添加了一个调试打印...这是Apache的error.log的一个片段:
[Fri Jan 20 09:56:50 …Run Code Online (Sandbox Code Playgroud)