streams/install/INSTALL.txt
2024-05-07 08:55:29 +10:00

385 lines
16 KiB
Text

Software Installation
We've tried very hard to ensure that this software will run on commodity
hosting platforms - such as those used to host Wordpress blogs and Drupal
websites. It will run on most any Linux VPS system or LAMP container.
Windows LAMP platforms such as XAMPP and WAMP are not officially supported
at this time - however we welcome patches if you manage to get it working.
Be aware that this software is more than a simple web application. It is a
complex communications and content management system which more closely
resembles an email server than a web server. For reliability and performance,
messages are delivered in the background and are queued for later delivery
when sites are down. This kind of functionality requires a bit more of the
host system than the typical blog. Not every PHP/MySQL hosting provider will
be able to support these requirements. Many will - but please review the
requirements and confirm these with your hosting provider prior to
installation. (And preferably before entering into a long-term contract.)
**Before you begin**
Choose a domain name or subdomain name for your server.
The software can only be installed into the root of a domain or
sub-domain, and can not be installed using alternate TCP ports. These
restrictions may be relaxed in the future, but will be inconvenient to work
with, so we still STRONGLY recommend you abide by them.
SSL is REQUIRED and you MUST use a "browser-valid" certificate. You MUST NOT
use self-signed certificates!
Please test your certificate prior to installation. A web tool for testing your
certificate is available at "http://www.digicert.com/help/". When visiting your
site for the first time, please use the SSL ("https://") URL. This will avoid
problems later.
Free "browser-valid" certificates are available from providers such as ZeroSSL
and LetsEncrypt.
If you use LetsEncrypt to provide certificates and create a file under
.well-known/acme-challenge so that LetsEncrypt can verify your domain
ownership, please remove or rename the .well-known directory as soon as the
certificate is generated. The software will provide its own handler for
".well-known" services when it is installed, and an existing directory in this
location may prevent some of these services from working correctly. This
should not be a problem with Apache, but may be an issue with nginx or other
web server platforms.
**Installation**
1. Requirements
- Apache with mod-rewrite enabled and "AllowOverride All" so you can use a
local .htaccess file. Some folks have successfully used nginx and lighttpd.
Example config scripts are available for these platforms in the install
directory. Apache and nginx have the most support.
- PHP 8.1 or later.
- PHP *command line* access with register_argc_argv set to true in the
php.ini file - and with no hosting provider restrictions on the use of
exec() and proc_open().
- Composer - visit getcomposer.org and follow the instructions.
- curl, gd (with at least jpeg and png support), sodium, mysqli, mbstring,
xml, xmlreader (FreeBSD), zip and openssl extensions. The imagick extension
MAY be used instead of gd, but is not required and MAY also be disabled via
configuration option. One of bcmath or gmp are also required for encryption
support.
- some form of email server or email gateway such that PHP mail() works.
- Mysql 5.5.3 or later or MariaDB or postgres database server.
Case-insensitive search was not supported on postgres when this document was
released. This is not harmful, but does make searching for things more difficult.
- ability to schedule jobs with cron.
- Installation into a top-level domain or sub-domain (without a
directory/path component in the URL) is REQUIRED.
2. Unpack the project files into the root of your web server document area.
- 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. This makes the
software much easier to update. The Linux command to clone the repository
into a directory "mywebsite" would be
git clone https://codeberg.org/streams/streams.git mywebsite
- Check out the 'release' branch. This is recommended as it is well tested and stable.
git checkout release
- If you are a developer and interested in working with the absolute latest code changes, you might wish to checkout the 'dev' branch instead. This contains experimental code and is often not as well tested. Use at your own risk.
- Pull in external libraries with composer. Leave off the --no-dev
option if you are a developer and wish to install addditional CI/CD tools.
composer install --no-dev
- and then you can pick up the latest changes at any time with
git pull
composer install --no-dev
- If using Apache as your webserver, copy the file "htaccess.dist" to ".htaccess".
cp htaccess.dist .htaccess
- make sure the folders "cache/smarty3" and "store" exist and are
writable by the webserver.
mkdir -p "store"
mkdir -p "cache/smarty3"
chmod -R 700 store cache
This permission (700) should be used if you are logged in with the
same system uid that starts webserver processes. If this is not the
case, the object of this command is to allow full read/write access
to this directory only by the webserver.
- For installing addons
- First you should be **on** your website folder
cd mywebsite
- Then you should clone the addon repository (separately). We'll give this repository
a nickname of 'zaddons'. You can pull in other addon repositories by
giving them different nicknames.
util/add_addon_repo https://codeberg.org/streams/streams-addons.git zaddons
- This should pull the 'release' branch by default (mentioned earlier). If you are in doubt,
cd extend/addon/zaddons
git checkout release
cd mywebsite
- replace withh a different code branch name or repository nickname if your situation requires.
- For keeping the addon tree updated, you should be on your top level website
directory and issue an update command for that repository.
cd mywebsite
util/update_addon_repo zaddons
3. Create an empty database and note the access details (hostname, username,
password, database name). The PDO database libraries will fallback to socket
communication if the hostname is 'localhost' and some people have reported
issues with the socket implementation. Use it if your requirements mandate.
Otherwise if the database is served on the local server, use '127.0.0.1' for
the hostname. When using MySQL or MariaDB, please set the database character
encoding to utf8mb4 to avoid encoding issues with emojis. All the internal
tables are created with utf8mb4_general_ci encoding, but issues have been
encountered when using these in a database that was configured for 'utf8'
and not utf8mb4.
Internally we now use the PDO library for database connections. If you
encounter a database configuration which cannot be expressed on the setup form
(for instance using MySQL with an unusual socket location); you can supply
the PDO connection string as the database hostname. For instance
mysql:unix_socket=/my/special/socket_path
You should still fill in all other applicable form values as needed.
4. If you know in advance that it will be impossible for the web server to
write or create files in your web directory, create an empty file called
.htconfig.php and make it writable by the web server.
5. Visit your website with a web browser and follow the instructions. Please
note any error messages and correct these before continuing. If you are using
SSL with a known signature authority, use the https: link to your
website.
6. *If* the automated installation fails for any reason, check the following:
- ".htconfig.php" exists
If not, edit htconfig.php and change system settings. Rename
to .htconfig.php
- Database is populated.
If not, import the contents of "install/schema_xxxxx.sql" with phpmyadmin
or mysql command line (replace 'xxxxx' with your DB type).
7. At this point visit your website again, and register your personal account.
Registration errors should all be recoverable automatically.
If you get any *critical* failure at this point, it generally indicates the
database was not installed correctly. You might wish to move/rename
.htconfig.php to another name and empty (called 'dropping') the database
tables, so that you can start fresh.
In order for your account to be given administrator access, it should be the
first account created, and the email address provided during registration
must match the "administrator email" address you provided during
installation. Otherwise to give an account administrator access,
add 4096 to the account_roles for that account in the database.
For your site security there is no way to provide administrator access
using web forms.
****************************************************************************
****************************************************************************
******** THIS NEXT STEP IS IMPORTANT!!!! ***********
****************************************************************************
****************************************************************************
8. Set up a cron job or scheduled task to run the Cron manager once every 10-15
minutes to perform background processing and maintenance. Example:
cd /base/directory; /path/to/php src/Daemon/Run.php Cron
Change "/base/directory", and "/path/to/php" as appropriate for your situation.
If you are using a Linux server, run "crontab -e" and add a line like the
one shown, substituting for your unique paths and settings:
*/10 * * * * cd /home/myname/mywebsite; /usr/bin/php src/Daemon/Run.php Cron > /dev/null 2>&1
You can generally find the location of PHP by executing "which php". If you
have troubles with this section please contact your hosting provider for
assistance. The software will not work correctly if you cannot perform this
step.
You should also be sure that App::$config['system']['php_path'] is set
correctly in your .htconfig.php file, it should look like (changing it to the
correct PHP location):
App::$config['system']['php_path'] = '/usr/local/php74/bin/php';
#####################################################################
If things don't work...
#####################################################################
#####################################################################
- If you get the message
"System is currently unavailable. Please try again later"
#####################################################################
Check your database settings. It usually means your database could not be
opened or accessed. If the database resides on the same machine, check that
the database server name is "127.0.0.1" or the word "localhost".
#####################################################################
- 500 Internal Error
#####################################################################
This could be the result of one of our Apache directives not being
supported by your version of Apache. Examine your apache server logs.
Also check your file permissions. Your website and all contents must generally
be world-readable.
It is likely that your web server reported the source of the problem in
its error log files. Please review these system error logs to determine what
caused the problem. Often this will need to be resolved with your hosting
provider or (if self-hosted) your web server configuration.
#####################################################################
- 400 and 4xx "File not found" errors
#####################################################################
First check your file permissions. Your website and all contents must
generally be world-readable.
Ensure that mod-rewite is installed and working, and that your
.htaccess file is being used. To verify the latter, create a file test.out
containing the word "test" in the top web directory, make it world
readable and point your web browser to
http://yoursitenamehere.com/test.out
This file should be blocked. You should get a permission denied message.
If you see the word "test" your Apache configuration is not allowing your
.htaccess file to be used (there are rules in this file to block access
to any file with .out at the end, as these are typically used for system logs).
Make certain the .htaccess file exists and is readable by everybody, then
look for the existence of "AllowOverride None" in the Apache server
configuration for your site. This will need to be changed to
"AllowOverride All".
If you do not see the word "test", your .htaccess is working, but it is
likely that mod-rewrite is not installed in your web server or is not working.
On most flavours of Linux,
% a2enmod rewrite
% service apache2 restart
Consult your hosting provider, experts on your particular Linux
distribution or (if Windows) the provider of your Apache server software if
you need to change either of these and can not figure out how. There is
a lot of help available on the web. Google "mod-rewrite" along with the
name of your operating system distribution or Apache package.
#####################################################################
- If you see an error during database setup that DNS lookup failed
#####################################################################
This is a known issue on some versions of FreeBSD, because
dns_get_record() fails for some lookups. Create a file in your top webserver
folder called '.htpreconfig.php' and inside it put the following:
<?php
App::$config['system']['do_not_check_dns'] = 1;
This should allow installation to proceed. Once the database has been
installed, add the same config statement (but not the '<?php' line) to the
.htconfig.php file which was created during installation.
#####################################################################
- If you are unable to write the file .htconfig.php during installation
due to permissions issues:
#####################################################################
create an empty file with that name and give it world-write permission.
For Linux:
% touch .htconfig.php
% chmod 777 .htconfig.php
Retry the installation. As soon as the database has been created,
******* this is important *********
% chmod 755 .htconfig.php
#####################################################################
- Apache processes hanging, using as much CPU as they can
#####################################################################
This seems to happen sometimes if you use mpm_prefork and the PHP process
started by Apache cannot get database access.
Consider the following settings:
In /etc/apache2/mods-enabled/mpm_prefork.conf (Debian, path and file name
may vary depending on your OS and distribution), set
GracefulShutdownTimeout 300
This makes sure that Apache processes that are running wild will not do so
forever, but will be killed if they didn't stop five minutes after a
shutdown command was sent to the process.
If you expect high load on your server (public servers, e.g.), also make
sure that Apache will not spawn more processes than MySQL will accept
connections.
In the default Debian configuration, in
/etc/apache2/mods-enabled/mpm_prefork.conf the maximum number of workers
is set to 150:
MaxRequestWorkers 150
However, in /etc/mysql/my.cnf the maximum number of connection is set to
100:
max_connections = 100
150 workers are a lot and probably too much for small servers. However you
set those values, make sure that the number of Apache workers is smaller
than the number of connections MySQL accepts, leaving some room for other
stuff on your server that might access MySQL, and the communication poller
whichneeds MySQL access, too. A good setting for a medium-sized hub might be
to keep MySQL's max_connections at 100 and set mpm_prefork's MaxRequestWorkers
to 70.
Here you can read more about Apache performance tuning:
https://httpd.apache.org/docs/2.4/misc/perf-tuning.html
There are tons of scripts to help you with fine-tuning your Apache
installation. Just search with your favorite search engine
'apache fine-tuning script'.