私はPythonスクリプトを使用してCGIを実装しようとしています。 127.0.0.1/hello
を開くと、ファイルは実行されずにダウンロードされます。内容は次のとおりPython CGI executable
#!/home/musigma/anaconda3/bin python3
私のpythonファイルにシェバング行として、次のように私は、次を追加しました私は
/home/musigma/anaconda3/bin
にインストールのpythonを持ってsites-available
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
AddHandler cgi-script .py
</Directory>
<Directory /var/www/>
Options ExecCGI Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler cgi-script .py
</Directory>
ScriptAlias /cgi-bin/ /usr-lib/cgi-bin/
<Directory "/usr-lib/cgi-bin/">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
の私000-default.conf
ファイルです私のpythonファイルの
#!/home/musigma/anaconda3/bin python3
print("Content-type:text/html\r\n\r\n")
print("<html>")
print("<head><title>cgi script </title></head>")
print("<body>")
print('<p>I think it worked</p>')
for i in range(5):
print("<h1>hello world</h1>")
print("</body>")
print("</head>")
ファイルを/var/www
に置きました。私はまた、
sudo chmod 755 hello.py
私のpythonファイルを実行可能にするために以下の行を走っしかし、それはまだ私のPythonスクリプト実行可能にしていません。実行する代わりに、ファイルがダウンロードされます。私は物事を今働かせる方法がわかりません。どんな方向にも大きな助けになるでしょう。私はこれらのリンクを試みたが、私の目的を果たさない。私はすでに私が次に何をすべきかわから最後の四から五時間ではないので、これを理解しようとしているこれらの事の
Python CGI executable script downloads/shows script code
を世話をしてきました。どんな方向性も素晴らしいでしょう。
PS:私は、あなたが/コピーした場合hello.cgi
とhello.py
にファイルをシンボリックリンクは何のUbuntuに16.04
apacheのバージョン
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2016-07-14T12:32:26
あなたは(素人用語で、おそらくより多くのように)もう少し説明することができますか? –