mac php開發(fā)環(huán)境配置

1 terminal安裝 myzsh,hombrew

myzhs:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2 安裝nginx,mysql,php(具體版本按需安裝)

brew install nginx
brew install mysql
brew install php

3 文件路徑

nginx: 項(xiàng)目目錄/usr/local/var/www/
配置文件 /usr/local/etc/nginx/nginx.conf
虛擬域名配置 /usr/local/etc/nginx/servers/.conf;


image.png

4.配置虛擬域名,device.conf內(nèi)容

server {
    listen       80;
    server_name  local_device.dqd.com;
    access_log  /usr/local/etc/nginx/logs/device.access.log;
    error_log  /usr/local/etc/nginx/logs/device.error.log;

    #####默認(rèn)請求
    location / {
        root   /usr/local/var/www/device/webroot/index.php;      #定義服務(wù)器的默認(rèn)網(wǎng)站根目錄位置
        index index.php index.html index.htm;   #定義首頁索引文件的名稱
    #       fastcgi_pass  local.dongqiudi.com;
        fastcgi_param  SCRIPT_FILENAME  /usr/local/var/www/device/webroot/index.php/$fastcgi_script_name;
        include fastcgi_params;

        try_files $uri $uri/ /index.php?$query_string;
    }

    # 定義錯(cuò)誤提示頁面
    error_page   500 502 503 504 /50x.html;
         location = /50x.html {
         root   html;
    }


    #PHP 腳本請求全部轉(zhuǎn)發(fā)到 FastCGI處理. 使用FastCGI默認(rèn)配置.
    location ~ \.php$ {
         root /usr/local/var/www/device/webroot/index.php;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
         fastcgi_param SCRIPT_FILENAME /usr/local/var/www/device/webroot/index.php/$fastcgi_script_name;
         include fastcgi_params;
    }


    #禁止訪問 .htxxx 文件
    location ~ /\.ht {
         deny all;
    }

 }

編輯hosts文件
vim /etc/hosts添加
127.0.0.1 local_device.dqd.com

重啟nginx

sudo nginx -s stop
sudo nginx

5 php添加擴(kuò)展

例如安裝redis擴(kuò)展下載好解壓,cd到redis擴(kuò)展目錄
1./usr/local/Cellar/php@7.0/7.0.30_1/bin/phpize
2../configure --with-php-config=/usr/local/Cellar/php@5.6/5.6.36_1/bin/php-config
3.make && make install
安裝成功會說明擴(kuò)展安裝目錄
/usr/local/Cellar/php@7.0/7.0.30_1/pecl/20151012
4.編輯php.ini加入
[redis] extension=/usr/local/Cellar/php@7.0/7.0.30_1/pecl/20151012/redis.so
重啟php
pkill php-fpm
/usr/local/Cellar/php@7.0/7.0.30_1/sbin/php-fpm -R

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容