Mac下LEMP安装配置

Nginx

安装
# Search
$ brew search nginx
# Install
$ brew install nginx
配置
# 修改nginx默认端口为80
$ vim /usr/local/etc/nginx/nginx.conf
$ ....

# nginx监听80端口需要root权限
$ sudo chown root:wheel /usr/local/Cellar/nginx/[版本号]/bin/nginx
$ sudo chmod u+s /usr/local/Cellar/nginx/[版本号]/bin/nginx

# 启动
$ nginx # 或者 brew services start nginx

#测试配置是否有语法错误
$ nginx -t

# 重新加载配置|重启|停止|退出 nginx
$ nginx -s reload|reopen|stop|quit

#使用launchctl来启动|停止
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

# 基本nginx站点
server {
    listen       80;
    server_name  localhost;

    charset utf-8;

    access_log /usr/local/var/log/nginx/localhost.access.log;
    error_log /usr/local/var/log/nginx/localhost.error.log;

    root /path/to/youSites;
    location / {
        index  index.php index.html index.htm;
        # try_files $uri /$uri index.php?$args;
    }

    error_page  404              /404.html;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # 可单独提取出来,再引入
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

Mysql

# Search
$ brew search mysql
# Install
$ brew install mysql
# Exec mysql_secure_installation
$ mysql_secure_installation

# 查看mysql帮助
$ mysqld --help --verbose | more
...
Default options are read from the following files in the given order: # mysql 默认配置读取顺序
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
...

# 查看mysql默认配置样例
$ ls $(brew --prefix mysql)/support-files/my-*
/usr/local/opt/mysql/support-files/my-default.cnf
# 移动到/usr/local/etc/my.cnf

PHP

# Install php56 or php70 or php71
$ brew install php56
# 通过php-version控制多版本的php
$ brew install php-version
# PS: php-version使用在其他版本

基本开发足够,其余优化后续
未完待续..

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,859评论 18 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 172,977评论 25 708
  • 1.MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下产品。My...
    黄花菜已凉阅读 4,598评论 3 60
  • 在人的一生中总会有许多迷茫的时刻,各种诱惑蜂拥而至想要让你堕落,于是你在欲望与理性之中苦苦争扎,不知所措。 突然,...
    叶落风狂舞阅读 206评论 0 0
  • 听 那滴答滴答的雨声 声声入耳,撩动心弦 抬头,望啊 雨水溅起,那屋檐,白蒙蒙一片 风是最不争气的想念 雨是难以抗...
    慕卿苑阅读 188评论 0 0