• nginx降权+安装php


    nginx降权
    使用普通用户启动Nginx

    1. 为什么要让nginx服务使用普通用户
      默认情况下,nginx的master进程使用的是root用户,worker进程使用的是nginx指定的普通用户,使用root用户跑nginx的master进程有两个大问题:
      (1)管理权限必须是root,这就使得最小化分配权限原则遇到问题
      (2)使用root跑nginx服务,一旦网站出现漏洞,用户就可以很容易获得服务器的root权限

    2. 给nginx服务降权的解决方案
      (1)给nginx服务降权,用inca用户跑nginx服务,给开发及运维人员设置普通账号,只要与inca同组即可管理nginx
      (2)开发人员使用普通账户即可管理nginx服务及站点下的程序和日志
      (3)采取项目负责制,即谁负责项目维护,出现问题就是谁负责
      创建普通用户

    root@ubuntu:~# useradd -d /home/test -m test
    root@ubuntu:~# passwd test
    New password: 
    Retype new password: 
    passwd: password updated successfully
    root@ubuntu:~# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    创建相关文件
    $ mkdir nginx
    $ cd nginx
    $ mkdir conf logs www sbin
    使用root用户copy配置文件中网页支持类型文件

    root@ubuntu:/www/env/nginx/conf# cp /www/env/nginx/conf/mime.types /home/test/nginx/conf/
    
    • 1

    使用root用户拷贝nginx配置文件

    root@ubuntu:~# cp /www/env/nginx/conf/nginx.conf /home/test/nginx/conf/
    
    • 1

    设置权限

    root@ubuntu:~# chown -R test:test /www/env/nginx/
    
    • 1
    worker_processes  4;
    worker_rlimit_nofile 65535;
    error_log  /home/test/nginx/logs/error.log;
    user test test;
    pid  /home/test/nginx/logs/nginx.pid;
    events {
        use epoll;
        worker_connections  1024;
    }
    http {
        include       /home/test/nginx/conf/mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
        server {
            listen       8080;
            server_name  localhost;
            root  /home/test/nginx/www;
            location / {
                index  index.html index.htm;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
            access_log  /home/test/nginx/logs/access.log;
        }
     
    
    • 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

    安装 PHP
    PHP即“超文本预处理器”,是一种通用开源脚本语言。PHP是在服务器端执行的脚本语言,与C语言类似,是常用的网站编程语言。PHP独特的语法混合了C、Java、Perl以及 PHP 自创的语法。利于学习,使用广泛,主要适用于Web开发领域。
    1.下载和解压

    cd /usr/local/src/ #切换目录
    wget http://cn2.php.net/distributions/php-7.4.10.tar.bz2 #下载
    wget http://xmlsoft.org/downloads.html/
    tar jxvf php-7.4.10.tar.bz2 #解压
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述
    2.安装

    systemctl status php7.4-fpm
    chmod 777 /run/php/php7.2-fpm.sock
    
    • 1
    • 2
  • 相关阅读:
    Reinforcement Learning 强化学习(四)
    数据结构之带头双向循环链表
    领域驱动设计:从后端到前端
    idea软件_启动出错&永久办法&leetcode关联
    隆云通空气温湿,光照三合一传感器
    R语言确定聚类的最佳簇数:3种聚类优化方法
    “无法为保留分区分配驱动器号”的解决
    直播间自动点赞第一章:MouseEvent 实现根据坐标X,Y自动点击浏览器的效果
    Prometheus PromQL及传统部署 Alertmanager 发送告警
    谈谈我对云原生与软件供应链安全的思考
  • 原文地址:https://blog.csdn.net/WHearTBeat/article/details/128002738