在mac os下的Apache服务器的cgi中运行python
我是搬运工。。
Running Python Programs on the Mac OS X Apache Web Server
The Mac OS X operating system includes a pre-configured Apache web server and also includes the libraries needed to run Python. Thus, Python CGI scripts can be run without any configuration changes to the Apache configuration as long as the scripts are placed in the correct location and given the correct file permissions.
This guide assumes you are using OS X Leopard, although the steps should be the same or similar for earlier versions of OS X.
The default location to place CGI programs for the OS X apache installation is in the following directory:
/Library/WebServer/CGI-Executables
Files placed in this directory can be accessed via the following URL:
http://localhost/cgi-bin/file-name
In order for Apache to be able to execute the CGI script, the permissions on the file must be set correctly. For example, open EditRocket and create a file called test.py with the following contents. Save this file to the /Library/WebServer/CGI-Executables directory.
#!/usr/bin/python
print "Content-type: text/html"
print "<html><head>"
print ""
print "</head><body>"
print "Test Page"
print "</body></html>"
Open a terminal window (Applications -> Utilities -> Terminal). Execute the following command:
cd /Library/WebServer/CGI-Executables
Then execute the following (if prompted, enter your password)
sudo chmod 755 test.py
You now have a Python program, test.py, saved with the correct permissions in the /Library/WebServer/CGI-Executables directory.
Now, we need to restart the web server to make sure the changes take effect. To restart, do the following:
1. Go to System Preferences -> Sharing View
2. Uncheck the Web Sharing box. Then check the Web Sharing box again. This will start and stop the apache web server.
You can test this page by entering the following in your web browser:
http://localhost/cgi-bin/test.py
在mac os下的Apache服务器的cgi中运行python的更多相关文章
- mac os 下打开FTP服务器
mac下一般用smb服务来进行远程文件访问,但要用FTP的话,高版本的mac os默认关掉了,可以用如下命令打开: sudo -s launchctl load -w /System/Library/ ...
- Windows 配置Apache以便在浏览器中运行Python script的CGI模式
打开httpd.conf,找到”#ScriptInterpreterSource Registry “,移除前面的注释# (如果找不到这行,就自己添加进去) 找到“Options Indexes Fo ...
- Mac下配置Apache服务器
有的时候,我们需要在内网工作组中分享一些文件或是后台接口没有及时给出,你又想要模拟真实数据,直接在项目里创建plist也可以做到这种需求,但难免让工程变得冗余且看起来比较Low.这个时候就看出配置本地 ...
- Mac 下搭建 Apache 服务器
Apache作为最流行的Web服务器端软件之一,它的优点与地位不言而喻.下面介绍下在Mac下搭建Apache服务器的步骤: (1)“前往” –>”个人” (2)在你的个人目录下新建一个文件夹,改 ...
- Mac OS X取消Apache(httpd)开机启动
安装MAMP后,启动服务时提示Apache启动失败,80端口被占用.查看进程发现存在几个httpd. OS X自带Apache,可是默认是没有启动的.我也没有开启Web共享,怎么就开机启动了呢? 不知 ...
- YII 框架在 MAC OS下 连接数据库失败 提示 DB connection: SQLSTATE[HY000] [2002]
作者:zccst CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2002] No such file or dire ...
- Mac OS 自带apache 启动不了的问题
问题:Mac OS 自带apache,启动不了,拒绝访问. 1.先看一下错误日志 /etc/apache2/httpd.conf 2.然后我去找了一下/private/var/log/apache2/ ...
- mac os 下搭建android开发环境
mac os 下搭建android开发环境 周银辉 mac os 下搭建android环境比较方便, 如下几个步骤: 1,安装jdk 先搞清楚自己是否已经安装,在命令行下:java -version, ...
- mac os 下的sublime --- 快捷键
mac os 下的sublime ---列模式 http://www.oschina.net/question/249672_161413 触控板也可以的:左手同时按住 Option 和触控板左下角 ...
随机推荐
- java开发过程中从前台传到后台中文乱码《filter》
在企业开发中,最常见的是javaweb项目,有web项目就免不了和后台打交道,比如我从jsp页面发送新增请求到后台,后台可能是servlet.struts2.springmvc等,这时就存在一个问题, ...
- .NET Core常用配置文件示例
.NET Core相关地址: 1.官网:https://www.microsoft.com/net 2..NET Core:http://dotnet.github.io/3.Getting Star ...
- html alert 的三种方式
html alert 一共有三种方式. 第一种是最简单的直接在js的函数里alert("要输出的内容"); 这种直接就是一个弹出框,显示要输出的内容. 第二种是带选择的弹出框,弹出 ...
- [Android] 环境配置之基础开发环境(SDK/Android Studio)(转)
[Android] 环境配置之基础开发环境(SDK/Android Studio) 博客: blog.csdn.net/qiujuer 网站: www.qiujuer.net 开源库: Geniu ...
- Android Studio使用教程(一)(转)
今年的Google全球开发者大会虽然没有新的Android系统和设备,但是还是推出了一些不错的产品,Android Studio就是其中之一.这个基于Intellij IDEA开发的Android I ...
- Linux 学习手记(3):Linux基本的文件管理操作
复制文件和目录 在Linux中使用命令cp来复制文件或者目录,使用方式: cp 源文件(文件夹) 目标文件(文件夹) cp命令常用参数: -r 递归复制整个目录 -v 显示详细信息 移动.重命名一个文 ...
- YUIDoc example代码高亮错误、生成API文档目录不按源文件注释顺序
1.如果发现yuidoc命令用不了,那就重装nodejs吧 昨天不知道是清扫电脑的原因,yuidoc命令用不了(命令不存在),也没有找到好的解决方法,怒重装YUIDoc也不行.最后想了想,怒重装了no ...
- 回车键和button按钮都绑定同一个事件,如何避免按回车的时候button重复点击
保存一个全局变量,用来记录Button的焦点状态 <button onclick="login();" onfocus="window.buttonIsFocuse ...
- 实验12:Problem I: 成绩排序
Home Web Board ProblemSet Standing Status Statistics Problem I: 成绩排序 Problem I: 成绩排序 Time Limit: 1 ...
- Atitit.HTTP 代理原理及实现 正向代理与反向代理attilax总结
Atitit.HTTP 代理原理及实现 正向代理与反向代理attilax总结 1. 普通代理1 1.1.1. 普通代理2 2. 隧道代理3 3. 反向代理 4 4. 正向代理也可以使用apache实现 ...