“Set up CGI with Apache on kali Linux”的版本间的差异
跳到导航
跳到搜索
第88行: | 第88行: | ||
[https://wiki.debian.org/nginx/FastCGI nginx FastCGI on debian] | [https://wiki.debian.org/nginx/FastCGI nginx FastCGI on debian] | ||
+ | |||
+ | [https://code-maven.com/set-up-cgi-with-apache Set up CGI with Apache on Ubuntu Linux] | ||
[https://www.server-world.info/en/note?os=Ubuntu_20.04&p=nginx&f=6 Nginx : Use CGI Scripts ] | [https://www.server-world.info/en/note?os=Ubuntu_20.04&p=nginx&f=6 Nginx : Use CGI Scripts ] |
2021年5月21日 (五) 13:59的版本
[[category:]]
ins httpd
sudo apt-get install apache2
config
理论上只动这两个配置 /etc/apache2/apache2.conf /etc/apache2/conf-available/serve-cgi-bin.conf mkdir /var/www/cgi-bin cd /var/www/cgi-bin/ sudo vi /etc/apache2/apache2.conf 并在末尾添加以下内容 ################################################################### ######### Adding capaility to run CGI-scripts ################# ServerName localhost ScriptAlias /cgi-bin/ /var/www/cgi-bin/ Options +ExecCGI AddHandler cgi-script .cgi .pl .py sudo vi /etc/apache2/conf-available/serve-cgi-bin.conf #修改成如下所示: 原来的最好backup <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> ## cgi-bin config ScriptAlias /cgi-bin/ /var/www/cgi-bin/ <Directory "/var/www/cgi-bin/"> AllowOverride None Options +ExecCGI </Directory> </IfDefine> </IfModule> 使用以下命令启用CGI模块。此命令创建模块配置文件到/etc/apache2/mod-enabled/ 目录下的软链接。 sudo a2enmod cgi udo service apache2 restart cd /var/www/cgi-bin touch hello.py chmod o+x hello.py sudo vi hello.py #cgi等等文件名也行 #!/usr/bin/python3 print("Content-Type: text/html;charset=utf-8") print () print ("你好啊,evan") 打开浏览器 IP/cgi-bin/hello.py