mac下环境搭建php

不积跬步无以至千里。

在mac 下搭建php环境。首先要先了解php 能够干嘛。和nginx是用来干嘛的。
1.下载php安装包。官方文档里面有安装的的方法。
2.启动fpm网关管理器(我的个人理解就是一个管理php-cgi的工具)。
3.使用brew 安装nginx 其实很简单就是brew install nginx。记录一下nginx 一些有用的命令

/usr/local/etc/nginx/nginx.conf  nginx 声明路径
sudo /usr/local/Cellar/nginx/1.8.0/bin/nginx nginx 启动命令
sudo /usr/local/Cellar/nginx/1.8.0/bin/nginx -s reload 重启

4.另nginx 对php 的支持。这里截止上代码

server {
        listen       8888;
        server_name  localhost;
    root         /Users/zengfeng/Documents/GoGoPhp;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
    
    location / {
            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #

    location ~* \.php$ {
            fastcgi_index   index.php;
            fastcgi_pass    127.0.0.1:9000;
            include         fastcgi_params;
            fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
            fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

比较关键的几个点listen 是开放的端口.
location 要加上index.php 最后加上php的支持

location ~* \.php$ {
            fastcgi_index   index.php;
            fastcgi_pass    127.0.0.1:9000;
            include         fastcgi_params;
            fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
            fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }

root 你部署的php 项目根目录
最后。嘻嘻。

nginx -s reload 

enjoy php ......

你可能感兴趣的:(mac下环境搭建php)