문제

For run every script i do:

go build script.go
mv script script.fcgi

My apache config looks so:

<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>

Question: 1) If i build 1 script, it will builded with all packages that i link, right? 2) How i can customize fcgi and go so that it will not need build every time

sorry for bad english

도움이 되었습니까?

해결책

You can't. Go isn't a "scripting language" and Apache doesn't know how to process it (unlike PHP FCGI and variants).

You need to build (compile) your Go application with a HTTP or FCGI server, and run it, and then use Apache (or nginx) to reverse proxy to the HTTP port/FCGI socket your Go app is listening on.

Take a look at the net/http documentation and the simple web application tutorial in the Go documentation. From my experience I'd recommend using a reverse HTTP proxy over FCGI as it's easier to debug/configure.

i.e.

<VirtualHost myhost:80>
                ServerName www.mydomain.com
                ProxyPass / http://localhost:8000/ # Your Go app's listening port
                ProxyPassReverse / http://localhost:8000/
</VirtualHost>

Note that this isn't tested nor a complete example, but should hopefully get you started.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top