如何配置apache执行cgi

发布于 2025-01-19 16:27:14 字数 550 浏览 6 评论 0原文

我对 LAMP 很陌生,我已经测试了 php 是否在 apache 服务器上运行,创建了一个文件testing.php,而不是显示 php 版本和其他内容,它只是显示与我输入的内容完全相同的内容:

<?php phpinfo(); ?>

我尝试使用 python 脚本并且也只是显示我输入的内容:

#!usr/bin/python

print ("Content-type:text/html\r\n\r\n")
print ("<html>")
print ("<head>)"
print ("<title>Hello world!</title>")
print ("</head>")
print ("<body>")
print ("<h2>Hello world!</h2>")
print ("</body>")
print ("</html>")

我应该如何配置 apache 来执行 cgi?

I'm very new to LAMP and I've tested if php is running on apache server creating a file testing.php and instead of showing php version and stuff it just show exactly the same thing I typed:

<?php phpinfo(); ?>

I tried to use python script and also just show the exactly what I typed:

#!usr/bin/python

print ("Content-type:text/html\r\n\r\n")
print ("<html>")
print ("<head>)"
print ("<title>Hello world!</title>")
print ("</head>")
print ("<body>")
print ("<h2>Hello world!</h2>")
print ("</body>")
print ("</html>")

How should I configure apache to execute cgi?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

送舟行 2025-01-26 16:27:14

您是否使用过 a2enmod 来启用 PHP?

您需要执行以下操作:

sudo a2enmod php7.4

sudo systemctl restart apache2

Have you used a2enmod to enable PHP?

You'll need to do something like:

sudo a2enmod php7.4

sudo systemctl restart apache2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文