-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME
150 lines (120 loc) · 4.7 KB
/
README
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
Habrometr Source Code.
Version 2.0.
This program collects habrahabr.ru karma, habraforce and habra rate values and
visualizes it on graphical informers.
The software published under GPL3 License.
* Copyright (C) 2009 Leontyev Valera
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
SOFTWARE DEPENDENCIES
1) HTTP-Webserver (possible Apache);
2) MySQL Database (5.x and heigher);
3) PHP 5.1 or heigher with Curl, IMagick and memcache extensions;
4) Image Magick libs;
5) [Optional] nginx, eaccelerator, memcached.
INSTALLATION
1) Create new database and user. "Add" user to new database. Exequte SQL from
./habrometr.sql file.
2) Create config.local.php file with the next contents:
Listing 1. config.local.php
---------------------------------------------------------------------------------
<?php
define('DB_USER', 'xxx');
define('DB_PASS', 'yyy');
define('DB_NAME', 'zzz');
define('SERVICE_URL', 'http://localhost/habrometr');
define('RE_CAPTCHA_KEY_PRIVATE', '=== your private key ==='); // http://www.google.com/recaptcha/
define('RE_CAPTCHA_KEY_PUBLIC', '=== your public key ===');
define('DEBUG_MODE', true); // true to dump uncatched exception message, false to
// send wordless 404 or 500 responce codes
define('LOG_LEVEL', 7); // 0...7 according BSD Syslog message severities
---------------------------------------------------------------------------------
Replace the xxx, yyy, zzz, keys and www-root path with real values.
3) Upload all source code to server. Chmod `image_cache` directory to 0777.
4) If you don't want to use Memcache (in relation with nginx), comment out
last if-block in index.php.
Other way use the next nginx configuration (replace hostnames and ports
with your values):
Listing 2. nginx.conf
---------------------------------------------------------------------------------
user www-data;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
add_header Habrometr "hacker_mode_enabled;)";
server {
listen 80;
server_name habrometr.server.valera.ws habrometr.ru www.habrometr.ru;
access_log /var/log/nginx/habrometr.access.log;
location / {
root /home/habrometr/public_html;
index index.html index.htm;
if (-f $document_root/image_cache${uri}) {
rewrite ^.*$ /image_cache/$uri last;
break;
}
set $memcached_key "habrometr$uri";
memcached_pass localhost:11211;
error_page 404 405 502 504 = @backend;
add_header Content-Type "text/html; charset=UTF-8";
gzip on;
gzip_proxied any;
gzip_types application/octet-stream;
}
location @backend {
set $proxy_uri http://habrometr.ru:9999$request_uri;
proxy_pass $proxy_uri;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X_Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 20;
}
location /image_cache/ {
root /home/habrometr/public_html;
expires modified +2h;
}
location /stuff/ {
root /home/habrometr/public_html;
expires 30d;
}
location ~* \.(gif|jpg|jpeg|ico) {
root /home/habrometr/public_html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;
}
location ~ \.php$ {
proxy_pass http://habrometr.ru:9999;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X_Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 20;
}
location ~ /\.ht {
deny all;
}
}
}