美文网首页
mac php开发环境配置

mac php开发环境配置

作者: 热河hot | 来源:发表于2018-07-15 20:41 被阅读0次

    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: 项目目录/usr/local/var/www/
    配置文件 /usr/local/etc/nginx/nginx.conf
    虚拟域名配置 /usr/local/etc/nginx/servers/.conf;


    image.png

    4.配置虚拟域名,device.conf内容

    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;
    
        #####默认请求
        location / {
            root   /usr/local/var/www/device/webroot/index.php;      #定义服务器的默认网站根目录位置
            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;
        }
    
        # 定义错误提示页面
        error_page   500 502 503 504 /50x.html;
             location = /50x.html {
             root   html;
        }
    
    
        #PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI默认配置.
        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添加扩展

    例如安装redis扩展下载好解压,cd到redis扩展目录
    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
    安装成功会说明扩展安装目录
    /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

    相关文章

      网友评论

          本文标题:mac php开发环境配置

          本文链接:https://www.haomeiwen.com/subject/xcwppftx.html