mac 配置 httpd nginx php-fpm 详细记录 已解决

news2024/11/19 9:28:24

       在日常mac电脑 开发php项目一直是 httpd 方式 运行,由于有 多版本 运行的需求,docker不想用,索性用 php-fpm进行 功能处理。上次配置 是好的,但是感觉马马虎虎,这次 配置底朝天。因为配置服务器,几乎也都是傻瓜命令,  很少注意细节,大致出现问题原因,用户和组的问题。

运行代码 有  unknown 字样。错误 是 运行用户权限 有误

参考链接

        https://blog.csdn.net/qq_23306647/article/details/107442078/ 

        https://blog.51cto.com/u_15230485/5821339  //  mac 用户组的概念

nginx 详细 使用 流程

       nginx.conf 代码


#user  nobody;

user  zhenxi admin;
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;


    # 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 vhosts/*;
}

虚拟主机 fast.demo.com.conf 代码 

server {
    #监听端口
    listen    80;
 
    #虚拟主机域名
    server_name  fast.demo.com;
 
    #网站根目录
    root /Users/zhenxi/www/fast.demo.com/public;

    access_log  /usr/local/var/log/fast_demo_com.access.error_log;
    error_log /usr/local/var/log/fast_demo_com.error.log error;

    #定义路径下默认访问的文件名
    index index.php index.html;
 
    location / {

        #try_files $uri $uri/ /index.php?$query_string;
 
        #打开目录浏览功能,可以列出整个目录
        #autoindex on;

        index index.php index.html index.htm;

    }

 
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
        #try_files        $uri = 404;
        fastcgi_pass     127.0.0.1:9000;
        fastcgi_index    index.php;
        fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include          fastcgi_params;
    }

    location ~ .*\.(bmp|gif|jpg|jpeg|png|swf)$ {
        access_log off;
        expires 30d;
    }
}

日常命令

sudo nginx -c /usr/local/etc/nginx/nginx.conf

ps aux | grep nginx. 查看启动 用户权限

sudo nginx -t  测试修改是否成功

sudo nginx  启动

sudo nginx -s reload  重启

sudo brew services start nginx -d  集成命令

sudo lsof -Pni4| grep nginx   // 管道 查找进程

sudo kill -9 

php-fpm 详细使用流程

    php-fpm.conf 代码

     

;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr/local/Cellar/php@7.4/7.4.23). This prefix can be dynamically changed by using the
; '-p' argument from the command line.

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /usr/local/var
; Default Value: none
pid = run/php-fpm.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; into a local file.
; Note: the default prefix is /usr/local/var
; Default Value: log/php-fpm.log
error_log = log/php-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon

; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
;syslog.ident = php-fpm

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice

; Log limit on number of characters in the single line (log entry). If the
; line is over the limit, it is wrapped on multiple lines. The limit is for
; all logged characters including message prefix and suffix if present. However
; the new line character does not count into it as it is present only when
; logging to a file descriptor. It means the new line character is not present
; when logging to syslog.
; Default Value: 1024
;log_limit = 4096

; Log buffering specifies if the log line is buffered which means that the
; line is written in a single write operation. If the value is false, then the
; data is written directly into the file descriptor. It is an experimental
; option that can potentionaly improve logging performance and memory usage
; for some heavy logging scenarios. This option is ignored if logging to syslog
; as it has to be always buffered.
; Default value: yes
;log_buffering = no

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated.  This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; The maximum number of processes FPM will fork. This has been designed to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128

; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lowest priority)
; Note: - It will only work if the FPM master process is launched as root
;       - The pool process will inherit the master process priority
;         unless specified otherwise
; Default Value: no set
; process.priority = -19

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
daemonize = no

; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Specify the event mechanism FPM will use. The following is available:
; - select     (any POSIX os)
; - poll       (any POSIX os)
; - epoll      (linux >= 2.5.44)
; - kqueue     (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll  (Solaris >= 7)
; - port       (Solaris >= 10)
; Default Value: not set (auto detection)
;events.mechanism = epoll

; When FPM is built with systemd integration, specify the interval,
; in seconds, between health report notification to systemd.
; Set to 0 to disable.
; Available Units: s(econds), m(inutes), h(ours)
; Default Unit: seconds
; Default value: 10
;systemd_interval = 10

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options.  The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p argument)
;  - /usr/local/Cellar/php@7.4/7.4.23 otherwise
include=/usr/local/etc/php/7.4/php-fpm.d/*.conf

www.conf 代码

; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[www]

; Per pool prefix
; It only applies on the following directives:
; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr/local/Cellar/php@7.4/7.4.23) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = zhenxi
group = admin
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on
;                            a specific port;
;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses
;                            (IPv6 and IPv4-mapped) on a specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000

运行情况  分别是  9080 代表 php8.0 fpm   9074  代表 php7.4版本

php-fpm 详细 运行代码

启动 php-fpm

php-fpm -c /usr/local/etc/php/7.4/php.ini -y /usr/local/etc/php/7.4/php-fpm.conf

launchctl list | grep php  查看 9100是否启动

sudo lsof -i :9000   Mac 查看端口占用方法

sudo lsof -Pni4 | grep LISTEN | grep php  查看 php进程号

sudo kill -9 <进程ID>  关闭进程

sudo brew services start php@7.4 -d  集成命令

httpd 日常命令

Listen 80

LoadModule php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so
#LoadModule php_module /usr/local/opt/php@8.0/lib/httpd/modules/libphp.so

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>


<Directory />
    AllowOverride none
    Require all denied
</Directory>

DocumentRoot "/Users/zhenxi/www"
<Directory "/Users/zhenxi/www">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options FollowSymLinks Multiviews Indexes 

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>


# Virtual hosts
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf

httpd 虚拟主机代码

<VirtualHost *:80>
    DocumentRoot "/Users/zhenxi/www/fast.demo.com/public"
    ErrorLog "/Users/zhenxi/www/fast.demo.com/error_log"
    ServerName fast.demo.com
</VirtualHost>

 httpd 日常命令

 brew services start httpd  聚合命令

 sudo httpd   启动

 sudo lsof -Pni4 | grep LISTEN | grep httpd   查看httpd 进程

 sudo kill -9 <进程ID>  关闭进程

    日志查看命令

 tail -f -n 100  2021.log

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1035743.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

9. Java字符串支持正则表达式的方法

Java —— String字符串 1. 正则表达式2. String正则API3. Object类和toString方法4. equals方法5. 包装类及Number 1. 正则表达式 正则表达式&#xff08;Regular Expression&#xff09;&#xff1a;简称为Regex或RegExp&#xff0c;是一种用于描述字符串模式的工具 作用&…

Jmeter性能测试步骤

Jmeter多用户并发测试 第1步&#xff0c; 在安装目录下的bin文件夹下打开Jmeter&#xff0c;如下图 第2步&#xff0c;新建一个线程组 第3步&#xff0c;新建一个HTTP请求&#xff0c;这里给这个请求重命名为getMsgSum 设置HTTP请求的IP端口&#xff0c;以及路径等 第4步&#…

SoftwareTest3 - 要了人命的Bug

软件测试基础篇 一 . 如何合理的创建一个 Bug二 . Bug 等级2.1 崩溃2.2 严重2.3 一般2.4 次要 三 . Bug 的生命周期四 . 跟开发产生争执应该怎么解决 Hello , 大家好 , 又给大家带来新的专栏喽 ~ 这个专栏是专门为零基础小白从 0 到 1 了解软件测试基础理论设计的 , 虽然还不足…

C++ -- 特殊类设计

目录 设计一个类&#xff0c;不能被拷贝 C98的做法 C11的做法 设计一个类&#xff0c;只能在堆上创建对象 实现方式1 实现方式2 设计一个类&#xff0c;只能在栈上创建对象 实现方式1 方式1的优化 实现方式2 设计一个类&#xff0c;不能被继承 设计模式 什么是设计…

怒刷LeetCode的第9天(Java版)

目录 第一题 题目来源 题目内容 解决方法 方法一&#xff1a;双指针 方法二&#xff1a;递归 方式三&#xff1a;迭代 方法四&#xff1a;优先队列 第二题 题目来源 题目内容 解决方法 方法一&#xff1a;贪心算法 方法二&#xff1a;数学方法 方法三&#xff1…

iOS应用中的内存泄漏问题解决

解决iOS应用中的内存泄漏问题是非常重要的&#xff0c;因为内存泄漏可能导致应用变得缓慢或不稳定。以下是一些解决iOS内存泄漏问题的工具和方法&#xff0c;希望对大家有所帮助。北京木奇移动技术有限公司&#xff0c;专业的软件外包开发公司&#xff0c;欢迎交流合作。 工具&…

HTML5day02综合案例2

案例展示 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>注册信息</title> </head> &l…

MC互联网联机frp实现

我使用的是java版本的MC&#xff0c;联机方式如下。只是一个简单的笔记&#xff0c;所以只说重点。 主机开启局域网 整合包中自带的局域网联网插件&#xff1a;Lan Server Properties 1.10.1 在线模式选择关闭&#xff0c;不然非正版用户无法连接。 frp 具体不说了&#x…

基于MUSIC算法的二维超声波成像matlab仿真

目录 1.算法运行效果图预览 2.算法运行软件版本 3.部分核心程序 4.算法理论概述 4.1、基本原理 4.2、数学公式 4.3、实现过程 5.算法完整程序工程 1.算法运行效果图预览 2.算法运行软件版本 matlab2022a 3.部分核心程序 ..........................................…

前端react 18.2整合ckeditor富文本编辑器——配置插件、自定义toolbar工具栏

文章目录 ⭐前言⭐引入ckeditor⭐npm 包引入⭐cdn资源引入 ⭐自定义插件&#x1f496; 自定义yma16配置插件 ⭐总结⭐结束 ⭐前言 大家好&#xff0c;我是yma16&#xff0c;本文分享关于前端react整合ckeditor——配置插件、自定义toolbar工具栏。 react系列往期文章&#xff…

sylixos 5.0.4 ecs

sylixos 5.0.4 ecs 2692407267qq.com&#xff0c;更多内容请见http://user.qzone.qq.com/2692407267/

人类的态势感知可分为先验、似然、后验的三部分

人类的态势感知可以分为先验、似然和后验三个部分。这些部分描述了在不同阶段对环境的感知和理解。先验感知&#xff1a;先验感知基于先前的知识、经验和先验信息来理解环境。它利用已有的知识和模型&#xff0c;进行预测和推断&#xff0c;从而形成对当前环境的初步认知。先验…

Go 并发可视化解释 - sync.Mute

在学习 Go 编程语言时&#xff0c;您可能会遇到这句著名的格言&#xff1a;“不要通过共享内存来进行通信&#xff1b;相反&#xff0c;通过通信来共享内存。” 这句话构成了 Go 强大并发模型的基础&#xff0c;其中通道&#xff08;channels&#xff09;作为协程之间的主要通信…

unity自己对象池的使用

unity出了自己的对象池 这里记录一下用法 命名空间就是这个 一般有两种用法&#xff0c;第一种是在using里面获取&#xff0c;脱离这个域就释放。第二种是在Get和Release配合使用 // This version will only be returned to the pool if we call Release on it.//只有使用Re…

【计算机基础】让我们重新认识一下Visual Stduio及其操作,知识点汇总!!

&#x1f4e2;&#xff1a;如果你也对机器人、人工智能感兴趣&#xff0c;看来我们志同道合✨ &#x1f4e2;&#xff1a;不妨浏览一下我的博客主页【https://blog.csdn.net/weixin_51244852】 &#x1f4e2;&#xff1a;文章若有幸对你有帮助&#xff0c;可点赞 &#x1f44d;…

远程连接ubuntu的mysql服务报错10061的解决方案

远程连接ubuntu的mysql服务报错10061的解决方案 我的解决方案是&#xff1a; 首先&#xff1a;进入/etc/mysql/mysql.conf.d文件夹下面&#xff0c;编辑mysqld.cnf文件。如图所示&#xff1a; 然后&#xff1a;将bind-address那一行改成bind-address 0.0.0.0.如图所示&…

李宏毅hw-8,auto-encoder for anomaly_detection

一、查漏补缺、熟能生巧: 主要是mu均值 和 logvar对数标准差 std标准差的 处理方面不熟练 二、代码解读&#xff1a; 1.sample_code中提供了3种model&#xff1a;fcn_model 、 conv_model 和 vae_model: (1)fcn_model的结构非常好理解&#xff1a; 就是通过全连接层进行降维…

子比主题v7.4绕授权接口源码

子比主题7.4绕授权接口源码&#xff0c;仅包含api文件仅供学习参考&#xff01;正版子比主题7.4请到官方下载这里不提供。 使用方法: 1.搭建一个站点&#xff0c;绑定apizibl.com域名&#xff0c;并开启SSL (随便找个域名的证书就行) 2.上传以上源码&#xff0c;并配置好伪静…

LeetCode75-06:移动零

移动零 初版(bug) func moveZeroes(nums []int) {if len(nums) 1{return}// 设置两个指针fp1,fp2分别指向第一个元素和第二个元素&#xff0c;// 两种情况// 假如指针fp1指向元素为零// 1) *fp2!0&#xff0c;则交换。// 2) *fp20&#xff0c;则fp2后移,直至*fp2!0,与fp1交换…

【刷题笔记9.24】LeetCode:对称二叉树

LeetCode&#xff1a;对称二叉树 一、题目描述&#xff1a; 给你一个二叉树的根节点 root &#xff0c; 检查它是否轴对称。 二、题目分析 题目&#xff1a;对称二叉树 1、p 指针和 q 指针一开始都指向这棵树的根 2、随后 p 右移时&#xff0c;q 左移&#xff0c;p 左移时&a…