Tag: 服务器

尝试加载gem“uglifier”时发生错误。 (捆扎机:: GemRequireError)

为什么我得到这个错误? shibly@mybox:~/blog$ rails server /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'uglifier'. (Bundler::GemRequireError) from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require' from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each' from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require' from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each' from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require' from /home/shibly/.gem/ruby/2.2.4/gems/bundler-1.11.2/lib/bundler.rb:99:in `require' from /home/shibly/blog/config/application.rb:7:in `<top (required)>' from /home/shibly/.gem/ruby/2.2.4/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:78:in `require' […]

如何使一个node.js应用程序永久运行?

在Debian服务器上,我安装了Node.js. 我知道如何用这个命令行从putty启动一个应用程序: node /srv/www/MyUserAccount/server/server.js 并在地址50.51.52.53:8080和端口)上得到它。 但是,只要我closures腻子,那么我不能再达到地址50.51.52.53:8080 。 如何使一个NodeJS应用程序永久运行? 你可以猜到,我是一个Linux和Node.js的初学者。

为什么我需要使用http.StripPrefix来访问我的静态文件?

main.go package main import ( "net/http" ) func main() { http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) http.ListenAndServe(":8080", nil) } 目录结构: %GOPATH%/src/project_name/main.go %GOPATH%/src/project_name/static/..files and folders .. 即使在阅读文档之后,我仍然无法理解http.StripPrefix在这里的作用。 1)为什么我不能访问localhost:8080/static如果我删除http.StripPrefix ? 2)如果我删除该function,什么URL映射到/static文件夹?

使用“模板”包在golang中为客户端生成dynamic网页需要花费太多时间

使用template包为客户端生成一个dynamic网页时,速度非常慢。 testing代码如下,golang 1.4.1 http.Handle("/js/", (http.FileServer(http.Dir(webpath)))) http.Handle("/css/", (http.FileServer(http.Dir(webpath)))) http.Handle("/img/", (http.FileServer(http.Dir(webpath)))) http.HandleFunc("/test", TestHandler) func TestHandler(w http.ResponseWriter, r *http.Request) { Log.Info("Entering TestHandler …") r.ParseForm() filename := NiConfig.webpath + "/test.html" t, err := template.ParseFiles(filename) if err != nil { Log.Error("template.ParseFiles err = %v", err) } t.Execute(w, nil) } 根据日志,我发现t.Execute(w, nil)花了大约3秒钟,我不知道为什么它使用这么多的时间。 我也尝试过Apache服务器来testingtest.html ,它的响应速度非常快。

Apache2:“AH01630:客户端被服务器configuration拒绝”

尝试通过浏览器访问本地主机时出现此错误。 AH01630: client denied by server configuration 我检查我的网站文件夹权限使用: sudo chmod 777 -R * 这是我的configuration文件: <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /home/user-name/www/myproject <Directory /> Options FollowSymLinks AllowOverride all Allow from all </Directory> <Location /> Allow from all Order Deny,Allow </Location> <Directory /home/user-name/www/myproject/> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ […]

使用node.js作为一个简单的Web服务器

我想运行一个非常简单的HTTP服务器。 每个对example.com GET请求都应该得到index.html ,但是作为一个普通的HTML页面(也就是当你阅读正常的网页的时候)。 使用下面的代码,我可以读取index.html的内容。 如何将index.html作为常规网页提供服务? var http = require('http'); var fs = require('fs'); var index = fs.readFileSync('index.html'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(index); }).listen(9615); 下面的一个build议很复杂,需要我为每个我想使用的资源(CSS,JavaScript,图像)文件写一个get line。 我如何用一些图片,CSS和JavaScript来提供一个HTML页面?

XMLHttpRequest无法加载https:// www。 .com /

我有一个Grunt进程启动一个express.js服务器的实例。 直到现在,它开始提供一个空白页面,并且在Chrome(最新版本)的开发者控制台的错误日志中出现以下内容: XMLHttpRequest无法加载https:// www。[website] .com /否请求的资源上存在“Access-Control-Allow-Origin”标头。 原因' http:// localhost:4300 '因此不被允许访问。 什么阻止我访问页面?

如何运行node.js应用程序作为后台服务?

由于这篇文章多年来引起了很多关注,我已经在这篇文章的底部列出了每个平台的顶级解决方案。 原文 : 我想让我的node.js服务器在后台运行,即:当我关闭我的终端时,我希望我的服务器继续运行。 我GOOGLE了这个,并提出了本教程 ,但它不能按预期工作。 所以,而不是使用该守护进程脚本,我以为我只是使用输出重定向( 2>&1 >> file一部分),但这也不会退出 – 我在我的终端空白行,像它正在等待输出/错误。 我也试图把这个过程放在后台,但是一旦我关闭了终端,这个过程也会被终止。 那么当我关闭本地计算机时,如何让它继续运行? 顶级解决方案 Systemd (Linux) 启动 (Mac) 节点窗口 (Windows) PM2 (Node.js)