nginx配置php的心得记录

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

nginx.conf可以配置 不同的用户

#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       80;
        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;
    #    }
    #}

}

里面配置php的启动的走的sock

然后php的sock里面也可以配置不同用户

1、

创建第二个php-fpm进程所使用的主配置文件

复制主配置文件 cp /etc/php-fpm.conf /etc/php-fpm2.conf
2复制子配置文件 cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www2.conf (注意子配置文件名会跟我这里有所不同注意www.conf是否存在用存在的作为复制对象)

3更改子配置文件 www2.conf的配置

listen = 127.0.0.1:9001 – 更改www2.conf 的监听端口

4更改主配置文件php-fpm2.conf的配置

include=/etc/php-fpm.d/www2.conf – 将配置改成复制出来的www2.conf

pid = /run/php-fpm/php-fpm2.pid – 区分php-fpm2的pid 方便之后对该php-fpm进行关闭启动

5启动php-fpm2.conf

linux命令/usr/sbin/php-fpm -y /etc/php-fpm2.conf – 启动php-fpmphp-fpm启动脚本 -y php-fpm配置。对该命令不解的自行百度php-fpm命令解析

6检查是否成功启动php-fpm2

linux命令ps aux | grep php-fpm

2、

like this /opt/php-5.6.3/etc/fpm.d/user1.conf

[user1]
listen.owner = user1
listen.group = user1
user = user1
group = user1
listen = /opt/php-5.6.3/sockets/user1.sock
listen.mode = 0666
阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: nginxphp

“nginx配置php的心得记录” 的相关文章

nginx中ngx1年前 (2023-02-02)
【Nginx01】Ngnix入门1年前 (2023-02-02)
PHP MySQL 插入数据1年前 (2023-02-02)
Nginx应用场景1年前 (2023-02-02)
利用FPM打包nginx1年前 (2023-02-02)
PHP 数据库 ODBC1年前 (2023-02-02)
Nginx入门与应用1年前 (2023-02-02)
PHP MySQL Update1年前 (2023-02-02)