测试部署 WordPress

This commit is contained in:
jysperm
2014-07-21 13:14:27 +08:00
parent 6d0c0c9eb6
commit d58e38140d
11 changed files with 59 additions and 26 deletions

View File

@@ -10,7 +10,7 @@
vi /etc/hosts
apt-get install nodejs git mongodb nginx postfix redis-server
apt-get install python g++ make screen git wget zip unzip iftop unrar-free axel vim emacs subversion subversion-tools curl tmux mercurial
apt-get install python g++ make screen git wget zip unzip iftop unrar-free axel vim emacs subversion subversion-tools curl tmux mercurial htop
apt-get install ntp quota quotatool
mongo
@@ -27,6 +27,10 @@
rm /etc/php5/fpm/pool.d/www.conf
rm /etc/nginx/sites-enabled/default
vi /etc/nginx/fastcgi_params
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
cat > /etc/nginx/sites-available/rpadmin
server {

1
WIKI/App/WordPress.md Normal file
View File

@@ -0,0 +1 @@
## 安装

View File

@@ -5,14 +5,24 @@
{
"listen": 80,
"server_name": ["domain1.com", "domain2.net"],
"server_name": [
"domain1.com",
"domain2.net"
],
"auto_index": false,
"index": ["index.html"],
"index": [
"index.php",
"index.html"
],
"root": "/home/user/web",
"location": {
"/": {
"fastcgi_pass": "unix:///home/user/phpfpm.sock",
"fastcgi_index": ["index.php"]
"try_files": ["$uri", "$uri/", "/index.php?$args"]
},
"~ \\.php$": {
"fastcgi_pass": "unix:///home/user/web",
"fastcgi_index": ["index.php"],
"include": "fastcgi_params"
}
}
}
@@ -78,7 +88,11 @@
* 站点路径匹配规则
* 对象,默认 `{}`
* 键名只能为 `/`
* 键名目前支持 `/`, `~ \.php$`
* location - try_files
* location - include
* location - fastcgi_pass

View File

@@ -2,7 +2,7 @@ request = require 'request'
config = require './../config'
exports.genAddress = (blockchain_secret, callback) ->
exports.genAddress = (callback) ->
request 'https://coinbase.com/api/v1/account/generate_receive_address',
method: 'POST'
json:

View File

@@ -71,7 +71,7 @@ exports.hashPassword = (password, password_salt) ->
exports.register = (username, email, password, callback) ->
password_salt = exports.randomSalt()
bitcoin.genAddress blockchain_secret, (address) ->
bitcoin.genAddress (address) ->
exports.insert
_id: new ObjectID()
username: username

View File

@@ -65,15 +65,17 @@ $ ->
e.preventDefault()
type = $('#nginxConfigType').find('.active a').attr('href').substr 1
try
$.post '/plugin/nginx/update_site/', JSON.stringify {
action: 'create'
type: type
config: JSON.parse($("##{type}").find('textarea').val())
}
.success ->
location.reload()
config = JSON.parse($("##{type}").find('textarea').val())
catch e
alert '配置文件格式不正确'
return alert '配置文件格式不正确'
$.post '/plugin/nginx/update_site/', JSON.stringify
action: if config.id then 'update' else 'create'
id: config.id
type: type
config: config
.success ->
location.reload()
mysql = $ '#mysql-input'
mysql.find 'button'

View File

@@ -14,12 +14,16 @@ sample =
listen: 80
server_name: ['domain1', 'domain2']
auto_index: false
index: ['index.html']
index: ['index.html', 'index.html']
root: '/home/user/web'
location:
'/':
try_files: ['$uri', '$uri/', '/index.php?$args']
'~ \\.php$':
fastcgi_pass: 'unix:///home/user/phpfpm.sock'
fastcgi_index: ['index.php']
include: 'fastcgi_params'
exports.use (req, res, next) ->
req.inject [requestAuthenticate], ->

View File

@@ -39,7 +39,7 @@ exports.assert = (account, config, site_id, callback) ->
return callback 'invalid_root'
for path, rules of config.location
unless path in ['/']
unless path in ['/', '~ \\.php$']
return callback 'invalid_location'
for name, value of rules
@@ -51,10 +51,18 @@ exports.assert = (account, config, site_id, callback) ->
unless utils.checkHomeFilePath account, value.slice fastcgi_prefix.length
return callback 'invalid_fastcgi_pass'
if name == 'fastcgi_index'
else if name == 'fastcgi_index'
for file in value
unless utils.rx.test file
return callback 'invalid_fastcgi_index'
else if name == 'include'
unless value == 'fastcgi_params'
return callback 'invalid_include'
else if name == 'try_files'
for item in value
unless item in ['$uri', '$uri/', '/index.php?$args']
return callback 'invalid_try_files'
else
return callback 'unknown_command'
callback null

View File

@@ -11,7 +11,7 @@ table.table.table-hover
for site in account.attribute.plugin.nginx.sites
tr(data-id= '#{site._id}')
td= site.server_name.join(', ')
td root: ~#{site.root.match(/\/home\/[^\/]+(.*)/)[1]}, fastcgi_pass: ~#{site.location['/'].fastcgi_pass.match(/unix:\/\/\/home\/[^\/]+(.*)/)[1]}
td root: ~#{site.root.match(/\/home\/[^\/]+(.*)/)[1]}
td(style= 'width: 150px;')
button.nginx-edit-btn.btn.btn-info.btn-xs
span.glyphicon.glyphicon-edit

View File

@@ -3,7 +3,7 @@
user = <%= account.username %>
group = <%= account.username %>
listen = /home/<%= account.username %>/php-fpm.sock
listen = /home/<%= account.username %>/phpfpm.sock
listen.owner = <%= account.username %>
listen.group = <%= account.username %>
@@ -14,10 +14,10 @@ pm.max_children = 3
pm.process_idle_timeout = 10s
pm.max_requests = 500
slowlog = /home/<%= account.username %>/php-fpm.slowlog
slowlog = /home/<%= account.username %>/phpfpm.slowlog
request_slowlog_timeout = 5s
request_terminate_timeout = 15s
php_admin_value[memory_limit] = 128M
php_admin_value[error_log] = /home/<%= account.username %>/php-fpm.error_log
php_admin_value[error_log] = /home/<%= account.username %>/phpfpm_error.log
php_admin_flag[log_errors] = On

View File

@@ -8,8 +8,8 @@ monitor = require '../linux/monitor'
module.exports =
enable: (account, callback) ->
child_process.exec "sudo useradd -m -s /bin/bash #{account.username}", (err, stdout, stderr) ->
throw err if err
callback()
child_process.exec "sudo usermod -G #{account.username} -a www-data", (err, stdout, stderr) ->
callback()
delete: (account, callback) ->
async.series [