在mac上安装nginx

Before we get started

If you are running Mac OS X Snow Leopard (version 10.6.x), please refer to this article: Nginx on Mac OS X Snow Leopard in 2 Minutes. You may use newer versions of Nginx and the prerequisite software, but whether you choose to do so, or you stick to the packages outlined in the above article, you will get a working Nginx web server on you Mac. Please note that the included build script will still work on Snow Leopard if you don’t want to go the DIY (do it yourself) route.

Overview

This guide will show you how I compiled a basic version of Nginx 1.1.4 on Mac OS X 10.7.1 Lion. The “2 minute” compilation that I mention in the title of this article is when using the script that I provide below. For the DIY folks, I’m breaking down the steps. Variations in your Mac’s specs, and your copy and paste skills may increase the total time to over 2 minutes.

Prerequisites

First, if you do not already have it installed, download and install Xcode from the Mac App Store.

Install PCRE

Nginx requires PCRE – Perl Compatible Regular Expressions to build, I used PCRE version 8.13. In a Terminal, run:

sudo curl -OL h ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.tar.gz > /usr/local/src/pcre-8.13.tar.gz

sudo mkdir -p /usr/local/src

cd /usr/local/src

tar xvzf pcre-8.13.tar.gz

cd pcre-8.13

./configure --prefix=/usr/local

make

sudo make install

cd ..

Install Nginx

(You should still be in /usr/local/src, if you followed along from above.)

tar xvzf nginx-1.1.4.tar.gz

cd nginx-1.1.4

./configure --prefix=/usr/local --with-http_ssl_module

make

sudo make install

Start Nginx

Assuming that you have /usr/local in your $PATH (which nginx should say:/usr/local/sbin/nginx), you can simply run:

sudo nginx

Note: to add /usr/local to your $PATH variable, edit or create ~/.profile to include it. For reference, mine currently looks like this:

PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/X11/bin:/opt/X11/bin" – I emphasized in bold type what you need to add to your PATH.

The 2 Minute way, using my script

All of the above instructions, in a nice little script. Save it to your Mac as build-nginx.sh, open a new Terminal window and run:

chmod a+x build-nginx.sh

sudo ./build-nginx.sh

Conclusion

It’s a pretty quick process to get Nginx installed nicely on your Mac, especially if you use my script. This provides a very basic install, but it should get you moving in the right direction. Your feedback is appreciated, so leave a comment below.

mac自带easy_install报错解决办法

mac集成了python的easysetup,使用时却报错

 

[Errno 13] Permission denied: ‘/Library/Python/2.7/site-packages/test-easy-install-4092.write-test’

 

是因为user没有写/Library/Python/2.7/site-packages/目录的权限

 

解决方法

 

sudo chmod +a ‘user:你的用户名 allow add_subdirectory,add_file,delete_child,directory_inherit’ /Library/Python/2.7/site-packages