• home > OS > MacOS > Tutorials >

    mac搭建php(mysql)运行环境—搭建xmapp

    Author:zhoulujun Date:

    首先可以复习下:MAC配置mysql:mac下启动 停止 重启mysql服务brew install安装的软件放在什么地方mac启动MySQL报错:ERROR 2002 (HY000

    如果英文好,可看这个:

    https://wpbeaches.com/updating-to-php-versions-7-4-and-8-on-macos-12-monterey/

    https://chrisbergeron.com/2021/03/17/macos-11-big-sur-nginx-php-and-mysql/



    首先可以复习下:



    准备环境:

    mac brew安装php


    brew install php@7.1

    安装完后,查看php版本

    php -v


    配置php

    修改配置 php-fpm.conf,一般在/usr/local/etc/php下(如果php-fpm.conf中不存在,则查找php-fpm.d目录)

    vim php-fpm.conf

    listen = 127.0.0.1:9000

    启动PHP7.1

    brew services start php@7.1

    这时php-fpm会监听9000端口,修改nginx的配置文件改为端口为9000(一般在/usr/local/etc/nginx/下面)

    echo 'export PATH="/usr/local/opt/php@8.1/bin:$PATH"' >> ~/.zshrc
    echo 'export PATH="/usr/local/opt/php@8.1/sbin:$PATH"' >> ~/.zshrc
    export LDFLAGS="-L/usr/local/opt/php@8.1/lib"
    export CPPFLAGS="-I/usr/local/opt/php@8.1/lib/include"
    brew services start php@8.1


    mac brew安装mysql

    brew install mysql

    启动mysql

    mysql.server start

    查看mysql 版本

    mysql --version

    mac brew安装nginx

    brew install nginx

    安装完毕

    主页的文件在/usr/local/var/www 文件夹下

    对应的配置文件地址在/usr/local/etc/nginx/nginx.conf

    mac 使用brew安装nginx 各种命令

    • 启动:brew services start nginx       或者         sudo brew services start nginx

    • 重启:brew services restart nginx        或者         sudo brew services restart nginx

    • 停止:brew services stop nginx           或者            sudo brew services stop nginx

    • 查看:cat usr/local/etc/nginx/nginx.conf

    • 编辑:vi usr/local/etc/nginx/nginx.conf

    重新启动nginx

    nginx -s reload

    nginx 开启目录展示

    server {
           listen       8080;
           server_name  localhost;
    
           #charset koi8-r;
    
           #access_log  logs/host.access.log  main;
    
           root /Users/andyzhou/www/;
           index  index.html index.htm;
           autoindex on;   #开启nginx目录浏览功能
           autoindex_exact_size off;   #文件大小从KB开始显示
           autoindex_localtime on;   #显示文件修改时间为服务器本地时间
    
           #error_page  404              /404.html;
    
           # redirect server error pages to the static page /50x.html
           #
           error_page   500 502 503 504  /50x.html;
           location = /50x.html {
               root   html;
           }
    
       }

    查看nginx版本

    nginx -v


    Brew 卸载MySql以及安装Mysql

    1. brew remove mysql

    2. brew cleanup

    3. launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

    4. rm ~/Library/LaunchAgents/com.mysql.mysqld.plist

    5. sudo rm -rf /usr/local/var/mysql


    安装xampp

    https://www.apachefriends.org/index.html

    上面的都可以解决,懒人好办法

    安装



    参考文章:

    MacOS12安装PHP7.4、composer、Nginx https://learnku.com/articles/59553





    转载本站文章《mac搭建php(mysql)运行环境—搭建xmapp》,
    请注明出处:https://www.zhoulujun.cn/html/OS/Mac/MacOSTutorials/8799.html

    下一篇:Last page