INSTALL 18 KB

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