zoukankan      html  css  js  c++  java
  • Mac下PHP7.1+Nginx安装和配置

    https://blog.csdn.net/haiyanggeng/article/details/79186982

    PHP:7.1.13
    Nginx:1.12.2

    1. 安装PHP
    # 添加源
    brew tap homebrew/dupes
    brew tap homebrew/versions
    brew tap homebrew/homebrew-php
    #更新源
    brew update
    #安装
    brew install php71 --with-imap --with-tidy --with-debug --with-pgsql --with-mysql --with-fpm
    #验证(版本应该为7.1.13)
    php -v
    可能出现的问题:
    1.Error: The brew link step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink sbin/php-fpm /usr/local/sbin is not writable.
    解决方法:

    sudo mkdir sbin
    sudo chown -R $(whoami) $(brew --prefix)/*
    brew link php71

    2.php -v版本为php7.1.7(Mac自带的PHP版本),不是我们安装的最新的PHP7.1.13
    解决方法:

    #编辑~/.bash_profile,添加
    export PATH=/usr/local/sbin:/usr/local/bin:$PATH
    #保存.bash_profile,并启用
    source ~/.bash_profile

    2. 安装Nginx
    brew install nginx

    3. 修改php-fpm文件
    #1. 修改文件名
    sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf
    #2. 编辑php-fpm.conf文件,修改error_log
    error_log = /usr/local/var/log/php-fpm.log

    4. 修改nginx配置文件
    编辑/usr/local/etc/nginx/mginx.conf文件

    # 1.修改文件location部分
    location / {
    root /Users/user_name/work/phpwork; #项目目录路径
    index index.html index.htm index.php; #添加index.php
    }
    # 2. 修改server下的location ~.php$部分,默认是注释掉的,要去掉注释。
    location ~ .php$ {
    root /Users/user_name/work/phpwork;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    #修改的部分
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

    5. 在/Users/user_name/work/phpwork/下创建index.php文件
    <?php
    phpinfo();
    ?>

    6. 启动php-fpm和nginx
    # 启动php-fpm
    sudo /usr/local/sbin/php71-fpm start
    # 停止php-fpm
    sudo /usr/local/sbin/php71-fpm stop
    # 启动nginx
    sudo nginx
    # 停止nginx
    sudo nginx -s stop
    # 修改nginx.conf文件后,重新加载配置文件
    sudo nginx -s reload
    ---------------------
    作者:morven936
    来源:CSDN
    原文:https://blog.csdn.net/haiyanggeng/article/details/79186982
    版权声明:本文为博主原创文章,转载请附上博文链接!

    ERROR: unable to bind listening socket for address ’127.0.0.1:9000′

    解决办法:

    killall php-fpm

    然后重启即可。

  • 相关阅读:
    KubeSphere 社区开源负载均衡器 Porter 进入 CNCF 云原生全景图
    The Overview of KubeSphere 3.0
    对象存储在无人驾驶高精度地图的场景实践
    谁来打通混合云“最后一公里”?唯有容器混合云
    QingStor 对象存储架构设计及最佳实践
    如何通过IAM打造零信任安全架构
    智能家居巨头 Aqara 基于 KubeSphere 打造物联网微服务平台
    微信小程序集成jenkins自动打码
    windows运行python,提示import win32file ImportError: DLL load failed: 找不到指定的程序。
    centos7搭建easy-mock服务
  • 原文地址:https://www.cnblogs.com/rxbook/p/10130032.html
Copyright © 2011-2022 走看看