sh nginx-vhost.sh
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh nginx-vhost.sh相关的知识,希望对你有一定的参考价值。
#!/bin/bash
name=$1
DIR=$2
WEB_ROOT_DIR="/usr/share/nginx/html/"$2
email=${3-'webmaster@localhost'}
sitesAvailable='/etc/nginx/conf.d/'
sitesAvailabledomain=$sitesAvailable$name.conf
### create virtual host rules file
echo "
server {
listen 80;
server_name $name;
access_log /var/log/nginx/$DIR.access.log;
error_log /var/log/nginx/$DIR.error.log;
root $WEB_ROOT_DIR;
index index.php;
## serve imagecache files directly or redirect to drupal if they do not exist.
location ~* files/styles {
access_log off;
expires 30d;
try_files \$uri @drupal;
}
## serve imagecache files directly or redirect to drupal if they do not exist.
location ~* ^.+.(xsl|xml)\$ {
access_log off;
expires 1d;
try_files \$uri @drupal;
}
## Default location
location / {
try_files \$uri \$uri/ @drupal;
index index.php;
}
location @drupal {
rewrite ^/(.*)$ /index.php?q=\$1 last;
}
## Images and static content is treated different
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 30d;
}
## Parse all .php file in the /var/www directory
location ~ .php$ {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param SCRIPT_NAME \$fastcgi_script_name;
fastcgi_param QUERY_STRING \$query_string;
fastcgi_param REQUEST_METHOD \$request_method;
fastcgi_param CONTENT_TYPE \$content_type;
fastcgi_param CONTENT_LENGTH \$content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
deny all;
}
}" > $sitesAvailabledomain
echo -e $"\nNew Virtual Host Created\n"
sed -i "1s/^/127.0.0.1 $name\n/" /etc/hosts
service nginx reload
echo "Done, please browse to http://$name to check!"
以上是关于sh nginx-vhost.sh的主要内容,如果未能解决你的问题,请参考以下文章
如何使我的命令行在具有扩展名(.sh)和名称如“weird.sh.sh.sh”的文件上工作
sh sh_template.sh
sh sh.sh
Linux下面如何运行 SH文件
配置告警系统主脚本main.sh mon.sh load.sh 502.sh disk.sh
shell 脚本各种执行方式(source ./*.sh, . ./*.sh, ./*.sh)的区别