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