在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 和触控板左下角 ...
随机推荐
- 用C语言制作爱心
国庆我们实验室布置了作业,其中一项为,利用流程控制语句打印以下图形 * *** ***** ******* ***** *** * 代码如下 #include <stdio.h> int ...
- setTimeout实现动画的黄金优化法则
1.使用递归思想实现setTimeout的轮询动画:在每一次执行方法的时候都重新的设置一个定时器,然后在指定时间内重新的执行当前的方法 问题:每一次设置的定时器,虽然不执行了,但是还存在呢,浪费性能 ...
- ECMAScript 6学习笔记(二):let和块级作用域
同步发布于:https://mingjiezhang.github.io/(转载请说明此出处). ES6中加入了let,也让JavaScript拥有了块级作用域. 没有块级作用域的JavaScript ...
- linux服务器如何设置目录权限,让开发只能在测试目录下开发,不在线上目录上开发
当一台服务器上,既有测试环境,也有生成的环境,开发需要在线上测试,如果开发生产环境的权限,那开发容易误操作 需求如下: (1)生产环境的代码,必须有专用的账号登陆进行管理 (2)开发测试环境的代码,开 ...
- 关于Eclipse 和 IDEA 导入library库文件 的步骤
这里我们以PullToRefresh(上拉刷新下拉加载)组件的library为例 下载地址: https://github.com/chrisbanes/Android-PullToRefresh 现 ...
- iOS实现(超级猜图)源码
//首先建立模型文件 QLLQuestion.hheQLLQuestion.m文件 #import <Foundation/Foundation.h> @interface QLLQues ...
- Git使用之设置SSH Key
设置SSH Key 1. 检查是否已经有SSH Key. $cd ~/.ssh 如果说没有这个目录,就直接看第三步 2. 备份 3. 生成一个新的SSH. $ssh-keygen - ...
- 抓包工具charles使用教程指南
0x01 前言: Charles是一款抓包修改工具,相比起burp,charles具有界面简单直观,易于上手,数据请求控制容易,修改简单,抓取数据的开始暂停方便等等优势!下面来详细介绍下这款强大好用的 ...
- 《笨办法学python第三版》习题26,原错误代码及正确代码
#import ex25 1 def break_words(stuff): """This function will break up words for us.&q ...
- 人机交互—对win10自带输入法的评价
在我的电脑换成win10系统后我就用他自带的输入法,它可以中英文切换,用起来很方便,就用了它,就没有下载别的输入法. 用户界面:这个输入法的界面非常简单,没有像搜狗,百度之类的皮肤一说,看起来很简单, ...