mac系统下如何配置php+nginx+mysql+phpmyadmin

Original 2016-10-29 15:36:35 464
abstract:mac 10.9系统如何配置php+nginx+mysql+phpmyadmin,网上看了好多教程安装Brewruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"安装nginx,mysql,phpmyadminbrew install nginx mys

mac 10.9系统如何配置php+nginx+mysql+phpmyadmin,网上看了好多教程

安装Brew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装nginx,mysql,phpmyadmin

brew install nginx mysql phpmyadmin

安装特定版本php(以5.6为例)

brew tap homebrew/php
brew install php56

设置开机启动

brew tap homebrew/services
sudo brew services start php56
sudo brew services start nginx
sudo brew services start mysql

基本设置mysql

mysql_secure_installation

设置nginx(在文件在/usr/local/etc/nginx/nginx.conf中插入)

server {
        listen       80;
        server_name  localhost;

        location /pma {
        alias /usr/local/share/phpmyadmin/;
        try_files $uri $uri/ /index.php;
        disable_symlinks off;
        index index.php;
        
        location ~ ^/pma(.+\.php)$ {
            alias /usr/local/share/phpmyadmin$1;
            fastcgi_pass 127.0.0.1:9000;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME /usr/local/share/phpmyadmin$1;
            fastcgi_intercept_errors        on;
        }
    }

        location / {
            root   /srv/www;
            index  index.php index.html index.htm;
            try_files $uri $uri/ /index.php?$query_string;
            
        }

        location ~ \.php$ {
            root           /srv/www; 
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }


nginx重启
sudo nginx -s reload

在浏览器输入localhost/pma应该就ok了

Release Notes

Popular Entries