当尝试 运行 cgi 时,它会下载
when trying to run cgi it downloads instead
编辑:根据对类似问题的回答,我用 chown 声明了文件夹和文件的所有权。一旦我将文件夹的权限设置为 777,它就会开始工作。
我不太了解 apache 配置,但到目前为止我已经能够让它与我的 web 应用程序一起使用。
现在我正在尝试学习 C 中的一些东西,这是正在发生的事情:
- 当我在 http://localhost/cgi-bin/ 上从浏览器打开文件时,一切正常; - 文件位于 /usr/lib/cgi-bin/
- 当我将文件移动到 /var/www/cgi-bin/ 并尝试在浏览器中从 http://codigoc/ 打开它们时,它所做的只是下载文件而不是 运行 它们。
我一直在网上搜索,但还没有找到解决方案。
由于我不确定到底需要做什么,我会在下面留下我的文件。
/etc/apache2/conf-enabled/serve-cgi-bin.conf
<IfModule mod_alias.c>
<IfModule mod_cgi.c>
Define ENABLE_USR_LIB_CGI_BIN
</IfModule>
<IfModule mod_cgid.c>
Define ENABLE_USR_LIB_CGI_BIN
</IfModule>
<IfDefine ENABLE_USR_LIB_CGI_BIN>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
</IfDefine>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
/etc/apache2/apache2.conf
<Directory /var/www/cgi-bin/>
Options +ExecCGI
AddHandler cgi-script .cgi .pl
</Directory>
/etc/apache2/sites-enabled/codigoc.conf
<VirtualHost *:80>
ServerName codigoc
ServerAdmin webmaster@localhost
DocumentRoot /var/www/cgi-bin/
ScriptAlias /cgi-bin/ /var/www/cgi-bin
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI -Multiviews +SymLinksIfOwnerMatch
Require all granted
</Directory>
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
不确定这是否足以让你们帮助我,但如果我遗漏了什么,请告诉我。
提前致谢!
是权限问题...现在已解决
谢谢约翰,很抱歉占用您的时间
编辑:根据对类似问题的回答,我用 chown 声明了文件夹和文件的所有权。一旦我将文件夹的权限设置为 777,它就会开始工作。
编辑:根据对类似问题的回答,我用 chown 声明了文件夹和文件的所有权。一旦我将文件夹的权限设置为 777,它就会开始工作。
我不太了解 apache 配置,但到目前为止我已经能够让它与我的 web 应用程序一起使用。 现在我正在尝试学习 C 中的一些东西,这是正在发生的事情:
- 当我在 http://localhost/cgi-bin/ 上从浏览器打开文件时,一切正常; - 文件位于 /usr/lib/cgi-bin/
- 当我将文件移动到 /var/www/cgi-bin/ 并尝试在浏览器中从 http://codigoc/ 打开它们时,它所做的只是下载文件而不是 运行 它们。
我一直在网上搜索,但还没有找到解决方案。 由于我不确定到底需要做什么,我会在下面留下我的文件。
/etc/apache2/conf-enabled/serve-cgi-bin.conf
<IfModule mod_alias.c>
<IfModule mod_cgi.c>
Define ENABLE_USR_LIB_CGI_BIN
</IfModule>
<IfModule mod_cgid.c>
Define ENABLE_USR_LIB_CGI_BIN
</IfModule>
<IfDefine ENABLE_USR_LIB_CGI_BIN>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
</IfDefine>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
/etc/apache2/apache2.conf
<Directory /var/www/cgi-bin/>
Options +ExecCGI
AddHandler cgi-script .cgi .pl
</Directory>
/etc/apache2/sites-enabled/codigoc.conf
<VirtualHost *:80>
ServerName codigoc
ServerAdmin webmaster@localhost
DocumentRoot /var/www/cgi-bin/
ScriptAlias /cgi-bin/ /var/www/cgi-bin
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI -Multiviews +SymLinksIfOwnerMatch
Require all granted
</Directory>
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
不确定这是否足以让你们帮助我,但如果我遗漏了什么,请告诉我。
提前致谢!
是权限问题...现在已解决
谢谢约翰,很抱歉占用您的时间
编辑:根据对类似问题的回答,我用 chown 声明了文件夹和文件的所有权。一旦我将文件夹的权限设置为 777,它就会开始工作。