在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 和触控板左下角 ...
随机推荐
- Follow me to learn how to use mvc template
Introduction After having gone through many project: Project A Project B Project C I start to write ...
- mysql awr v1.0.2发布
改进说明: 1.新增监控Mysql实例通过web控制台http://ip:port/hosts.html进行,无需更改mysql-jdbc.properties配置文件和spring-servlet. ...
- RHEL7文件查找
本文介绍RHEL7下which.whereis.locate.find命令的使用,重点介绍find命令的使用 which 命令:which 作用:查找命令的执行文件路径 语法:which [选项] [ ...
- LIST-PROCESSING用法 ABAP任意时刻进行List输出_SAP
如何在SAP的Screen中编写List报表 1.相关命令LEAVE TO LIST-PROCESSING [AND RETURN TO SCREEN <nnnn>].LEAVE LIST ...
- C语言接口与实现实例
一个模块有两部分组成:接口和实现.接口指明模块要做什么,它声明了使用该模块的代码可用的标识符.类型和例程,实现指明模块是如何完成其接口声明的目标的,一个给定的模块通常只有一个接口,但是可能会有许多种实 ...
- Purchase购物车实例分析
源代码下载地址:http://code4app.com/ios/55655def933bf09d328b5141 此源代码从中学到以下四个知识点 第一:关于右边只有一个被选中的效果展现,左边部分代码内 ...
- App开发流程之数据持久化和编译静态链接库
先记录数据持久化. iOS客户端提供的常用数据持久化方案:NSUserDefaults代表的用户设置,NSKeydArchiver代表的归档,plist文件存储,SQLite数据库(包括上层使用的Co ...
- 如何改进iOS App的离线使用体验
App Store中的App分析 App已经与我们形影不离了,不管在地铁上.公交上还是在会场你总能看到很多人拿出来手机,刷一刷微博,看看新闻. 据不完全统计有近一半的用户在非Wifi环境打开App,以 ...
- 算法积累:解决如何获取指定文件夹路径或者文件路径下所有子文件后缀为.h .m .c的文本的行数
1.先解决如何获取一个文件的代码行数 一开始对于这个问题,我的思路就回荡在:1字符串子字符串的判断 2循环直到结束的想法 3将原来是"\n"替换掉之类的想法 一个问题总会有多种解决 ...
- linux命令----网络地址
IP即时生效(重启后失效): ifconfig eth0 192.168.1.102 netmask 255.255.255.0 route add default gw 192.168.1.1 ...