在fcgi下在Apache上构建和运行go脚本
对于运行我执行的每个脚本:在fcgi下在Apache上构建和运行go脚本,apache,go,fastcgi,Apache,Go,Fastcgi,对于运行我执行的每个脚本: go build script.go mv script script.fcgi 我的apache配置看起来是这样的: <VirtualHost [myip]:80> ServerAdmin webmaster@example.com ServerName website.com DocumentRoot /home/user/www RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENA
go build script.go
mv script script.fcgi
我的apache配置看起来是这样的:
<VirtualHost [myip]:80>
ServerAdmin webmaster@example.com
ServerName website.com
DocumentRoot /home/user/www
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /our_bin [QSA,L]
<Directory /home/user/www>
Allow from all
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ script.fcgi/$1 [QSA,L]
</Directory>
</VirtualHost>
服务器管理员webmaster@example.com
服务器名网站
DocumentRoot/home/user/www
重写cond%{DOCUMENT\u ROOT}%{REQUEST\u FILENAME}-F
重写规则^(.*)$/our_bin[QSA,L]
通融
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-d[或]
重写cond%{REQUEST_URI}^/$
重写规则^(.*)$script.fcgi/$1[QSA,L]
问题:
1) 如果我构建1个脚本,它将使用我链接的所有包构建,对吗?
2) 如何定制fcgi和go,使其不必每次构建
对不起,英语不好,你不能。Go不是一种“脚本语言”,Apache不知道如何处理它(与PHP FCGI和变体不同)
您需要使用HTTP或FCGI服务器构建(编译)Go应用程序,并运行它,然后使用Apache(或nginx)将代理反向到Go应用程序正在侦听的HTTP端口/FCGI套接字
请查看Go文档中的文档和教程。根据我的经验,我建议在FCGI上使用反向HTTP代理,因为它更容易调试/配置
i、 e
服务器名www.mydomain.com
ProxyPass/http://localhost:8000/ #你的Go应用程序的侦听端口
ProxyPassReverse/http://localhost:8000/
请注意,这既不是经过测试的示例,也不是一个完整的示例,但很有希望让您开始学习。您不能。Go不是一种“脚本语言”,Apache不知道如何处理它(与PHP FCGI和变体不同)。您需要使用HTTP或FCGI服务器构建(编译)您的Go应用程序,并运行它,然后使用Apache(或nginx)将代理反向到您的Go应用程序正在侦听的HTTP端口/FCGI套接字。@elithrar将此作为问题的答案发布。
<VirtualHost myhost:80>
ServerName www.mydomain.com
ProxyPass / http://localhost:8000/ # Your Go app's listening port
ProxyPassReverse / http://localhost:8000/
</VirtualHost>