peony 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab3c849d57215fbcbf615541fd75c307a29f64cb
4
- data.tar.gz: 54de31d03fba5f39abf42c3c835554d97a9e0600
3
+ metadata.gz: 71a9982e5f32013ab5ba4fc8034e6c72d978f86e
4
+ data.tar.gz: 5ffb0d9c65cf80846f4f1e0c27173805bd64248c
5
5
  SHA512:
6
- metadata.gz: 18b722718b15ed4e854a64541fab66103ca6ec3ac31ca878a0111b6b2edf9e8cd4545d7be6158874e39a57ff204e8fd57a478601e9bfc1eeb07a88159f191178
7
- data.tar.gz: c324e9a1ed1b649454d1d108625fde04fc16bf0d2945fc8aeacae74aaa312adbb4a6426d58a5b7a6e5f9ad11ba2d2e7b098d2d168328c5d508e629a0fa580018
6
+ metadata.gz: 8feaff6c88dacee399549f76d2bbe375b1a66311dbf6a3ae10afde6404cf6608d13063123349acef1ef3555ebbdc172656e263c9398104535cfeabf9670bd3c0
7
+ data.tar.gz: 553595c2ad5f0c8923839632a30410061169ba5f2c5a16e299257d6c8f327989d277cfe6c8d1f3fc664b65c3e800771a27d81338a9434523d58a2fd1de94a906
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/README.md CHANGED
@@ -27,3 +27,5 @@ TODO: Write usage instructions here
27
27
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
28
  4. Push to the branch (`git push origin my-new-feature`)
29
29
  5. Create new Pull Request
