Python的CGI编程实现-通过接口运行服务器py脚本

yum 安装apcche


【apache】yum 安装Apache(Centos 6.9) https://www.cnblogs.com/lauren1003/p/5993654.html
只需一行命令:
yum instal httpd -y #安装
service httpd start #启动apache

apache的参数和路径说明:https://blog.csdn.net/shj_php/article/details/79495861
apache的CGI参数配置 https://www.cnblogs.com/myvic/p/6821368.html

Python CGI编程:http://www.runoob.com/python/python-cgi.html


配置过程:
vi /etc/httpd/conf/httpd.conf


service httpd start 启动
service httpd restart 重新启动
service httpd stop 停止服务

#!/usr/bin/python2.6
# -*- coding: UTF-8 -*-
print "Content-type:text/html"
print # 空行,告诉服务器结束头部
print '<html>'
print '<head>'
print '<meta charset="utf-8">'
print '<title>Hello World - 我的第一个 CGI 程序!</title>'
print '</head>'
print '<body>'
print '<h2>Hello World! 我是来自菜鸟教程的第一CGI程序</h2>'
print '</body>'
print '</html>'

if version_info<(3,0):
print('注意当前是:python2')
else:
print('python3')


服务目录 /etc/httpd
主配置文件 /etc/httpd/conf/httpd.conf
网站数据目录 /var/www/html
访问日志 /var/log/httpd/access_log
错误日志 /var/log/httpd/error_log

转载于:https://www.cnblogs.com/andylhc/p/9889706.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值