Until you run python with apache

Start and stop

apache is included in mac by default. Check the version.

$ httpd -v
Server version: Apache/2.4.9 (Unix)
Server built:   Sep  9 2014 14:48:20

How to start and restart. The default is port 80, so [http: // localhost].

$ sudo apachectrl start
$ sudo apachectrl stop

Enable cgi

Enable cgi_module. Since it is a comment, remove it and restart.

LoadModule cgi_module libexec/apache2/mod_cgi.so

Change path

Looking inside httpd.conf, the settings are as follows.

Create and change "~ / Web / doc" and "~ / Web / cgi".

DocumentRoot "/Users/myname/Web/doc"
<Directory "/Users/myname/Web/doc">
...
</Directory>
<IfModule alias_module>
    ScriptAliasMatch ^/cgi-bin/((?!(?i:webobjects)).*$) "/Users/myname/Web/cgi/$1"
</IfModule>
#
<Directory "/Users/myname/Web/cgi">
...
</Directory>

confirm

All that is left is to check the operation. Create a python script like the one below with + x and access "localhost / cgi-bin / test.py".

test.py


#!/usr/bin/python
print 'Content-Type: text/html\n\n'
print "Hello world!"

Recommended Posts

Until you run python with apache
Until you can use opencv with python
Run Python with VBA
Run prepDE.py with python3
Run Blender with python
Run iperf with python
Until you run the changefinder sample in python
Until you use PhantomJS with Python on Heroku
Run python with PyCharm (Windows)
Run Python with CloudFlash (arm926ej-s)
Let's run Excel with Python
Python3 + Django ~ Mac ~ with Apache
Run Label with tkinter [Python]
Run DHT22 with RasPi + Python
Run with CentOS7 + Apache2.4 + Python3.6 for the time being
Until you install Python with pythonbrew and run Flask on a WSGI server
Until you start Jupyter with Docker
Until you can install your own Python library with pip
Nice to meet you with python
Run Rotrics DexArm with python API
Until you put Python in Docker
Run XGBoost with Cloud Dataflow (Python)
Run Aprili from Python with Orange
Run python3 Django1.9 with mod_wsgi (deploy)
Until you can install blender and run it with python for the time being
Until you create a machine learning environment with Python on Windows 7 and run it
Until dealing with python in Atom
Until you shake ruby with renpy
Python | What you can do with Python
Until you install and run matplotlib
Until you build the environment with ABCI and run MaskTrack RCNN
Memorandum of understanding when Python is run on EC2 with Apache
Note until you use emacs with WSL
Until you confirm iOS communication with mitmproxy
Until you install your own Python library
CentOS 6.4 with Python 2.7.3 with Apache with mod_wsgi and Django
Run a Python web application with Docker
FizzBuzz with Python3
Scraping with Python
Statistics with python
Scraping with Python
[Introduction to machine learning] Until you run the sample code with chainer
Python with Go
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
Cast with python
Until you CI what you made with Django with Jenkins
Until you install Caffe and run the sample
Until you use the Kaggle API with Colab
Python> Run with run-time arguments> Use import argparse
You can easily create a GUI with Python
What are you comparing with Python is and ==?
Until it works with virtualenv + flask + apache + wsgi