]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - INSTALL
Don't accept non-objects before testing with "instanceof".
[quix0rs-gnu-social.git] / INSTALL
1 TABLE OF CONTENTS
2 =================
3 * Prerequisites
4     - PHP modules
5     - Better performance
6 * Installation
7     - Getting it up and running
8     - Fancy URLs
9     - Themes
10     - Private
11 * Extra features
12     - Sphinx
13     - SMS
14     - Translation
15     - Queues and daemons
16 * After installation
17     - Backups
18     - Upgrading
19
20 Prerequisites
21 =============
22
23 PHP modules
24 -----------
25
26 The following software packages are *required* for this software to
27 run correctly.
28
29 - PHP 5.5+      For newer versions, some functions that are used may be
30                 disabled by default, such as the pcntl_* family. See the
31                 section on 'Queues and daemons' for more information.
32 - MariaDB 5+    GNU Social uses, by default, a MariaDB server for data
33                 storage. Versions 5.x and 10.x have both reportedly
34                 worked well. It is also possible to run MySQL 5.5+.
35 - Web server    Apache, lighttpd and nginx will all work. CGI mode is
36                 recommended and also some variant of 'suexec' (or a
37                 proper setup php-fpm pool)
38                 NOTE: mod_rewrite or its equivalent is extremely useful.
39
40 Your PHP installation must include the following PHP extensions for a
41 functional setup of GNU Social:
42
43 - openssl       (compiled in for Debian, enabled manually in Arch Linux)
44 - php5-curl     Fetching files by HTTP.
45 - php5-gd       Image manipulation (scaling).
46 - php5-gmp      For Salmon signatures (part of OStatus).
47 - php5-intl     Internationalization support (transliteration et al).
48 - php5-json     For WebFinger lookups and more.
49 - php5-mysqlnd  The native driver for PHP5 MariaDB connections. If you
50                   use MySQL, 'php5-mysql' or 'php5-mysqli' may be enough.
51
52 The above package names are for Debian based systems. In the case of
53 Arch Linux, PHP is compiled with support for most extensions but they
54 require manual enabling in the relevant php.ini file (mostly php5-gmp).
55
56 Better performance
57 ------------------
58
59 For some functionality, you will also need the following extensions:
60
61 - opcache       Improves performance a _lot_. Included in PHP, must be
62                 enabled manually in php.ini for most distributions. Find
63                 and set at least:  opcache.enable=1
64 - mailparse     Efficient parsing of email requires this extension.
65                 Submission by email or SMS-over-email uses this.
66 - sphinx        A client for the sphinx server, an alternative to MySQL
67                 or Postgresql fulltext search. You will also need a
68                 Sphinx server to serve the search queries.
69 - gettext       For multiple languages. Default on many PHP installs;
70                 will be emulated if not present.
71 - exif          For thumbnails to be properly oriented.
72
73 You may also experience better performance from your site if you configure
74 a PHP cache/accelerator. Most distributions come with "opcache" support.
75 Enable it in your php.ini where it is documented together with its settings.
76
77 Installation
78 ============
79
80 Getting it up and running
81 -------------------------
82
83 Installing the basic GNU Social web component is relatively easy,
84 especially if you've previously installed PHP/MariaDB packages.
85
86 1. Unpack the tarball you downloaded on your Web server. Usually a
87    command like this will work:
88
89        tar zxf gnusocial-*.tar.gz
90
91    ...which will make a gnusocial-x.y.z subdirectory in your current
92    directory. (If you don't have shell access on your Web server, you
93    may have to unpack the tarball on your local computer and FTP the
94    files to the server.)
95
96 2. Move the tarball to a directory of your choosing in your Web root
97    directory. Usually something like this will work:
98
99        mv gnusocial-x.y.z /var/www/gnusocial
100
101    This will often make your GNU Social instance available in the gnusocial
102    path of your server, like "http://example.net/gnusocial". "social" or
103    "blog" might also be good path names. If you know how to configure 
104    virtual hosts on your web server, you can try setting up
105    "http://social.example.net/" or the like.
106
107    If you have "rewrite" support on your webserver, and you should,
108    then please enable this in order to make full use of your site. This
109    will enable "Fancy URL" support, which you can read more about if you
110    scroll down a bit in this document.
111
112 3. Make your target directory writeable by the Web server.
113
114        chmod a+w /var/www/gnusocial/
115
116    On some systems, this will probably work:
117
118        chgrp www-data /var/www/gnusocial/
119        chmod g+w /var/www/gnusocial/
120
121    If your Web server runs as another user besides "www-data", try
122    that user's default group instead. As a last resort, you can create
123    a new group like "gnusocial" and add the Web server's user to the group.
124
125 4. You should also take this moment to make your avatar, background, and
126    file subdirectories writeable by the Web server. An insecure way to do
127    this is:
128
129        chmod a+w /var/www/gnusocial/avatar
130        chmod a+w /var/www/gnusocial/background
131        chmod a+w /var/www/gnusocial/file
132
133    You can also make the avatar, background, and file directories
134    writeable by the Web server group, as noted above.
135
136 5. Create a database to hold your site data. Something like this
137    should work (you will be prompted for your database password):
138
139        mysqladmin -u "root" -p create social
140
141    Note that GNU Social should have its own database; you should not share
142    the database with another program. You can name it whatever you want,
143    though.
144
145    (If you don't have shell access to your server, you may need to use
146    a tool like phpMyAdmin to create a database. Check your hosting
147    service's documentation for how to create a new MariaDB database.)
148
149 6. Create a new database account that GNU Social will use to access the
150    database. If you have shell access, this will probably work from the
151    MariaDB shell:
152
153        GRANT ALL on social.*
154        TO 'social'@'localhost'
155        IDENTIFIED BY 'agoodpassword';
156
157    You should change the user identifier 'social' and 'agoodpassword'
158    to your preferred new database username and password. You may want to
159    test logging in to MariaDB as this new user.
160
161 7. In a browser, navigate to the GNU Social install script; something like:
162
163        https://social.example.net/install.php
164
165    Enter the database connection information and your site name. The
166    install program will configure your site and install the initial,
167    almost-empty database.
168
169 8. You should now be able to navigate to your social site's main directory
170    and see the "Public Timeline", which will probably be empty. You can
171    now register new user, post some notices, edit your profile, etc.
172
173 Fancy URLs
174 ----------
175
176 By default, GNU Social will use URLs that include the main PHP program's
177 name in them. For example, a user's home profile might be found at either
178 of these URLS depending on the webserver's configuration and capabilities:
179
180     https://social.example.net/index.php/fred
181     https://social.example.net/index.php?p=fred
182
183 It's possible to configure the software to use fancy URLs so it looks like
184 this instead:
185
186     https://social.example.net/fred
187
188 These "fancy URLs" are more readable and memorable for users. To use
189 fancy URLs, you must either have Apache 2.x with .htaccess enabled and
190 mod_rewrite enabled, -OR- know how to configure "url redirection" in
191 your server (like lighttpd or nginx).
192
193 1. See the instructions for each respective webserver software:
194     * For Apache, inspect the "htaccess.sample" file and save it as
195         ".htaccess" after making any necessary modifications. Our sample
196         file is well commented. 
197     * For lighttpd, inspect the lighttpd.conf.example file and apply the
198         appropriate changes in your virtualhost configuration for lighttpd.
199     * For nginx, inspect the nginx.conf.sample file and apply the appropriate
200         changes.
201     * For other webservers, we gladly accept contributions of
202         server configuration examples.
203
204 2. Assuming your webserver is properly configured and have its settings
205     applied (remember to reload/restart it), you can add this to your
206     GNU social's config.php file: 
207        $config['site']['fancy'] = true;
208
209 You should now be able to navigate to a "fancy" URL on your server,
210 like:
211
212     https://social.example.net/main/register
213
214 Themes
215 ------
216
217 As of right now, your ability change the theme is limited to CSS
218 stylesheets and some image files; you can't change the HTML output,
219 like adding or removing menu items, without the help of a plugin.
220
221 You can choose a theme using the $config['site']['theme'] element in
222 the config.php file. See below for details.
223
224 You can add your own theme by making a sub-directory of the 'theme'
225 subdirectory with the name of your theme. Each theme can have the
226 following files:
227
228 display.css: a CSS2 file for "default" styling for all browsers.
229 logo.png: a logo image for the site.
230 default-avatar-profile.png: a 96x96 pixel image to use as the avatar for
231     users who don't upload their own.
232 default-avatar-stream.png: Ditto, but 48x48. For streams of notices.
233 default-avatar-mini.png: Ditto ditto, but 24x24. For subscriptions
234     listing on profile pages.
235
236 You may want to start by copying the files from the default theme to
237 your own directory.
238
239 Private
240 -------
241
242 A GNU social node can be configured as "private", which means it will not
243 federate with other nodes in the network. It is not a recommended method
244 of using GNU social and we cannot at the current state of development
245 guarantee that there are no leaks (what a public network sees as features,
246 private sites will likely see as bugs). 
247
248 Private nodes are however an easy way to easily setup collaboration and
249 image sharing within a workgroup or a smaller community where federation
250 is not a desired feature. Also, it is possible to change this setting and
251 instantly gain full federation features.
252
253 Access to file attachments can also be restricted to logged-in users only:
254
255 1. Add a directory outside the web root where your file uploads will be
256    stored. Use this command as an initial guideline to create it:
257
258        mkdir /var/www/gnusocial-files
259
260 2. Make the file uploads directory writeable by the web server. An
261    insecure way to do this is (to do it properly, read up on UNIX file
262    permissions and configure your webserver accordingly):
263
264        chmod a+x /var/www/gnusocial-files
265
266 3. Tell GNU social to use this directory for file uploads. Add a line
267    like this to your config.php:
268
269        $config['attachments']['dir'] = '/var/www/gnusocial-files';
270
271 Extra features
272 ==============
273
274 Sphinx
275 ------
276
277 To use a Sphinx server to search users and notices, you'll need to
278 enable the SphinxSearch plugin. Add to your config.php:
279
280     addPlugin('SphinxSearch');
281     $config['sphinx']['server'] = 'searchhost.local';
282
283 You also need to install, compile and enable the sphinx pecl extension for
284 php on the client side, which itself depends on the sphinx development files.
285
286 See plugins/SphinxSearch/README for more details and server setup.
287
288 SMS
289 ---
290
291 StatusNet supports a cheap-and-dirty system for sending update messages
292 to mobile phones and for receiving updates from the mobile. Instead of
293 sending through the SMS network itself, which is costly and requires
294 buy-in from the wireless carriers, it simply piggybacks on the email
295 gateways that many carriers provide to their customers. So, SMS
296 configuration is essentially email configuration.
297
298 Each user sends to a made-up email address, which they keep a secret.
299 Incoming email that is "From" the user's SMS email address, and "To"
300 the users' secret email address on the site's domain, will be
301 converted to a notice and stored in the DB.
302
303 For this to work, there *must* be a domain or sub-domain for which all
304 (or most) incoming email can pass through the incoming mail filter.
305
306 1. Run the SQL script carrier.sql in your StatusNet database. This will
307    usually work:
308
309        mysql -u "statusnetuser" --password="statusnetpassword" statusnet < db/carrier.sql
310
311    This will populate your database with a list of wireless carriers
312    that support email SMS gateways.
313
314 2. Make sure the maildaemon.php file is executable:
315
316        chmod +x scripts/maildaemon.php
317
318    Note that "daemon" is kind of a misnomer here; the script is more
319    of a filter than a daemon.
320
321 2. Edit /etc/aliases on your mail server and add the following line:
322
323        *: /path/to/statusnet/scripts/maildaemon.php
324
325 3. Run whatever code you need to to update your aliases database. For
326    many mail servers (Postfix, Exim, Sendmail), this should work:
327
328        newaliases
329
330    You may need to restart your mail server for the new database to
331    take effect.
332
333 4. Set the following in your config.php file:
334
335        $config['mail']['domain'] = 'yourdomain.example.net';
336
337 Translations
338 ------------
339
340 For info on helping with translations, see the platform currently in use
341 for translations: https://www.transifex.com/projects/p/gnu-social/
342
343 Translations use the gettext system <http://www.gnu.org/software/gettext/>.
344 If you for some reason do not wish to sign up to the Transifex service,
345 you can review the files in the "locale/" sub-directory of GNU social.
346 Each plugin also has its own translation files.
347
348 To get your own site to use all the translated languages, and you are
349 tracking the git repo, you will need to install at least 'gettext' on
350 your system and then run:
351     $ make translations
352
353 Queues and daemons
354 ------------------
355
356 Some activities that StatusNet needs to do, like broadcast OStatus, SMS,
357 XMPP messages and TwitterBridge operations, can be 'queued' and done by
358 off-line bots instead.
359
360 Two mechanisms are available to achieve offline operations:
361
362 * New embedded OpportunisticQM plugin, which is enabled by default
363 * Legacy queuedaemon script, which can be enabled via config file.
364
365 ### OpportunisticQM plugin
366
367 This plugin is enabled by default. It tries its best to do background
368 job during regular HTTP requests, like API or HTML pages calls.
369
370 Since queueing system is enabled by default, notices to be broadcasted
371 will be stored, by default, into DB (table queue_item).
372
373 Each time it can, OpportunisticQM will try to handle some of them.
374
375 This is a good solution whether you:
376
377 * have no access to command line (shared hosting)
378 * do not want to deal with long-running PHP processes
379 * run a low traffic GNU social instance
380
381 In other case, you really should consider enabling the queuedaemon for
382 performance reasons. Background daemons are necessary anyway if you wish
383 to use the Instant Messaging features such as communicating via XMPP.
384
385 ### queuedaemon
386
387 If you want to use legacy queuedaemon, you must be able to run
388 long-running offline processes, either on your main Web server or on
389 another server you control. (Your other server will still need all the
390 above prerequisites, with the exception of Apache.) Installing on a
391 separate server is probably a good idea for high-volume sites.
392
393 1. You'll need the "CLI" (command-line interface) version of PHP
394    installed on whatever server you use.
395
396    Modern PHP versions in some operating systems have disabled functions
397    related to forking, which is required for daemons to operate. To make
398    this work, make sure that your php-cli config (/etc/php5/cli/php.ini)
399    does NOT have these functions listed under 'disable_functions':
400
401        * pcntl_fork, pcntl_wait, pcntl_wifexited, pcntl_wexitstatus,
402          pcntl_wifsignaled, pcntl_wtermsig
403
404    Other recommended settings for optimal performance are:
405        * mysqli.allow_persistent = On
406        * mysqli.reconnect = On
407
408 2. If you're using a separate server for queues, install StatusNet
409    somewhere on the server. You don't need to worry about the
410    .htaccess file, but make sure that your config.php file is close
411    to, or identical to, your Web server's version.
412
413 3. In your config.php files (on the server where you run the queue
414     daemon), set the following variable:
415
416        $config['queue']['daemon'] = true;
417
418    You may also want to look at the 'Queues and Daemons' section in
419    this file for more background processing options.
420
421 4. On the queues server, run the command scripts/startdaemons.sh.
422
423 This will run the queue handlers:
424
425 * queuedaemon.php - polls for queued items for inbox processing and
426   pushing out to OStatus, SMS, XMPP, etc.
427 * imdaemon.php - if an IM plugin is enabled (like XMPP)
428 * other daemons, like TwitterBridge ones, that you may have enabled
429
430 These daemons will automatically restart in most cases of failure
431 including memory leaks (if a memory_limit is set), but may still die
432 or behave oddly if they lose connections to the XMPP or queue servers.
433
434 It may be a good idea to use a daemon-monitoring service, like 'monit',
435 to check their status and keep them running.
436
437 All the daemons write their process IDs (pids) to /var/run/ by
438 default. This can be useful for starting, stopping, and monitoring the
439 daemons. If you are running multiple sites on the same machine, it will
440 be necessary to avoid collisions of these PID files by setting a site-
441 specific directory in config.php:
442
443        $config['daemon']['piddir'] = __DIR__ . '/../run/';
444
445 It is also possible to use a STOMP server instead of our kind of hacky
446 home-grown DB-based queue solution. This is strongly recommended for
447 best response time, especially when using XMPP.
448
449 After installation
450 ==================
451
452 Backups
453 -------
454
455 There is no built-in system for doing backups in GNU social. You can make
456 backups of a working StatusNet system by backing up the database and
457 the Web directory. To backup the database use mysqldump <https://mariadb.com/kb/en/mariadb/mysqldump/>
458 and to backup the Web directory, try tar.
459
460 Upgrading
461 ---------
462
463 Upgrading is strongly recommended to stay up to date with security fixes
464 and new features. For instructions on how to upgrade GNU social code,
465 please see the UPGRADE file.