[英]running local server .py prompts a text editor instead of opening page
I have a file which currently works on my production site as mysite.com/pages/lister.py. 我有一个文件,目前在我的生产网站上以mysite.com/pages/lister.py的形式运行。
I am trying to build a local version of the site. 我正在尝试构建本地版本的网站。 The index.php works and other pages work, but when I go to a .py page like: localhost/pages/lister.py it doesnt change the site, it just asks if I want to use gedit to open the file.
index.php工作,其他页面工作,但当我转到.py页面,如:localhost / pages / lister.py它不会更改网站,它只是询问我是否要使用gedit打开文件。
My guess is that my local config is off somewhere, but I do not know where to start when approaching this problem. 我的猜测是我的本地配置在某处,但我不知道在接近这个问题时从哪里开始。
NOTES: 笔记:
I am running a lamp server which I downloaded using sudo apt-get install lamp-server^
我正在运行一个使用
sudo apt-get install lamp-server^
下载的sudo apt-get install lamp-server^
and my apache config is /etc/apache2/sites-available/000-default.conf
and contains: 我的apache配置是
/etc/apache2/sites-available/000-default.conf
并包含:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory /var/www/>
Options ExecCGI Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler cgi-script .py
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
EDIT 1 编辑1
This may be the solution to my question but its not really working yet so idk yet. 这可能是我的问题的解决方案,但它还没有真正起作用。
I ran 我跑了
sudo a2enmod cgi
sudo service apache2 restart
and now it gives: 现在它给出了:
Internal Server Error 内部服务器错误
The server encountered an internal error or misconfiguration and was unable to complete your request. 服务器遇到内部错误或配置错误,无法完成您的请求。
Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error. 请通过webmaster @ localhost与服务器管理员联系,告知他们此错误发生的时间以及您在此错误发生之前执行的操作。
More information about this error may be available in the server error log. 服务器错误日志中可能提供了有关此错误的更多信息。 Apache/2.4.18 (Ubuntu) Server at localhost Port 80
Apache / 2.4.18(Ubuntu)服务器在localhost端口80
My configuration for .pl and .py scripts that write HTML directly out to a page is the following: 我将直接将HTML写入页面的.pl和.py脚本的配置如下:
<Directory "[put production path here]">
Options Indexes FollowSymLinks ExecCGI
AllowOverride All
Require all granted
</Directory>
As I'm new to full stack work, I'm not sure if this is appropriate for your situation, but it might be worth a try. 由于我是全栈工作的新手,我不确定这是否适合您的情况,但可能值得一试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.