whcoding whcoding
首页
归档
关于
GitHub (opens new window)
首页
归档
关于
GitHub (opens new window)
  • ngxin

    • nginx 常用配置
    • 给你的网站免费配置 https
    • 更改 nginx php-fpm 运行用户
      • Nginx 设置允许跨域
    • Nginx
    • ngxin
    whcoding
    2020-04-10
    目录

    更改 nginx php-fpm 运行用户

    # 为什么要更改运行用户

    • nginx 和 fpm 默认运行用户的 www-data
    • 再部署项目的时候 一般来说都是用自己创建的用户去 git clone 代码 所以 clone 下来的代码文件 都属于这个用户, 所以在运行项目的时候就会有很多权限的问题, 所以要改变 nginx 和 fpm 的默认运行用户

    # 更改 nginx 默认用户

    vi /etc/nginx/nginx.conf
    
    1
    user 更改这里;
    worker_processes auto;
    pid /run/nginx.pid;
    include /etc/nginx/modules-enabled/*.conf;
    
    events {
            worker_connections 768;
            # multi_accept on;
    }
    
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    # 更改 php-fpm 默认用户

    /etc/php/7.3/fpm/pool.d/www.conf
    
    1
    ..... 
    user = 更改这里
    group = 更改这里
    
    ....
    listen.owner = 更改这里
    listen.group = 更改这里
    
    1
    2
    3
    4
    5
    6
    7

    最后要记得 重启 nginx 和 php-fpm

    上次更新: 2022/08/30, 23:31:20
    给你的网站免费配置 https
    Nginx 设置允许跨域

    ← 给你的网站免费配置 https Nginx 设置允许跨域→

    Theme by Vdoing | Copyright © 2018-2023
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式