-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp_nginx.rb
53 lines (45 loc) · 1.72 KB
/
wp_nginx.rb
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env ruby
domain = ARGV[0]
if not domain
throw "no domain specified"
end
template = """server {
listen 80;
server_name #{domain};
rewrite ^/(.*) http://www.#{domain}/$1 permanent;
}
server {
listen 80;
server_name www.#{domain};
access_log /home/public_html/#{domain}/log/access.log;
error_log /home/public_html/#{domain}/log/error.log;
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov) {
access_log off;
expires 30d;
root /home/public_html/#{domain}/public/www;
}
location / {
root /home/public_html/#{domain}/public/www;
index index.php index.html;
# Basic version of Wordpress parameters, supporting nice permalinks.
# include /usr/local/nginx/conf/wordpress_params.regular;
# Advanced version of Wordpress parameters supporting nice permalinks and WP Super Cache plugin
include /usr/local/nginx/conf/wordpress_params.regular;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /home/public_html/#{domain}/public/www/$fastcgi_script_name;
}
}
"""
if File.exist? domain
puts template
else
File.open(domain, 'w') do |f|
f.puts template
end
end