MacOS – Understanding install of mod_wsgi on apache terminal commands

apachemacospythonterminal

I'm installing a django development environment on OSX. Apache is, of course, installed by default. From my (very limited) understanding of Macs, I don't believe there is preconfigured functionality for interfacing python with apache in this default install (?). So, my first step is to install this interface, mod_wsgi, and I am following this person's tutorial on how to do that. He includes these terminal commands:

curl -o mod_wsgi.tgz http://modwsgi.googlecode.com/files/mod_wsgi-2.5.tar.gz
tar -xzf mod_wsgi.tgz
cd mod_wsgi-2.5
./configure
make
sudo make install

I'm confused about these commands. I don't want to just type them and move on; I want to understand what's going on. Can someone explain to me what they mean?

Best Answer

To do this you will need to install Xcode from App Store and then its command line tools from an option in Xcode as you need a development environment.

It might be easier to use a package manager like Macports or Homebrew after that to install apache and mod_wsgi. the writers of the package will have sorted out any issues.

I will explain the commands in the line after each one

curl -o mod_wsgi.tgz http://modwsgi.googlecode.com/files/mod_wsgi-2.5.tar.gz

Get the source code from the given server. curl is a program that downloads via http. You could just enter the URL in your browser and download the file. The curl command puts the mod_wsgi.tgz in your current directory.

tar -xzf mod_wsgi.tgz

Untar the file - ie get all the individual files out of the package and put them in the correct subdirectories. If you had downloaded in your browser the default action would have down this unpack, or select this file in Finder and double click to extract.

cd mod_wsgi-2.5

Change directory into the top level of the source code. If you had used the browser in the first two steps then cd ~/Downloads/mod_wsgi-2.5

./configure

The source code can be built for many versions of Unix, Linux and possible other operating systems. configure is a shell script that calls on certain programs in Xcode to generate the correct source code files so that this setup will build on OSX. The ./ is required as your current directory is not on your path.

make

Make an executable and support files out of the source code. This will all be in or beneath your current directory. make is a program that does things based on a set of rules held in makefiles.

sudo make install

This puts the executables in a directory that can be used by apache. make install uses the make program as above but with a command install to do something different (actually if you had not done make before it will also do the build as in the command above as that is defined as a dependency on the makefile but don't do this because of the sudo) sudo is a command that makes the rest of the line run as the root user, this is needed as you should not have permission to write to the directories the executables should end up in, this you need a special command to get that permission. Note that your user needs to be set up to use sudo, if you are an Administrator then that will be sufficient.

This should give you enough pointers to help you read up on anything that I have started to explain.