我终于管理了如何为我的虚拟主机需要正确配置httpd.conf.这是httpd.conf文件的相关部分
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Applications/XAMPP/htdocs/
</VirtualHost>
<VirtualHost *:80>
ServerName test.local
DocumentRoot /Applications/XAMPP/htdocs/test/
</VirtualHost>
<VirtualHost *:80>
ServerName work.local
DocumentRoot /Applications/XAMPP/htdocs/work/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
当我访问localhost上的任何内容(即http:// localhost/phpmyadmin)时,一切都非常快.每当我访问test.local或work.local(或我配置的其他人)时,它会在查找上花费10-15秒.以下请求被正确处理并且速度非常快但是在一分钟左右不活动之后,它必须再次查找.
这是我的/ etc/hosts文件
127.0.0.1 localhost
255.255.255.255 broadcasthost
#::1 localhost
fe80::1%lo0 localhost
# Virtualhosts
127.0.0.1 test.local work.local yii.local
Run Code Online (Sandbox Code Playgroud)
我怎么能解决这个恼人的问题?
我有一个相关的小文件(几百千字节),我希望在内存中直接访问整个代码执行.
我不确切知道NodeJ的内部,所以我问是否fs open足够或我必须读取所有文件并复制到Buffer?
我有一个基本的快速服务器,需要在每个请求处理期间存储一些全局变量.更深入的是,请求处理涉及许多需要存储在变量中的操作,例如global.transaction[]
当然,如果我使用global范围,每个连接将共享其事务的信息,我需要一个全局范围,因为我需要在执行期间从许多其他模块访问事务数组.
有关这个问题的任何建议吗?我觉得这是非常微不足道的事情,但我正在寻找复杂的解决方案:)
非常感谢!
更新 这是一个案例场景,更清楚.
在每次请求我有3个模块(ModuleA,ModuleB,ModuleC),其读出的10个随机文件的内容在一个目录中.我想跟踪每个请求读取的文件名列表,并返回res.write列表.
因此,ModuleA/B/C需要访问某种全局变量,但名单request_1,request_2,request_3等...没有混淆.
我的应用程序应该将一个大文件流回浏览器,即远程服务器。目前,该文件由本地 NodeJS 服务器提供。
我正在使用 25GB 的 VirtualBox 磁盘映像,只是为了确保它在流式传输时没有存储在内存中。这是我正在努力的相关代码
require __DIR__ . '/vendor/autoload.php';
use GuzzleHttp\Stream\Stream;
use GuzzleHttp\Stream\LimitStream;
$client = new \GuzzleHttp\Client();
logger('==== START REQUEST ====');
$res = $client->request('GET', 'http://localhost:3002/', [
'on_headers' => function (\Psr\Http\Message\ResponseInterface $response) use ($res) {
$length = $response->getHeaderLine('Content-Length');
logger('Content length is: ' . $length);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="testfile.zip"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . $length);
}
]);
$body = $res->getBody();
$read = 0;
while(!$body->eof()) {
logger("Reading chunk. " . $read);
$chunk …Run Code Online (Sandbox Code Playgroud) node.js ×2
apache ×1
buffer ×1
express ×1
guzzle ×1
httpd.conf ×1
javascript ×1
php ×1
stream ×1
streaming ×1
virtualhost ×1