mac安装lnmp(lamp)-php环境

安装方式

  • 编译安装
  • brew安装
  • 安装包引导安装

服务

  • php(多个版本)
  • nginx
  • apache
  • MySql(多个版本)
  • redis
  • memcahce
  • composer
  • rabbitmq
  • beanstalkd
  • mongo
  • nodejs

nginx

brew install nginx

/usr/local/var/www 页面项目位置
/usr/local/etc/nginx/nginx.conf 配置文件
/usr/local/etc/nginx/servers 虚拟主机

php5.6

brew tap exolnet/homebrew-deprecated 增加安装源
brew install exolnet/deprecated/php@5.6

错误信息

Error: Your Xcode (10.1) is too outdated.
Please update to Xcode 10.2.1 (or delete it).
Xcode can be updated from the App Store.

A: 打开App Store -> 更新 -> xcode 更新.

nginx+php 配置

server {

    listen 80;
    listen [::]:80;

    # For https
    # listen 443 ssl;
    # listen [::]:443 ssl ipv6only=on;
    # ssl_certificate /etc/nginx/ssl/default.crt;
    # ssl_certificate_key /etc/nginx/ssl/default.key;

    server_name spike.test;
    root /usr/local/var/www/spike;
    index index.php index.html index.htm;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

mac-php 默认安装

cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf
cp /private/etc/php-fpm.d/www.conf.default /private/etc/php-fpm.d/www.conf

php-fpm -D 启动php

lnmp 启动及关闭

  • brew services stop mysql@5.6 关闭
  • nginx -s stop 关闭
  • brew services stop php@5.6 关闭

实验操作记录

mac-php-最新源码编译安装、模块安装

相关资料

mac 下安装PHP5.6 redis扩展遇到的坑

发表评论