首页 > 系统相关 >macbook(M1芯片)搭建php+nginx运行环境

macbook(M1芯片)搭建php+nginx运行环境

时间:2024-03-24 16:33:38浏览次数:31  
标签:index server nginx html M1 location php

macbook(M1芯片)搭建php+nginx运行环境

  1. php

    1. 安装php

      brew install php
      // 低版本php需要这样安装
      brew install shivammathur/php/[email protected]
      
    2. 配置环境变量(低版本的php才需要)

      echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
      echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
      
    3. 刷新环境变量(低版本的php才需要)

      source ~/.zshrc
      
    4. php-fpm的使用

      1. 启动

        sudo php-fpm
        
      2. 关闭

        sudo kill -int [pid]
        
  2. nginx

    1. 安装nginx

      brew install nginx
      
    2. 配置nginx(/opt/homebrew/etc/nginx/nginx.conf)

      1. 单个配置

        #user  nobody;
        worker_processes  1;
        
        #error_log  logs/error.log;
        #error_log  logs/error.log  notice;
        #error_log  logs/error.log  info;
        
        #pid        logs/nginx.pid;
        
        
        events {
            worker_connections  1024;
        }
        
        
        http {
            include       mime.types;
            default_type  application/octet-stream;
        
            #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
            #                  '$status $body_bytes_sent "$http_referer" '
            #                  '"$http_user_agent" "$http_x_forwarded_for"';
        
            #access_log  logs/access.log  main;
        
            sendfile        on;
            #tcp_nopush     on;
        
            #keepalive_timeout  0;
            keepalive_timeout  65;
        
            #gzip  on;
        
            server {
                listen       8080;
                server_name  localhost;
        
                #charset koi8-r;
        
                #access_log  logs/host.access.log  main;
        
                location / {
                    root   html;
                    index  index.html index.htm;
                }
        
                #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;
                }
        
                # proxy the PHP scripts to Apache listening on 127.0.0.1:80
                #
                #location ~ \.php$ {
                #    proxy_pass   http://127.0.0.1;
                #}
        
                # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
                #
                #location ~ \.php$ {
                #    root           html;
                #    fastcgi_pass   127.0.0.1:9000;
                #    fastcgi_index  index.php;
                #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
                #    include        fastcgi_params;
                #}
        
                # deny access to .htaccess files, if Apache's document root
                # concurs with nginx's one
                #
                #location ~ /\.ht {
                #    deny  all;
                #}
            }
        
        
            # another virtual host using mix of IP-, name-, and port-based configuration
            #
            #server {
            #    listen       8000;
            #    listen       somename:8080;
            #    server_name  somename  alias  another.alias;
        
            #    location / {
            #        root   html;
            #        index  index.html index.htm;
            #    }
            #}
        
        
            # HTTPS server
            #
            #server {
            #    listen       443 ssl;
            #    server_name  localhost;
        
            #    ssl_certificate      cert.pem;
            #    ssl_certificate_key  cert.key;
        
            #    ssl_session_cache    shared:SSL:1m;
            #    ssl_session_timeout  5m;
        
            #    ssl_ciphers  HIGH:!aNULL:!MD5;
            #    ssl_prefer_server_ciphers  on;
        
            #    location / {
            #        root   html;
            #        index  index.html index.htm;
            #    }
            #}
          	# 配置子目录下的文件
            include servers/*;
            # 配置子目录下的文件
            include conf.d/*.conf;
        }
        
        
      2. 多个配置(这样可以避免修改默认文件,可以单独分开文件)

        1. 直接在servers文件加下创建一个文件(命名随便)

        2. 然后配置

          server {
              listen       8888;
              server_name  localhost;
            	# 项目目录
              root  /opt/homebrew/var/www/1.4.0.20230711/public;
              location / {
                # 伪静态
               	if (!-e $request_filename) {
             			rewrite  ^(.*)$  /index.php?s=/$1  last;
             			break;
              	}
                  index  index.html index.htm index.php;
              }
          
          
              error_page   500 502 503 504  /50x.html;
              location = /50x.html {
                  root   /Users/weiyonglin/Downloads/1.4.0.20230711/public;
              }
          		// 配置解析php
              location ~ \.php(.*)$ {
                  fastcgi_pass   127.0.0.1:9000;
                  fastcgi_index  indx.php;
                  fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                  fastcgi_param PATH_INFO $1;
                  include        fastcgi_params;
              }
          
              location ~ /\.ht {
                  deny all;
              }
          
          }
          
    3. 启动nginx

      sudo nginx
      
    4. 关闭nginx

      sudo nginx -s stop
      
    5. 重启nginx

      sudo nginx -s reload
      

标签:index,server,nginx,html,M1,location,php
From: https://www.cnblogs.com/00544--/p/18092602

相关文章

  • PhpStrom启动报错, java.net.BindException: Address already in use: bind
    问题描述:今天启动phpstromIDE时,突然报错,报错信息如下图:问题分析1.不正确关闭应用(强制关闭):可能是之前启动了一个本地web服务占了端口,在没有停掉服务,直接关闭IDE导致的(尝试了重启电脑也没解决)2.其他应用占用端口:安装了Hyper-V导致端口被占用?显然我的是第一种情况问题解决......
  • 补充--关于nginx服务器多个网站如何设置404的问题?
    补充--关于nginx服务器多个网站如何设置404的问题?需求1:设置多个网站404页面为一个都需配置网站的nginx.conf,以上面的多网站为例,404发布目录下,每个的nginx.conf1.知道每个网站的(nginx.conf)配置路径www.it.com/usr/local/nginx/conf/nginx.confbbs.it.com/usr/loc......
  • nginx挂载配置文件和日志-静态目录-方式二
    环境说明linux系统版本:lsb_release-a docker版本:docker-v Nginx镜像版本:1.24.0 不同的操作系统以及软件版本,可能会遇到不一样的问题,一定要注意版本问题。 .1.创建需要挂载的文件目录,比如html和log,还有配置文件nginx.conf.自己首先创建一个目录,结构如下。 ......
  • ECM1410面向对象程序设计
    ECM1410面向对象程序设计课程课业本课程包含全部模块评估的100%。这是一个双人练习,请注意大学关于合作和抄袭的指导方针手册(exeter.ac.uk/学生/行政管理/投诉和申诉/学术不端行为/)。本评估涵盖了使用Java编程的一系列面向对象概念的使用和实现您在ECM1410中所涵盖的语言。这项课......
  • 在线客服系统php网站源码 支持消息预知
    新增消息预知,消息撤回,消息已读未读,修复需要刷新才能收到消息修复客户来源地址修复消息提示音修复桌面推送提醒下载地址:消息预知在线客服系统php网站源码-麦田吧要求服务器环境:宝塔面板,Nginx1.16-1.18,7.2.23<php<7.3,Mysql5.6-Mysql5.7站点设置点击伪静态选择thin......
  • 【漏洞复现】福建科立迅通信指挥调度平台pwd_update.php SQL注入漏洞 (CVE-2024-2621)
        免责声明:文章来源互联网收集整理,请勿利用文章内的相关技术从事非法测试,由于传播、利用此文所提供的信息或者工具而造成的任何直接或者间接的后果及损失,均由使用者本人负责,所产生的一切不良后果与文章作者无关。该文章仅供学习用途使用。          ......
  • thinkphp6中jwt的使用
    thinkphp6中jwt的使用安装JWT插件composerrequirefirebase/php-jwt创建User模型phpthinkmake:modelUser创建User控制器phpthinkmake:controllerUser封装创建token函数,要在User模型中创建//加密的秘钥protected$key="test";//过期时间protect......
  • 笔记:J1939协议之DM1
    目标:学习SAE1939-73中的DM1,尤其是多包故障的传输规则一、基本概念SAE1939-73即CAN总线J1939协议的应用层-诊断符号缩写的含义DM1诊断信息1,当前故障码DM2诊断信息2,历史故障码DM3诊断信息3,历史故障码的清除/复位DM4诊断信息4,停帧参量DM5诊断信息5,诊断准备就绪DM6......
  • 深入理解PHP+Redis实现分布式锁的相关问题
    概念PHP使用分布式锁,受语言本身的限制,有一些局限性。通俗理解单机锁问题:自家的锁锁自家的门,只能保证自家的事,管不了别人家不锁门引发的问题,于是有了分布式锁。分布式锁概念:是针对多个节点的锁。避免出现数据不一致或者并发冲突的问题,让每个节点确保在任意时刻只有一个节点能够......
  • 文件上传一-WEB攻防-PHP应用&文件上传&函数缺陷&条件竞争&二次渲染&黑白名单&JS绕过9
    演示案例:PHP-原生态-文件上传-前后端验证PHP-原生态-文件上传-类型文件头验证PHP-原生态-文件上传-后缀黑白名单验证PHP-原生态-文件上传-解析配置&二次渲染PHP-原生态-文件上传-逻辑缺陷&函数缺陷#学习前必读:1、课前一定要明白:无文件解析安全问题上,格式解析是一......