Mac 配置Nginx + php + mysql
系统 mojave 10.14.3
1,安装homebrew
中文官网地址 https://brew.sh/index_zh-cn.html
安装命令 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2,安装nginx
brew install nginx
3,启动nginx
sudo nginx
4,重启 nginx
sudo nginx -s reload
5,cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf
并 修改 php-fpm.conf文件 error_log 配置为 /usr/local/var/log/php-fpm.log,
6 , 更改 cp www.conf.default www.conf
7 ,开启 php-fpm: sudo php-fpm -D
//配置文件
server {
listen 80;
server_name www.hello.com;
root /Users/koloor/wwwroot/hello;
location / {
index index.html index.htm index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
#测试配置是否有语法错误
nginx -t
#打开 nginx
sudo nginx
#重新加载配置|重启|停止|退出 nginx
nginx -s reload|reopen|stop|quit
brew 安装 Mysql
brew info mysql 检查依赖
brew install mysql 安装mysql 默认是最新版本
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
启动mysql mysql.server start
安装完成 初始化设置 : mysql_secure_installation
#启动
brew services start mysql
#重启
brew services restart mysql
#停止
brew services stop mysql
#查看所有可由Homebrew管理的服务
brew services list