30
+
31
+
data/bin/peony ADDED
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'rubygems' unless Object.const_defined?(:Gem)
5
+ require 'peony'
6
+ require 'rake'
7
+
8
+ # Intercept: if invoked as 'peony --help', don't let it pass through Rake, or else
9
+ # we'll see the Rake help screen. Redirect it to 'peony help'.
10
+ if ARGV.delete('--help') || ARGV.delete('-h')
11
+ ARGV << 'help'
12
+ end
13
+
14
+ if ARGV.delete('--version') || ARGV.delete('-V')
15
+ puts "Peony, version v#{Peony.version}"
16
+ exit
17
+ end
18
+
19
+ if ARGV.delete('--simulate') || ARGV.delete('-S')
20
+ ENV['simulate'] = '1'
21
+ end
22
+
23
+ Rake.application.instance_eval do
24
+ standard_exception_handling do
25
+
26
+ init 'peony'
27
+
28
+ @rakefiles += ['Peonyfile', 'peonyfile']
29
+ options.rakelib += ["recipes/**"]
30
+
31
+ # Load the Peony DSL.
32
+ require 'peony/rake'
33
+
34
+ load_rakefile if have_rakefile
35
+
36
+ Dir.glob(File.expand_path("../recipes/**/*.rake", __dir__)) do|fn|
37
+ load fn
38
+ end
39
+
40
+ top_level
41
+ end
42
+ end
43
+
@@ -0,0 +1,18 @@
1
+ set_default :base_dir, "/u"
2
+ set_default :var_dir, ->{"#{base_dir}/var"}
3
+ set_default :etc_dir, ->{"#{base_dir}/etc"}
4
+ set_default :run_dir, ->{"#{var_dir}/run"}
5
+ set_default :log_dir, ->{"#{var_dir}/log"}
6
+ set_default :www_dir, ->{"#{var_dir}/www"}
7
+ set_default :data_dir, ->{"#{var_dir}/data"}
8
+
9
+ set_default :user, "James"
10
+ set_default :group, "admin"
11
+
12
+ namespace :settings do
13
+ task :list do
14
+ settings.each do|k, v|
15
+ puts "#{k} = #{settings.send(k)}"
16
+ end
17
+ end
18
+ end
data/lib/peony/rake.rb ADDED
@@ -0,0 +1,3 @@
1
+ extend Peony::Utils
2
+
3
+ require 'peony/default'
@@ -0,0 +1,29 @@
1
+ module Peony
2
+ class Settings < Hash
3
+ def method_missing(method, *args, &block)
4
+ name = method.to_s
5
+ key, punct = name[0..-2].to_sym, name[-1..-1]
6
+ case punct
7
+ when '='
8
+ self[key] = args.first != nil ? args.first : block
9
+ when '?'
10
+ include? key
11
+ when '!'
12
+ raise Error, "Setting :#{key} is not set" unless include?(key)
13
+ evaluate self[key]
14
+ else
15
+ ret = evaluate self[method]
16
+ ret = block.call unless block.nil?
17
+ ret
18
+ end
19
+ end
20
+
21
+ def evaluate(value)
22
+ if value.is_a?(Proc)
23
+ value.call
24
+ else
25
+ value
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ module Peony
2
+ class TemplateBinding
3
+
4
+ def initialize(settings)
5
+ @settings = settings
6
+ end
7
+
8
+ def context_binding
9
+ binding
10
+ end
11
+
12
+ def method_missing(meth, *args, &blk)
13
+ val = @settings.send(meth, *args, &blk)
14
+ if val == nil
15
+ super
16
+ else
17
+ val
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,173 @@
1
+ require 'peony/template_binding'
2
+
3
+ module Peony
4
+ module Utils
5
+
6
+ def sudo(cmd)
7
+ sh "sudo #{cmd}" do |res, stat|
8
+ yield res, stat
9
+ end
10
+ end
11
+
12
+ # ### invoke
13
+ # Invokes another Rake task.
14
+ #
15
+ # Invokes the task given in `task`. Returns nothing.
16
+ #
17
+ # invoke :'git:clone'
18
+ # invoke :restart
19
+ #
20
+ # Options:
21
+ # reenable (bool) - Execute the task even next time.
22
+ #
23
+ def invoke(task, options = {})
24
+ Rake.application.invoke_task task
25
+ Rake::Task[task].reenable if options[:reenable]
26
+ end
27
+
28
+ def template(from, to, override=false)
29
+ template = find_templates(from).first
30
+ raise "Can't find tempalte #{from} in directory #{search_paths}." unless template
31
+ raise "File #{to} have already exists." if !override && File.exists?(to)
32
+ puts "copy #{template} to #{to}"
33
+ open(to, "w+") do|out|
34
+ out.write(erb(template))
35
+ end
36
+ end
37
+
38
+ # ### erb
39
+ # Evaluates an ERB block in the current scope and returns a string.
40
+ #
41
+ # a = 1
42
+ # b = 2
43
+ #
44
+ # # Assuming foo.erb is <%= a %> and <%= b %>
45
+ # puts erb('foo.erb')
46
+ #
47
+ # #=> "1 and 2"
48
+ #
49
+ # Returns the output string of the ERB template.
50
+ def erb(file, b=binding)
51
+ require 'erb'
52
+ ERB.new(File.read(file), nil, "-").result(b)
53
+ end
54
+
55
+ # ### report_time
56
+ # Report time elapsed in the block.
57
+ # Returns the output of the block.
58
+ #
59
+ # report_time do
60
+ # sleep 2
61
+ # # do other things
62
+ # end
63
+ #
64
+ # # Output:
65
+ # # Elapsed time: 2.00 seconds
66
+ def report_time(&blk)
67
+ time, output = measure &blk
68
+ print_str "Elapsed time: %.2f seconds" % [time]
69
+ output
70
+ end
71
+
72
+ # ### measure
73
+ # Measures the time (in seconds) a block takes.
74
+ # Returns a [time, output] tuple.
75
+ def measure(&blk)
76
+ t = Time.now
77
+ output = yield
78
+ [Time.now - t, output]
79
+ end
80
+
81
+ # ### error
82
+ # __Internal:__ Prints to stdout.
83
+ # Consider using `print_error` instead.
84
+ def error(str)
85
+ $stderr.write "#{str}\n"
86
+ end
87
+
88
+ # ### echo_cmd
89
+ # Converts a bash command to a command that echoes before execution.
90
+ # Used to show commands in verbose mode. This does nothing unless verbose mode is on.
91
+ #
92
+ # Returns a string of the compound bash command, typically in the format of
93
+ # `echo xx && xx`. However, if `verbose_mode?` is false, it returns the
94
+ # input string unharmed.
95
+ #
96
+ # echo_cmd("ln -nfs releases/2 current")
97
+ # #=> echo "$ ln -nfs releases/2 current" && ln -nfs releases/2 current
98
+ def echo_cmd(str)
99
+ if verbose_mode?
100
+ require 'shellwords'
101
+ "echo #{Shellwords.escape("$ " + str)} &&\n#{str}"
102
+ else
103
+ str
104
+ end
105
+ end
106
+
107
+ # ### set
108
+ # Sets settings.
109
+ # Sets given symbol `key` to value in `value`.
110
+ #
111
+ # Returns the value.
112
+ #
113
+ # set :domain, 'kickflip.me'
114
+ def set(key, *args, &block)
115
+ settings.send :"#{key}=", *args, block
116
+ end
117
+
118
+ # ### set_default
119
+ # Sets default settings.
120
+ # Sets given symbol `key` to value in `value` only if the key isn't set yet.
121
+ #
122
+ # Returns the value.
123
+ #
124
+ # set_default :term_mode, :pretty
125
+ # set :term_mode, :system
126
+ # settings.term_mode.should == :system
127
+ #
128
+ # set :term_mode, :system
129
+ # set_default :term_mode, :pretty
130
+ # settings.term_mode.should == :system
131
+ def set_default(key, *args, &block)
132
+ set(key, *args, block) unless settings.send(:"#{key}?")
133
+ end
134
+
135
+ # ### settings
136
+ # Accesses the settings hash.
137
+ #
138
+ # set :domain, 'kickflip.me'
139
+ #
140
+ # settings.domain #=> 'kickflip.me'
141
+ # domain #=> 'kickflip.me'
142
+ def settings
143
+ @settings ||= Settings.new
144
+ end
145
+
146
+ def search_paths
147
+ ["#{Dir.pwd}/templates", File.expand_path("../../templates", __dir__)]
148
+ end
149
+
150
+ def find_templates(name, file_only=true)
151
+ templates = []
152
+ search_paths.each do|path|
153
+ templates += Dir[File.expand_path(name, path)].reject{|filename| file_only && File.directory?(filename) }
154
+ end
155
+ templates
156
+ end
157
+
158
+ # ### method_missing
159
+ # Hook to get settings.
160
+ # See #settings for an explanation.
161
+ #
162
+ # Returns things.
163
+ def method_missing(meth, *args, &blk)
164
+ settings.send meth, *args
165
+ end
166
+
167
+ private
168
+ def template_binding
169
+ @template_binding ||= TemplateBinding.new(settings)
170
+ @template_binding.context_binding
171
+ end
172
+ end
173
+ end
data/lib/peony/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Peony
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/peony.rb CHANGED
@@ -1,5 +1,16 @@
1
1
  require "peony/version"
