安装顺序 nginx--》php--》mysql
一 安装及使用nginx
brew search nginx
brew install nginx
nginx -v
# 启动和停止
sudo nginx
sudo nginx -s stop
sudo nginx -s reload|reopen|stop|quit # 重新加载配置,重启,停止,退出
/usr/local/etc/nginx/nignx.conf # 配置
/usr/local/etc/nginx/servers # 多域名
/usr/local/var/log/nginx # 日志
/usr/local/var/www # 默认的网站目录
# 多域名配置示例
server {
listen 8080;
server_name d.com www.d.com;
root "/data/d.com";
location / {
index index.html index.htm index.php;
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
二 安装和使用php
brew install php
php -v # 当前是8.3
// 启动和停止
brew services start php
brew services stop php
brew services restart php
brew services status php
// 配置文件地址
/usr/local/etc/php/8.3/php.ini
// php-fpm
php-fpm -v
/usr/local/etc/php/8.3/php-fpm.conf # 配置文件
sudo php-fpm # 启动
sudo killall php-fpm # 停止
三 安装和使用mysql
brew install mysql
/usr/local/etc/my.cnf # 配置
brew services start mysql
mysql.server start
四 安装redis
brew install redis
brew services start redis
redis-server /usr/local/etc/redis.conf
// php安装
pecl install redis
五 设置开机启动
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
ln -sfv /usr/local/opt/php/*.plist ~/Library/LaunchAgents
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents