问题描述
我的服务器的Plesk下运行的CentOS所以编辑我的httpd.conf中添加一个条目Rewritelock是不是一种选择,因为我了解它。一个RewriteLock项也不能在vhost.config要么允许,所以我觉得我坚持寻找一个替代的描述下here.
My server is running CentOS under Plesk so editing my httpd.conf to add a Rewritelock entry is not an option as I understand it. A RewriteLock entry is also not allowed in a vhost.config either, so I think I'm stuck looking at an alternative as decribed here.
由于我成功地利用方法测试,这是略作修改,因为我的作品在我的vhost.conf。我还添加了我的企图锁定文件:
As a test I am successfully using this approach, which is slightly modified since my entries are in my vhost.conf. I also added my attempt at locking the file:
#!/usr/bin/env php
<?php
/* Extra lines to add to vhost.conf:
RewriteEngine On
RewriteMap tryme prg:/home/trainee/website/andy
RewriteRule (.*\.htm) ${tryme:$1}
*/
set_time_limit(0); # forever program!
$keyboard = fopen("php://stdin","r");
flock($keyboard, LOCK_EX); //lock the file
while (1) {
$line = trim(fgets($keyboard));
if (preg_match('/^(.*)\.htm$/',$line,$igot)) {
print "$igot[1].html\n";
} else {
print "$line\n";
}
}
?>
随着讨论的,它出现的任何进程将等待为独占锁,但我不知道如何以最佳方式测试。对于那些你谁可能知道,我的羊群使用()的确保所有的进程将等待并没有请求将在这个不断运行的程序得到炒?
As discussed here, it appears any process will wait for an exclusive lock, but I'm not sure how best to test. For those of you who may know, will my use of flock() ensure that all processes will wait and no requests will get scrambled in this ever running program?
推荐答案
有没有必要修改httpd.conf文件为主。 Plesk允许定义自定义Apache指令可以在单独的配置文件:
There is no need to edit main httpd.conf. Plesk allows to define custom apache directives can in separate config file:
/var/www/vhosts/domain.com/conf/vhost.conf
和则需要更新域的配置:
And then need to update domain's configuration:
有关的Plesk 10和Plesk 11:
For Plesk 10 and Plesk 11:
/usr/local/psa/admin/bin/httpdmng --reconfigure-domain domain.com
有关的Plesk 7,8和9:
For Plesk 7, 8 and 9:
/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=domain.com
这篇关于使用PHP的Apache RewriteLock选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!