Skip to content

Instantly share code, notes, and snippets.

@kevinzhow
Last active November 30, 2022 16:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinzhow/647f2ab86a7032179b77bcdff250f465 to your computer and use it in GitHub Desktop.
Save kevinzhow/647f2ab86a7032179b77bcdff250f465 to your computer and use it in GitHub Desktop.
在 macOS 10.12 配置 Nginx+MySQL+PHP+Discuz

详细的英文配置

https://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/

安装 Xcode

xcode-select --install

安装 Homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew update && brew upgrade

安装 PHP56

brew tap homebrew/dupes

brew tap homebrew/php/php56

brew install --without-apache --with-fpm --with-mysql homebrew/php/php56

配置 PHP 命令行环境

bash 环境

echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile && . ~/.bash_profile

zsh 如果是 zsh

echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc && . ~/.zshrc

配置 PHP 启动

mkdir -p ~/Library/LaunchAgents

cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/

launch it

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

brew services start homebrew/php/php56

安装 MySQL

brew install mysql

brew services start mysql

配置 MySQL

mysql_secure_installation

安装 Nginx

brew install nginx

brew services start nginx

安装 Discuz

cd ~/

mkdir data/www

cd data/www

brew install wget

wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip

unzip Discuz_X3.2_SC_UTF8.zip

mv upload/* ./

配置 nginx 启动 Discuz

code /usr/local/etc/nginx/servers/discuz.conf

pwd 查看当前路径,修改下面 root 和 fastcgi_param 的地址

server
{
    listen 8002;
    server_name localhost;
    index index.html index.htm index.php;
    root /Users/kevinzhow/data/www; 
    location ~ \.php$ {
        include fastcgi_params;
        # fastcgi_pass unix:/tmp/www.sock;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /Users/kevinzhow/data/www$fastcgi_script_name;
    }
}

fastcgi_pass 的地址需要查看 /usr/local/etc/php/5.6/php-fpm.conf 的 listen

brew services restart nginx

访问

http://localhost:8002

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment