]> git.mxchange.org Git - friendica.git/blob - doc/Install.md
Fix docs
[friendica.git] / doc / Install.md
1 Friendica Installation
2 ===============
3
4 We've tried very hard to ensure that Friendica will run on commodity hosting platforms - such as those used to host Wordpress blogs and Drupal websites.
5 We offer a manual and an automatic installation.
6 But be aware that Friendica is more than a simple web application.
7 It is a complex communications system which more closely resembles an email server than a web server.
8 For reliability and performance, messages are delivered in the background and are queued for later delivery when sites are down.
9 This kind of functionality requires a bit more of the host system than the typical blog.
10 Not every PHP/MySQL hosting provider will be able to support Friendica.
11 Many will.
12 But **please** review the requirements and confirm these with your hosting provider prior to installation.
13
14 Also if you encounter installation issues, please let us know via the [helper](http://forum.friendi.ca/profile/helpers) or the [developer](https://forum.friendi.ca/profile/developers) forum or [file an issue](https://github.com/friendica/friendica/issues).
15 Please be as clear as you can about your operating environment and provide as much detail as possible about any error messages you may see, so that we can prevent it from happening in the future.
16 Due to the large variety of operating systems and PHP platforms in existence we may have only limited ability to debug your PHP installation or acquire any missing modules - but we will do our best to solve any general code issues.
17 If you do not have a Friendica account yet, you can register a temporary one at [tryfriendica.de](https://tryfriendica.de) and join the forums mentioned above from there.
18 The account will expire after 7 days, but you can ask the server admin to keep your account longer, should the problem not be resolved after that.
19
20 Before you begin: Choose a domain name or subdomain name for your server.
21 Put some thought into this. Changing it after installation is currently not supported.
22 Things will break, and some of your friends may have difficulty communicating with you.
23 We plan to address this limitation in a future release.
24
25
26 Requirements
27 ---
28
29 * Apache with mod-rewrite enabled and "Options All" so you can use a local .htaccess file
30 * PHP 5.6.1+ (PHP 7 is recommended for performance)
31   * PHP *command line* access with register_argc_argv set to true in the php.ini file
32   * Curl, GD, PDO, MySQLi, hash, xml, zip and OpenSSL extensions
33   * The POSIX module of PHP needs to be activated (e.g. [RHEL, CentOS](http://www.bigsoft.co.uk/blog/index.php/2014/12/08/posix-php-commands-not-working-under-centos-7) have disabled it)
34   * some form of email server or email gateway such that PHP mail() works
35 * Mysql 5.5.3+ or an equivalent alternative for MySQL (MariaDB, Percona Server etc.)
36 * the ability to schedule jobs with cron (Linux/Mac) or Scheduled Tasks (Windows) (Note: other options are presented in Section 7 of this document.)
37 * Installation into a top-level domain or sub-domain (without a directory/path component in the URL) is preferred. Directory paths will not be as convenient to use and have not been thoroughly tested.
38 * If your hosting provider doesn't allow Unix shell access, you might have trouble getting everything to work.
39
40 Installation procedure
41 ---
42
43 ### Alternative Installation Methods
44
45 This guide will walk you through the manual installation process of Friendica.
46 If this is nothing for you, you might be interested in
47
48 * the [Friendica Docker image](https://github.com/friendica/docker) or
49 * how [install Friendica with YunoHost](https://github.com/YunoHost-Apps/friendica_ynh).
50
51 ### Get Friendica
52
53 Unpack the Friendica files into the root of your web server document area.
54 If you are able to do so, we recommend using git to clone the source repository rather than to use a packaged tar or zip file.
55 This makes the software much easier to update.
56 The Linux commands to clone the repository into a directory "mywebsite" would be
57
58     git clone https://github.com/friendica/friendica.git -b master mywebsite
59     cd mywebsite
60     bin/composer.phar install
61
62 Make sure the folder *view/smarty3* exists and is writable by the webserver user, in this case `www-data`
63
64     mkdir view/smarty3
65     chown www-data:www-data view/smarty3
66     chmod 775 view/smarty3
67
68 Get the addons by going into your website folder.
69
70     cd mywebsite
71
72 Clone the addon repository (separately):
73
74     git clone https://github.com/friendica/friendica-addons.git -b master addon
75
76 If you copy the directory tree to your webserver, make sure that you also copy .htaccess - as "dot" files are often hidden and aren't normally copied.
77
78 If you want to use the development version of Friendica you can switch to the develop branch in the repository by running
79
80     git checkout develop
81     bin/composer.phar install
82     cd addon
83     git checkout develop
84
85 please be aware that the develop branch may break your Friendica node at any time.
86 If you encounter a bug, please let us know.
87
88 ### Create a database
89
90 Create an empty database and note the access details (hostname, username, password, database name).
91
92 Friendica needs the permission to create and delete fields and tables in its own database.
93
94 With newer releases of MySQL (5.7.17 or newer), you might need to set the sql_mode to '' (blank).
95 Use this setting when the installer is unable to create all the needed tables due to a timestamp format problem.
96 In this case find the [mysqld] section in your my.cnf file and add the line :
97
98     sql_mode = ''
99
100 Restart mysql and you should be fine.
101
102 ### Option A: Run the manual installer
103
104 Point your web browser to the new site and follow the instructions.
105 Please note any error messages and correct these before continuing.
106
107 If you need to specify a port for the connection to the database, you can do so in the host name setting for the database.
108
109 *If* the manual installation fails for any reason, check the following:
110
111 * Does "config/local.config.php" exist? If not, edit config/local-sample.config.php and change the system settings.
112 * Rename to `config/local.config.php`.
113 * Is the database is populated? If not, import the contents of `database.sql` with phpmyadmin or the mysql command line.
114
115 At this point visit your website again, and register your personal account.
116 Registration errors should all be recoverable automatically.
117 If you get any *critical* failure at this point, it generally indicates the database was not installed correctly.
118 You might wish to move/rename `config/local.config.php` to another name and empty (called 'dropping') the database tables, so that you can start fresh.
119
120 ### Option B: Run the automatic install script
121
122 You have the following options to automatically install Friendica:
123 -       creating a prepared config file (f.e. `prepared.config.php`)
124 -       using environment variables (f.e. `MYSQL_HOST`)
125 -       using options (f.e. `--dbhost <host>`)
126
127 You can combine environment variables and options, but be aware that options are prioritized over environment variables. 
128
129 For more information during the installation, you can use this command line option
130
131     bin/console autoinstall -v
132
133 If you wish to include all optional checks, use `-a` like this statement:
134
135     bin/console autoinstall -a
136     
137 *If* the automatic installation fails for any reason, check the following:
138
139 *       Does `config/local.config.php` already exist? If yes, the automatic installation won't start
140 *       Are the options in the `config/local.config.php` correct? If not, edit them directly.
141 *       Is the empty MySQL-database created? If not, create it.
142
143 #### B.1: Config file
144
145 You can use a prepared config file like [local-sample.config.php](config/local-sample.config.php).
146
147 Navigate to the main Friendica directory and execute the following command:
148
149     bin/console autoinstall -f <prepared.config.php>
150     
151 #### B.2: Environment variables
152
153 There are two types of environment variables.
154 -       those you can use in normal mode too (Currently just **database credentials**)
155 -       those you can only use during installation (because Friendica will normally ignore it)
156
157 You can use the options during installation too and skip some of the environment variables.
158
159 **Database credentials**
160
161 if you don't use the option `--savedb` during installation, the DB credentials will **not** be saved in the `config/local.config.php`.
162
163 -       `MYSQL_HOST` The host of the mysql/mariadb database
164 -       `MYSQL_PORT` The port of the mysql/mariadb database
165 -       `MYSQL_USERNAME` The username of the mysql database login (used for mysql)
166 -       `MYSQL_USER` The username of the mysql database login (used for mariadb)
167 -       `MYSQL_PASSWORD` The password of the mysql/mariadb database login
168 -       `MYSQL_DATABASE` The name of the mysql/mariadb database
169
170 **Friendica settings**
171
172 This variables wont be used at normal Friendica runtime.
173 Instead, they get saved into `config/local.config.php`. 
174
175 -       `FRIENDICA_URL_PATH` The URL path of Friendica (f.e. '/friendica')
176 -       `FRIENDICA_PHP_PATH` The path of the PHP binary
177 -       `FRIENDICA_ADMIN_MAIL` The admin email address of Friendica (this email will be used for admin access)
178 -       `FRIENDICA_TZ` The timezone of Friendica
179 -       `FRIENDICA_LANG` The language of Friendica
180
181 Navigate to the main Friendica directory and execute the following command:
182
183     bin/console autoinstall [--savedb]
184
185 #### B.3: Execution options
186
187 All options will be saved in the `config/local.config.php` and are overruling the associated environment variables.
188
189 -       `-H|--dbhost <host>` The host of the mysql/mariadb database (env `MYSQL_HOST`)
190 -       `-p|--dbport <port>` The port of the mysql/mariadb database (env `MYSQL_PORT`)
191 -       `-U|--dbuser <username>` The username of the mysql/mariadb database login (env `MYSQL_USER` or `MYSQL_USERNAME`)
192 -       `-P|--dbpass <password>` The password of the mysql/mariadb database login (env `MYSQL_PASSWORD`)
193 -       `-d|--dbdata <database>` The name of the mysql/mariadb database (env `MYSQL_DATABASE`)
194 -       `-u|--urlpath <url_path>` The URL path of Friendica - f.e. '/friendica' (env `FRIENDICA_URL_PATH`)
195 -       `-b|--phppath <php_path>` The path of the PHP binary (env `FRIENDICA_PHP_PATH`)
196 -       `-A|--admin <mail>` The admin email address of Friendica (env `FRIENDICA_ADMIN_MAIL`)
197 -       `-T|--tz <timezone>` The timezone of Friendica (env `FRIENDICA_TZ`)
198 -       `-L|--lang <language>` The language of Friendica (env `FRIENDICA_LANG`)
199
200 Navigate to the main Friendica directory and execute the following command:
201
202     bin/console autoinstall [options]
203
204 ### Prepare .htaccess file
205
206 Copy .htaccess-dist to .htaccess (be careful under Windows) to have working mod-rewrite again. If you have installed Friendica into a sub directory, like /friendica/ set this path in RewriteBase accordingly.
207
208 Example:
209
210     cp .htacces-dist .htaccess
211
212 *Note*: Do **not** rename the .htaccess-dist file as it is tracked by GIT and renaming will cause a dirty working directory.
213
214 ### Verify the "host-meta" page is working
215
216 Friendica should respond automatically to important addresses under the /.well-known/ rewrite path.
217 One critical URL would look like, for example, https://example.com/.well-known/host-meta
218 It must be visible to the public and must respond with an XML file that is automatically customized to your site.
219
220 If that URL is not working, it is possible that some other software is using the /.well-known/ path.
221 Other symptoms may include an error message in the Admin settings that says "host-meta is not reachable on your system.
222 This is a severe configuration issue that prevents server to server communication."
223 Another common error related to host-meta is the "Invalid profile URL."
224
225 Check for a .well-known directory that did not come with Friendica.
226 The preferred configuration is to remove the directory, however this is not always possible.
227 If there is any /.well-known/.htaccess file, it could interfere with this Friendica core requirement.
228 You should remove any RewriteRules from that file, or remove that whole file if appropriate.
229 It may be necessary to chmod the /.well-known/.htaccess file if you were not given write permissions by default.
230
231 ### Set up the worker
232
233 Set up a cron job or scheduled task to run the worker once every 5-10 minutes in order to perform background processing.
234 Example:
235
236     cd /base/directory; /path/to/php bin/worker.php
237
238 Change "/base/directory", and "/path/to/php" as appropriate for your situation.
239
240 If you are using a Linux server, run "crontab -e" and add a line like the
241 one shown, substituting for your unique paths and settings:
242
243     */10 * * * * cd /home/myname/mywebsite; /usr/bin/php bin/worker.php
244
245 You can generally find the location of PHP by executing "which php".
246 If you run into trouble with this section please contact your hosting provider for assistance.
247 Friendica will not work correctly if you cannot perform this step.
248
249 If it is not possible to set up a cron job then please activate the "frontend worker" in the administration interface.
250
251 Once you have installed Friendica and created an admin account as part of the process, you can access the admin panel of your installation and do most of the server wide configuration from there.
252
253 At this point it is recommended that you set up logging and logrotation.
254 To do so please visit [Settings](help/Settings) and search the 'Logs' section for more information.
255
256 ### Set up a backup plan
257
258 Bad things will happen.
259 Let there be a hardware failure, a corrupted database or whatever you can think of.
260 So once the installation of your Friendica node is done, you should make yourself a backup plan.
261
262 The most important file is the `config/local.config.php` file.
263 As it stores all your data, you should also have a recent dump of your Friendica database at hand, should you have to recover your node.