ubuntu+ apache2+cgi配置(自己摸索了两天)解决(空白页,forbiden, internal server error )赠于python初学者

本文详细介绍了如何在Ubuntu上配置Apache2服务器以支持CGI,包括修改配置文件以允许CGI、设置自定义目录、解决内部服务器错误等问题。同时,针对Python CGI脚本的编写和运行进行了说明,特别提到了版本兼容性和中文编码问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一 第一步安装 apache2

sudo apt install apache2

检查是否安装成功

在浏览器地址栏输入http://localhost,查看Apache服务器默认网页是否运行正常,网页图如下:

在这里插入图片描述
三 更改目录
只需要对apache2在/etc/apache2和/etc/apache2/sites-available下的两个配置文件apache2.conf和000-default.conf两个配置进行修改就行了。
这里附上我的更改方法,
输入

sudo nautilus

1打开文件/etc/apache2/apache2.conf

<Directory />
	Options FollowSymLinks
	AllowOverride All
	Require all denied
</Directory>

<Directory /usr/share>
	AllowOverride All
	Require all granted
</Directory>

<Directory /var/www/cgi-bin>
	Options Indexes FollowSymLinks
	AllowOverride All
	Require all granted
	Allow from all
	AddHandler cgi-script .cgi .py .sh
</Directory>

#<Directory /srv/>
#	Options Indexes FollowSymLinks
#	AllowOverride All
#	Require all granted
#</Directory>
</
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值