2
2
 
3
3
  module Peony
4
- # Your code goes here...
4
+ PREFIX = File.dirname(__FILE__)
5
+ ROOT = File.expand_path('../../', __FILE__)
6
+
7
+ autoload :Utils, 'peony/utils'
8
+ autoload :Settings, 'peony/settings'
9
+
10
+
11
+ Error = Class.new(Exception)
12
+
13
+ def self.root_path(*a)
14
+ File.join ROOT, *a
15
+ end
5
16
  end
data/peony.gemspec CHANGED
@@ -9,15 +9,16 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["James Zhan"]
10
10
  spec.email = ["zhiqiangzhan@gmail.com"]
11
11
  spec.description = %q{Local Script Management System Using Rake}
12
- spec.summary = %q{Local Script Management System Using Rake}
13
- spec.homepage = ""
12
+ spec.summary = %q{Local Script Management System Using Rake.}
13
+ spec.homepage = "https://github.com/jameszhan/peony"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
-
20
+
21
+ spec.add_dependency "rake"
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
23
24
  end
@@ -0,0 +1,47 @@
1
+ set_default :pg_home, ->{`brew --prefix postgresql`.strip}
2
+ set_default :pg_initdb, "/usr/local/bin/initdb"
3
+ set_default :pg_ctl, "/usr/local/bin/pg_ctl"
4
+
5
+ set_default :pg_data_dir, ->{"#{data_dir}/pgsql"}
6
+ set_default :pg_init, ->{"#{pg_initdb} -D #{pg_data_dir} --debug"}
7
+ set_default :pg_start, ->{"#{pg_ctl} -D #{pg_data_dir} -l #{log_dir}/pgsql.log start"}
8
+ set_default :pg_stop, ->{"#{pg_ctl} -D #{pg_data_dir} stop"}
9
+ set_default :pg_reload, ->{"#{pg_ctl} -D #{pg_data_dir} reload"}
10
+ set_default :pg_restart, ->{"#{pg_ctl} -D #{pg_data_dir} -l #{log_dir}/pgsql.log restart"}
11
+
12
+ set_default :pg_super_users, {
13
+ pgsql: "123456"
14
+ }
15
+
16
+ namespace :db do
17
+ namespace :pg do
18
+ task :init do
19
+ if File.exists?("#{pg_data_dir}/postgresql.conf")
20
+ puts "Postgresql database has already initialized."
21
+ else
22
+ sh pg_init do |res, stat|
23
+ puts stat.inspect if !res
24
+ end
25
+ end
26
+ end
27
+
28
+ task :set_super_users do
29
+ pg_super_users.each do|user, password|
30
+ sqls = ["CREATE USER #{user} WITH PASSWORD '#{password}';", "ALTER USER #{user} WITH SUPERUSER;"]
31
+ sqls.each do|sql|
32
+ sh "psql -d postgres -c \"#{sql}\"" do|res, stat|
33
+ puts stat.inspect if !res
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ [:start, :stop, :restart, :reload].each do|cmd|
40
+ task cmd do
41
+ sh self.send("pg_#{cmd}") do|res, stat|
42
+ puts stat.inspect if !res
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,24 @@
1
+ set_default :www_http_port, 80
2
+ set_default :www_https_port, 443
3
+ set_default :www_paths, {}
4
+
5
+ namespace :nginx do
6
+ namespace :www do
7
+ task :init do
8
+ template("nginx/www.conf.erb", "#{nginx_etc_dir}/www.conf", true)
9
+ template("nginx/sites-enabled/static.conf.erb", "#{nginx_etc_dir}/sites-enabled/static.http.conf", true) unless www_paths.empty?
10
+ end
11
+
12
+ [:start, :stop, :reload].each do|t|
13
+ task t do
14
+ sudo self.send("nginx_#{t}_cmd", :www) do|res, stat|
15
+ puts stat.inspect if !res
16
+ end
17
+ end
18
+ end
19
+
20
+ task :restart do
21
+ nginx_restart(:www)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,50 @@
1
+ set_default :nginx, ->{"/usr/local/bin/nginx"}
2
+ set_default :nginx_home, ->{`brew --prefix nginx`.strip}
3
+ set_default :nginx_etc_dir, ->{"#{etc_dir}/nginx"}
4
+ set_default :nginx_run_dir, ->{"#{run_dir}/nginx"}
5
+ set_default :nginx_prefix, ->{"#{log_dir}/nginx"}
6
+
7
+ set_default :worker_processes, 8
8
+
9
+ set_default :upstreams, [
10
+ {name: :fastcgi, servers: ["127.0.0.1:6666"]},
11
+ ]
12
+
13
+ set_default :server_name, "localhost"
14
+
15
+ set_default :use_ssl, true
16
+ set_default :ssl_certificate, ->{"#{etc_dir}/ssl/server.crt"}
17
+ set_default :ssl_certificate_key, ->{"#{etc_dir}/ssl/server.key"}
18
+
19
+
20
+ def nginx_start_cmd(name)
21
+ "#{nginx} -c #{nginx_etc_dir}/#{name}.conf -p #{nginx_prefix}"
22
+ end
23
+
24
+ def nginx_stop_cmd(name)
25
+ "#{nginx} -s quit -c #{nginx_etc_dir}/#{name}.conf -p #{nginx_prefix}"
26
+ end
27
+
28
+ def nginx_reload_cmd(name)
29
+ "#{nginx} -s reload -c #{nginx_etc_dir}/#{name}.conf -p #{nginx_prefix}"
30
+ end
31
+
32
+ def nginx_restart(name)
33
+ invoke "nginx:#{name}:stop"
34
+ puts "Start nginx......"
35
+ sleep 5
36
+ invoke "nginx:#{name}:start"
37
+ end
38
+
39
+ namespace :nginx do
40
+ task :init do
41
+ [nginx_etc_dir, nginx_run_dir, nginx_prefix].each do|dir|
42
+ FileUtils.mkdir_p(dir) unless File.exists?(dir)
43
+ fail "#{dir} must be a directory!" unless File.directory?(dir)
44
+ end
45
+ unless File.exists?("#{nginx_etc_dir}/conf")
46
+ FileUtils.cp_r(find_templates("nginx/conf", false).first, nginx_etc_dir)
47
+ end
48
+ FileUtils.mkdir_p("#{nginx_etc_dir}/sites-enabled") unless File.exists?("#{nginx_etc_dir}/sites-enabled")
49
+ end
50
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Settings in rake tasks' do
4
+ it '#set should work' do
5
+ rake { set :domain, 'localhost' }
6
+
7
+ rake.domain.should == 'localhost'
8
+ rake.settings.domain.should == 'localhost'
9
+ end
10
+
11
+ it '#settings ||= should work' do
12
+ rake {
13
+ set :version, '2'
14
+ settings.version ||= '3'
15
+ }
16
+
17
+ rake.settings.version.should == '2'
18
+ rake.version.should == '2'
19
+ end
20
+
21
+ it '#settings with lambdas should work' do
22
+ rake {
23
+ set :version, '42'
24
+ set :path, lambda { "/var/www/#{version}" }
25
+ }
26
+
27
+ rake.path.should == "/var/www/42"
28
+ rake.path?.should be_true
29
+ end
30
+
31
+ it '#settings with a bang should work' do
32
+ expect {
33
+ rake {
34
+ set :path, lambda { "/var/www/#{version!}" }
35
+ }
36
+ rake.path
37
+ }.to raise_error(Peony::Error, /version/)
38
+ end
39
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+ describe Peony::Settings do
3
+ describe 'instances' do
4
+ before :each do
5
+ @settings = Peony::Settings.new
6
+ end
7
+
8
+ it 'setting/getting should work' do
9
+ @settings.email = 'zhiqiangzhan@gmail.com'
10
+ @settings.email.should == 'zhiqiangzhan@gmail.com'
11
+ end
12
+
13
+ it 'setting proc should work' do
14
+ @settings.email = ->{"zhiqiangzhan@gmail.com"}
15
+ @settings.email.should == 'zhiqiangzhan@gmail.com'
16
+ end
17
+
18
+ it 'lambdas should work' do
19
+ @settings.path = lambda { "/var/www/#{@settings.version}" }
20
+ @settings.version = '3'
21
+
22
+ @settings.path?.should be_true
23
+ @settings.path.should == "/var/www/3"
24
+ end
25
+
26
+ it 'setting block should work' do
27
+ @settings.send(:email=){"zhiqiangzhan@gmail.com"}
28
+ @settings.email.should == 'zhiqiangzhan@gmail.com'
29
+ end
30
+
31
+ it 'setting default value should value' do
32
+ @settings.send(:x=, 1){ 3 }
33
+ @settings.x.should == 1
34
+ @settings.send(:y=, nil){ 3 }
35
+ @settings.y.should == 3
36
+ @settings.send(:z=){ 6 }
37
+ @settings.z.should == 6
38
+ end
39
+
40
+ it 'setting get default value should value' do
41
+ @settings.x{1}.should == 1
42
+ @settings.y{3}.should == 3
43
+ @settings.z{6}.should == 6
44
+ end
45
+
46
+ it 'question mark should work with nils' do
47
+ @settings.deploy_to = nil
48
+ @settings.deploy_to?.should be_true
49
+ @settings.foobar?.should be_false
50
+ end
51
+
52
+ it '||= should work (1)' do
53
+ @settings.x = 2
54
+ @settings.x ||= 3
55
+ @settings.x.should == 2
56
+ end
57
+
58
+ it '||= should work (2)' do
59
+ @settings.x ||= 3
60
+ @settings.x.should == 3
61
+ end
62
+
63
+ it 'bangs should check for settings' do
64
+ expect { @settings.non_existent_setting! }.to raise_error(Peony::Error, /non_existent_setting/)
65
+ end
66
+
67
+ it 'bangs should return settings' do
68
+ @settings.version = 4
69
+ @settings.version!.should == 4
70
+ end
71
+
72
+ end
73
+ end
@@ -0,0 +1,40 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+
8
+ require 'rubygems'
9
+ require 'bundler/setup'
10
+
11
+ require 'rake'
12
+ require 'peony'
13
+
14
+
15
+ class RakeScope
16
+ include Rake::DSL if Rake.const_defined?(:DSL)
17
+ include Peony::Utils
18
+ end
19
+
20
+ def rake(&blk)
21
+ if block_given?
22
+ @scope ||= RakeScope.new
23
+ @scope.instance_eval &blk
24
+ end
25
+
26
+ @scope
27
+ end
28
+
29
+
30
+ RSpec.configure do |config|
31
+ config.treat_symbols_as_metadata_keys_with_true_values = true
32
+ config.run_all_when_everything_filtered = true
33
+ config.filter_run :focus
34
+
35
+ # Run specs in random order to surface order dependencies. If you find an
36
+ # order dependency and want to debug it, you can fix the order by providing
37
+ # the seed, which is printed after each run.
38
+ # --seed 1234
39
+ config.order = 'random'
40
+ end
@@ -0,0 +1,25 @@
1
+
2
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
3
+ fastcgi_param QUERY_STRING $query_string;
4
+ fastcgi_param REQUEST_METHOD $request_method;
5
+ fastcgi_param CONTENT_TYPE $content_type;
6
+ fastcgi_param CONTENT_LENGTH $content_length;
7
+
8
+ fastcgi_param SCRIPT_NAME $fastcgi_script_name;
9
+ fastcgi_param REQUEST_URI $request_uri;
10
+ fastcgi_param DOCUMENT_URI $document_uri;
11
+ fastcgi_param DOCUMENT_ROOT $document_root;
12
+ fastcgi_param SERVER_PROTOCOL $server_protocol;
13
+ fastcgi_param HTTPS $https if_not_empty;
14
+
15
+ fastcgi_param GATEWAY_INTERFACE CGI/1.1;
16
+ fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
17
+
18
+ fastcgi_param REMOTE_ADDR $remote_addr;
19
+ fastcgi_param REMOTE_PORT $remote_port;
20
+ fastcgi_param SERVER_ADDR $server_addr;
21
+ fastcgi_param SERVER_PORT $server_port;
22
+ fastcgi_param SERVER_NAME $server_name;
23
+
24
+ # PHP only, required if PHP was built with --enable-force-cgi-redirect
25
+ fastcgi_param REDIRECT_STATUS 200;