Windows下cygwin安装nginx、php7.1-配置Nextcloud

./setup-x86.exe -m http://mirrors.aliyun.com/cygwin/ -q -P nginx,php,php-fpm,php-mysql,php-gd,php-pdo,php-xml,php-mbstring,php-zip,php-mysqlnd,php-pdo-dblib,php-zlib,php-xmlwrite,php-xmlrpc,php-xmlreader,php-sqlite3,php-pdo-sqlite,php-simplexml,php-devel,php-json,sqlite

./setup-x86.exe -m http://mirrors.aliyun.com/cygwin/ -q -P sqlite3,sygrunsrv

/usr/sbin/nginx.exe
/usr/sbin/php-fpm.exe

#监听php-fpm
#设置好对应的域名
#如下根据自己的情况修改,也适用Linux系统配置


/etc/nginx/conf.d/nextcloud.conf

upstream php-nextcloud {
    server unix:/run/php-fpm/nextcloud.sock;
}

##############################################
mkdir -p /etc/nginx/conf.d/
cat >/etc/nginx/conf.d/https.nextcloud.conf<<EOF

    server {

        listen       80;
        server_name  ************;
        root         /home;


        location / {
        #root /usr/share/;

        # Add headers to serve security related headers
        # Before enabling Strict-Transport-Security headers please read into this topic first.
        # add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
        add_header X-Content-Type-Options nosniff;
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;


        # set max upload size
        client_max_body_size 10G;
        fastcgi_buffers 64 4K;

        # Disable gzip to avoid the removal of the ETag header
        gzip off;

        # Uncomment if your server is build with the ngx_pagespeed module
        # This module is currently not supported.
        #pagespeed off;

        index index.php;

        error_page 403 /core/templates/403.php;
        error_page 404 /core/templates/404.php;

        location ~ ^/apps-appstore/(.*)$ {
            alias /var/lib/apps/$1;
        }

        location ~ ^/assets/(.*)$ {
            alias /var/lib/assets/$1;
        }

        location ~ ^/(build|tests|config|lib|3rdparty|templates|data)/ {
            deny all;
        }

        location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
            deny all;
        }

        rewrite ^/remote/(.*) /remote.php last;
        rewrite ^/core/doc/([^\/]+)(?:$|/) /core/doc/$1/index.html;

        try_files $uri $uri/ =404;

        location ~ \.php(?:$|/) {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            #fastcgi_param HTTPS on;
            fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
            #fastcgi_pass 127.0.0.1:9000;
            fastcgi_pass php-nextcloud;
            fastcgi_intercept_errors on;
        }

        # Adding the cache control header for js and css files
        # Make sure it is BELOW the location ~ \.php(?:$|/) { block
        location ~* \.(?:css|js)$ {
            add_header Cache-Control "public, max-age=7200";
            # Optional: Don't log access to assets
            access_log off;
        }

        # Optional: Don't log access to other assets
        location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ {
            access_log off;
        }

        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
EOF


cat >/etc/php-fpm.d/nextcloud.conf<<EOF


[nextcloud]
user = nginx
group = nginx
listen = /run/php-fpm/nextcloud.sock
listen.acl_users = apache,nginx
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/nextcloud-slow.log
php_admin_value[error_log] = /var/log/php-fpm/nextcloud-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache
php_value[upload_max_filesize] = 10G
php_value[post_max_size] = 10G
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

EOF

mkdir -p /var/lib/php/session /var/lib/php/wsdlcache /var/log/php-fpm/ /run/php-fpm/
chown -R nginx:nginx  /var/lib/php/


#systemctl restart nginx
#systemctl restart php71-php-fpm
#ps -ef | grep nginx | awk -F ' ' '{print $2}' | xargs kill -9;/usr/sbin/nginx.exe
#ps -ef | grep php-fpm | awk -F ' ' '{print $2}' | xargs kill -9;/usr/sbin/php-fpm.exe