Posted: May 22, 2019 @ 10:48 AM
To get UAP v4 working on a SuSE Leap 15 installation, several preps are required, which are outlined below.
Purpose is to have a dev environment, with local Apache2 server (with or without virtual hosts) and MariaDB as SQL backend.
#############################
### System Configuration: ###
#############################
fresh install of OpenSuSE Leap 15 (with all updates)
CodePattern Web and LAMP server, and these packages:
apache2-mod_php7
php7
php7-fileinfo
php7-mysql
php7-gd
git
composer
and load the modules:
Codesudo a2enmod php7
sudo a2enmod fileinfo
sudo a2enmod rewrite
#############################
### Apache Configuration: ###
#############################
The file
/etc/hosts should be prepared, I used this:
Code127.0.0.1 localhost
127.0.0.1 oslhpeb840.my.domain oslhpeb840
/etc/apache2/default-server.conf
CodeServerName "oslhpeb840.my.domain"
DocumentRoot "/srv/www/htdocs"
<Directory "/srv/www/htdocs">;
Options FollowSymLinks
AllowOverride All
...
</Directory>
/etc/php7/apache2/php.ini
uncomment the line "extension=openssl", save the file and quit.
######################################
### Check if Apache works for UAP: ###
######################################
(shamelessly stolen from the interwebs)
Create the following files in Apache's DocumentRoot:
File
info.php:
Code<?php
var_dump(stream_get_wrappers());
phpinfo();
?>
File
test.html:
Code<h1 style="color:red">This is the HTML file.</h1>
File
test.php:
Code<h1 style="color:green">HELLO WORLD! This is the PHP file.</h1>
File
.htaccess:
CodeRewriteEngine on
RewriteRule ^/?test.html$ test.php [L]
Codechown wwwrun:www /srv/www/htdocs/*
chmod 664 *
1.) Check if PHP ('a2enmod php7') is working in Apache:
Direct your browser to /srv/www/htdocs/info.php. This should display the PHP webpage with it's version number and the many settings of PHP.
2.) Check if redirect ('a2enmod rewrite') is working
Codeapache2ctl -t -D DUMP_MODULES 2>&1 |grep rewrite
It should display a line like this:
Coderewrite_module (shared)
If it is not, then you might have to run 'a2enmod rewrite'
3.) Check if PHP shows "https" in the first (cryptic) line
If no "https" on the list, it might be missing in /etc/php7/apache2/php.ini.
Direct your browser to /srv/www/htdocs/test.html (Apache's DocumentRoot), the result should be the
green HELLO WORLD line from the php file. If the
red HELLO WORLD line from test.html is shown, the mod_rewrite doesn't work. Check in the config file, if "AllowOverride All" is set for the DocumentRoot.
#############################
### MariaDB Configuration ###
#############################
(shamelessly stolen from the interwebs)
If this is first touch with mariadb (or mysql), I found it useful to have a script to quickly setup default user and database. It is not a good aproach to work all the time with root users.
After the default installation from the LAMP stack, follow the instructions to provide a password to "mariadb root user".
Create this simple script file, name it e.g. ~/uap_initdb.sh, edit the values to your needs, chmod it to 755 and execute it.
File
~/uap_initdb.sh:
Code#! /bin/bash
newUser='uap_user'
newDbPassword='uap_password'
newDb='uap_databse'
host=localhost
#host='%'
commands="CREATE DATABASE \`${newDb}\`;CREATE USER '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT USAGE ON *.* TO '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT ALL privileges ON \`${newDb}\`.*
TO '${newUser}'@'${host}';FLUSH PRIVILEGES;"
echo "setup initial user and database:"
echo "user: ${newUser}"
echo "user pw: ${newDbPassword}"
echo "database: ${newDb}"
echo "Enter mariadb root password to continue:"
echo "${commands}" | /usr/bin/mysql -u root -p
##################
### UAP files: ###
##################
If the installation is done only once, the default (video) setup from the UAP website explains sufficiently, well, how to go. If however you need to repeated setups, and don't want to go through all the manual setup and clicking, this script can help. It will work with any UAP v4 zip file (from GitHub, normal or full installer). Currently version iUAP 4.2.1 is used.
A script called "uap_install.sh" gives several options to install into an
Apache standard server, or into an Apache virtual host. All options
are desribed in the zip file, launch it with "-h" as parameter, or read in
the header of the shell script. It reads its data from "uap.conf", where
one can change default settings. Prerequisite: the files Config.php and
index.php should be in the same directory, as uap_install.sh. They can be edited according to the needs. The script will place them into the required target dirs.
When UAP installation is finished, there is the option to customize,
hence a second script called "uap_customize.sh" is provided. I used it
to change the logo files and to change some database default settings. Your mileage may vary...
###################################################################
### reCaptcha keys (https://www.google.com/recaptcha/intro/v3.html):
### When registering user in UAP after a fresh install, there
### might be an error message in the displayed reCAPTCHA. Here how
### one can preload the values, and get around this issue.
###################################################################
To start using reCAPTCHA, you need to sign up for an API key
pair for your site. The key pair consists of a site key and
secret key. The site key is used to invoke reCAPTCHA service
on your site or mobile application. The secret key authorizes
communication between your application backend and the reCAPTCHA
server to verify the user's response. The secret key needs to
be kept safe for security purposes.
After UAP INSTALL is finished, one can copy the values into the database:
Codeecho "REPLACE INTO uap4_settings SET setting_id = 12, setting_title = 'site_recapcha_public', setting_data = '$recaptcha_pubkey';" > tmp_sql_fqfn
echo "REPLACE INTO uap4_settings SET setting_id = 13, setting_title = 'site_recapcha_private', setting_data = '$recaptcha_privkey';" >> tmp_sql_fqfn
mysql -u $db_username -p"$db_passwd" $db_name < tmp_sql_fqfn
for the purpose of the test setup above, use these keys:
pubkey: 6LcBDqMUAAAAAC9lz2BRaxjJ4Slj_iC1Rq6xIzxu
privkey: 6LcBDqMUAAAAANtN1vGPVWKuEUl6lKBdY7M874B1