Mac Yosemite安装配置nginx+php+mysql+memcached环境

一个命令全搞定

sudo port install php55 php55-fpm php55-curl php55-exif php55-gd php55-gettext php55-iconv php55-mbstring php55-mcrypt php55-mysql php55-memcache php55-odbc php55-opcache php55-openssl php55-oracle php55-postgresql php55-sockets php55-sqlite php55-xmlrpc php55-zip memcached nginx mysql55

然后就是去配置点东西了...

配置php
进入配置目录 /opt/local/etc/php55

sudo cp ./php-fpm.conf.default ./php-fpm.conf
sudo cp ./php.ini-development ./php.ini 可以根据需要换成php.ini-production的

配置nginx
进入配置目录 /opt/local/etc/nginx
建一个文件 fcgi.conf

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

fastcgi_param  REDIRECT_STATUS    200;

修改一下nginx.conf 主要是增加对php的支持

location ~ \.php$ {
            root           share/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include        fcgi.conf;
        }

配置mysql
先安装

sudo -u _mysql /opt/local/lib/mysql55/bin/mysql_install_db

设置root帐户的密码,并且移除test数据库,进行安全设置

sudo mysql_secure_installation

数据库目录在 /opt/local/var/db/mysql55

好了~~就这么简单。。。
说下自动启动的
/Library/LaunchDaemons 目录!
有类似这样的东东就完事了
屏幕快照 2015-08-06 下午1.50.46.png

可能还是有人不知道如何启动这些软件!!
好吧。。。再写点没用的

nginx_start   sudo launchctl load -w /Library/LaunchDaemons/org.macports.nginx.plist
nginx_stop    sudo launchctl unload -w /Library/LaunchDaemons/org.macports.nginx.plist

php_start   sudo launchctl load -w /Library/LaunchDaemons/org.macports.php55-fpm.plist
php_stop    sudo launchctl unload -w /Library/LaunchDaemons/org.macports.php55-fpm.plist

memcached_start   sudo launchctl load -w /Library/LaunchDaemons/org.macports.memcached.plist
memcached_stop    sudo launchctl unload -w /Library/LaunchDaemons/org.macports.memcached.plist

mysql_start   sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql55-server.plist
mysql_stop    sudo launchctl unload -w /Library/LaunchDaemons/org.macports.mysql55-server.plist


你可能感兴趣的:(Mac Yosemite安装配置nginx+php+mysql+memcached环境)