Luckean's blog Luckean's blog
首页
  • 前端文章

    • JavaScript
  • 项目笔记

    • 项目笔记
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • HTML
  • CSS
  • flutter 布局
  • dart 数组的定义
  • java目录
  • jenkins配置
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • vscode vim 结合使用
  • vscode vim 汇总
  • vscode快捷键
  • vscode自定义快捷键
  • typora 使用技巧
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档

Luckean

前端界的小学生
首页
  • 前端文章

    • JavaScript
  • 项目笔记

    • 项目笔记
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • HTML
  • CSS
  • flutter 布局
  • dart 数组的定义
  • java目录
  • jenkins配置
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • vscode vim 结合使用
  • vscode vim 汇总
  • vscode快捷键
  • vscode自定义快捷键
  • typora 使用技巧
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
  • php 学习笔记

    • day 01
  • php安装
  • laravel 初始化项目
  • mac 安装mysql
  • Mac配置nginx+php
    • 第一步:检查本地有没有PHP:输入php -v 命令
      • 修改php-fpm.conf文件
      • 重启brew services restart php@7.4
    • 第二步:安装nginx
    • 验证
  • phpstorm 安装
  • phpstrom debug 无法连接
  • mac 修改hosts成功但无效
  • mac 程序安装失败解决
  • 后端
Luckean
2023-08-23
目录

Mac配置nginx+php

# Mac配置nginx+php(brew安装nginx+php)

# 第一步:检查本地有没有PHP:输入php -v 命令

brew install php
brew services start php@7.4
brew services list #查看运行状态
sudo lsof -i -P -n | grep 9000 #查看端口有没有fpm开启,fpm默认端口是9000,联动nginx的fastcgi_pass
1
2
3
4
# 修改php-fpm.conf文件

找到这个文件:/opt/homebrew/etc/php/7.4/php-fpm.conf

把pid 前面的分号删除,pid = run/php-fpm.pid

把error_log前面的分号删除,error_log = log/php-fpm.log

# 重启brew services restart php@7.4

# 第二步:安装nginx

brew install nginx
brew services start nginx
brew services restart nginx

1
2
3
4

查看信息

brew info nginx

Docroot is: /opt/homebrew/var/www

The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To restart nginx after an upgrade:
  brew services restart nginx
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/nginx/bin/nginx -g daemon\ off\;
1
2
3
4
5
6
7
8
9
10
11
12
13
#nginx 程序所在目录 /opt/homebrew/opt/nginx/bin/nginx
/opt/homebrew/opt/nginx/bin/nginx -t # 检测语法,brew services restart nginx错误一样运行成功


sudo nginx                   #启动nginx服务
sudo nginx -s reload    #重启nginx服务
sudo nginx -s stop       #停止nginx服务
sudo nginx -t                #检测配置文件中是否存在语法错误
1
2
3
4
5
6
7
8

nginx/server/csm.test.conf

官网laravel:https://laravel.com/docs/10.x/deployment

server {
    listen 80;
    listen [::]:80;
    server_name csm.test;
    root /Users/luxiaoqing/project/test/blog-study/server/public;
 
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
 
    index index.php index.html index.htm;
 
    charset utf-8;
 
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
 
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
 
    error_page 404 /index.php;
 
    location ~ \.php$ {
        fastcgi_pass  127.0.0.1:9000; # fpm的端口
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
 
    location ~ /\.(?!well-known).* {
        deny all;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

# 验证

进入目录:cd /usr/local/var/www/       
创建文件:touch index.php
编辑文件:sudo vi index.php 
输入:<?php phpinfo(); ?>   保存并退出
1
2
3
4

http://localhost/index.php 验证

上次更新: 2023/08/23, 15:41:19
mac 安装mysql
phpstorm 安装

← mac 安装mysql phpstorm 安装→

最近更新
01
p12文件的生成
08-22
02
mac 程序安装失败解决
08-18
03
phpstrom debug 无法连接
08-15
更多文章>
Theme by Vdoing | Copyright © 2022-2023 Lucking | 粤ICP备2022078904号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式