fpm&nginx快速添加模版

addfpm() {
if [ ! -n "$1" ]; then username="newuser"; else username=$1;   fi
if [ ! -n "$2" ]; then prefix="/opt/php8"; else prefix=$2;   fi
useradd -r -s /bin/nologin  $username
cat>$prefix/etc/php-fpm.d/$username.conf<<EOF
[$username]
;listen=127.0.0.1:9006
listen=/dev/shm/\$pool.sock
listen.mode=0666
user=$username
group=$username
pm=dynamic
pm.max_children=128
pm.start_servers=20
pm.min_spare_servers=5
pm.max_spare_servers=35
pm.max_requests=10000
rlimit_files=51200
slowlog=log/\$pool.log.slow
env[PATH] = /usr/local/bin:/usr/bin:/bin:$prefix/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
EOF
}

addnginx(){
if [ ! -n "$1" ]; then echo "Please input Domain";exit; else domain=$1;   fi
cat>/etc/nginx/conf/$domain.conf<<EOF
server {
    listen 443 ssl;
    server_name $domain www.$domain;
    index default.php index.php index.htm index.html;
    root /home/$2/;
    access_log /var/log/httpd/$domain.log;
    error_log /var/log/httpd/$domain.error.log;
    ssl_certificate /etc/nginx/ssl/$domain.crt;
    ssl_certificate_key /etc/nginx/ssl/$domain.key;
    include ssl.conf;
    #include whmcs.conf;
    #include typecho.conf;

sub_filter_once off;
sub_filter_types text/css;
sub_filter "//ajax.googleapis.com" "//ajax.googleapis.cnpmjs.org";
sub_filter "//fonts.googleapis.com" "//fonts.googleapis.cnpmjs.org";
sub_filter "//fonts.gstatic.com" "//fonts.gstatic.cnpmjs.org";

location  /{
        location ~ [^/]\.php(/|\$){
                fastcgi_pass unix:/dev/shm/$2.sock;
                try_files \$uri = 404;
}
}

location /nginx_status {
  stub_status on;
  access_log   off;
}
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)\$ {expires 30d;}
    location ~ .*\.(js|css)?\$ { expires 12h;}
    location ~ /\. {deny all;}
    location ~/\.ht {deny all;}
  }

  server {
    listen 80;
    #server_name   ~^(www\.)?(.+)$;
    server_name $domain www.$domain;
    location  /{ 
      if (\$scheme = 'http' ) {rewrite ^/(.*)$ https://\$http_host/\$1 permanent;}
   }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)\$ {expires 30d;}
    location ~ .*\.(js|css)?\$ { expires 12h;}
    location ~ /\. {deny all;}
    location ~/\.ht {deny all;}
    location ~ /.well-known { allow all;}
    location /.well-known/acme-challenge/  { allow all;}
  }
EOF
}


 

 

添加新评论 »