心海恋歌 发表于 2017-7-7 12:00:12

mac 安装php+nginx+php-fpm+mysql

  1、下载编辑器http://www.iterm2.com/downloads.html




2、使用brew安装软件:brew又叫homebrew,是mac osx上的软件包管理工具,能在mac中方便的安装软件或者卸载软件,只需要一个命令,非常方便。



3、打开brew 的官方网站: http://brew.sh/



4、在linux命令行下输入:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装brew成功

5、安装git

直接在命令行中输入 brew install git

就可以安装成功,如果要卸载就直接输入 brew uninstall git

6、更新brew:brew update

具体用到可以直接查

7、安装nginx:
brew search nginx
brew install nginx

执行:

cd /usr/local/etc/nginx/

mkdir conf.d



vim nginx.conf

粘贴此内容:



<!-- lang: shell -->

worker_processes 1;



error_log    /usr/local/var/log/nginx/error.log warn;



pid    /usr/local/var/run/nginx.pid;



events {

worker_connections 256;

}



http {

include    mime.types;

default_type application/octet-stream;



log_format main '$remote_addr - $remote_user [$time_local] "$request" '

         '$status $body_bytes_sent "$http_referer" '

         '"$http_user_agent" "$http_x_forwarded_for"';



access_log   /usr/local/var/log/nginx/access.log main;

port_in_redirect off;

sendfile    on;

keepalive_timeout 65;



include /usr/local/etc/nginx/conf.d/*.conf;

}



vim default.conf

<!-- lang: shell -->

server {

listen    8080;

server_name localhost;



root /Users/user_name/nginx_sites/; # 该项要修改为你准备存放相关网页的路径



location / {

    index index.php;

    autoindex on;

}



#proxy the php scripts to php-fpm

location ~ \.php$ {

    include /usr/local/etc/nginx/fastcgi.conf;

    fastcgi_intercept_errors on;

    fastcgi_pass127.0.0.1:9000;

}



}





以上就是nginx配置完成





安装php

brew install php70 --with-imap --with-tidy --with-debug --with-mysql --with-fpm



  安装php-fpm


mac osx 10.9 以后的系统都自带了php、php-fpm,这样就省去了安装的麻烦

只需要执行:sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf



安装mysql



brew install mysql





测试nginx服务



在之前的nginx配置文件default.conf中设置的root项对应的文件夹下创建测试文件index.php



<?php phpinfo();?>



启动nginx服务

sudo nginx



启动php服务

sudo php-fpm



注意:

如果你之前在电脑上安装了php5.5,你再安装php7.0,当你在地址栏中输入localhost:8080 看到的php版本是5.5而不是最新的7.0看到的fpm版本也是5.5

解决:



1、sudo cp /usr/local/Cellar/php70/7.0.15_8/sbin/php-fpm /usr/sbin/php-fpm



2、

vim ~./zshrc 修改此文件的最后一行,把

export PATH=$HOME/bin:/usr/local/sbin:/usr/local/bin:$PATH



3、重新启动fpm :source .zshrc



4、看fpm的进程有哪些:ps aux|grep php-fpm



5、分别杀死这些进程:sudo kill 16591 16591 16589





4、最后看一下phpfpm的版本:/usr/local/sbin/php-fpm -v





意思就是先去sbin中去找php7文件,再去bin找,刚开始没有
页: [1]
查看完整版本: mac 安装php+nginx+php-fpm+mysql