|
| 1 | +Installation on Ubuntu 24.04 |
| 2 | +============================ |
| 3 | + |
| 4 | +# 1. Dependencies |
| 5 | + |
| 6 | +Install some utilities, database, webserver |
| 7 | +```bash |
| 8 | +sudo apt update |
| 9 | +sudo apt-get install -y zip unzip git gettext curl jq mariadb-client mariadb-server apache2 |
| 10 | +``` |
| 11 | + |
| 12 | +Install PHP and its dependencies (the default php version in Ubuntu 24.04 is php8.3): |
| 13 | +```bash |
| 14 | +sudo apt-get install -y php php-cli php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-bcmath php-intl php-imagick |
| 15 | +``` |
| 16 | + |
| 17 | +# 2. Monarc files |
| 18 | + |
| 19 | +Run the [install_latest_fo_release.sh](../scripts/install_latest_fo_release.sh) script with `sudo` |
| 20 | + to download the latest Monarc release and unpack it into `/var/lib/monarc/`. |
| 21 | + |
| 22 | +> The script is built to be used in the CI/CD pipelines and will fail with a clear error if the release is not reachable or the deploy directory already exits. |
| 23 | +
|
| 24 | +# 3. Webserver |
| 25 | + |
| 26 | +Enable required Apache modules: |
| 27 | + |
| 28 | +```bash |
| 29 | +sudo a2dismod status |
| 30 | +sudo a2enmod ssl |
| 31 | +sudo a2enmod rewrite |
| 32 | +sudo a2enmod headers |
| 33 | +``` |
| 34 | + |
| 35 | +Modify the default virtual host: |
| 36 | + |
| 37 | +```bash |
| 38 | +sudo nano /etc/apache2/sites-enabled/000-default.conf |
| 39 | +``` |
| 40 | + |
| 41 | +Use this configuration as an example: |
| 42 | + |
| 43 | +```conf |
| 44 | +<VirtualHost _default_:80> |
| 45 | + ServerAdmin admin@example.com |
| 46 | + ServerName monarc.local |
| 47 | + DocumentRoot /var/lib/monarc/fo/public |
| 48 | +
|
| 49 | + <Directory /var/lib/monarc/fo/public> |
| 50 | + DirectoryIndex index.php |
| 51 | + AllowOverride All |
| 52 | + Require all granted |
| 53 | + |
| 54 | + # increase the default php limits |
| 55 | + # better here then in the global php.ini as the webserver could run other projects |
| 56 | + php_value upload_max_filesize 200M |
| 57 | + php_value post_max_size 50M |
| 58 | + php_value max_execution_time 100 |
| 59 | + php_value max_input_time 223 |
| 60 | + php_value memory_limit 512M |
| 61 | + # Error logs settings for production: |
| 62 | + php_value error_reporting E_ALL |
| 63 | + php_flag log_errors On |
| 64 | + # for development, set to "On" |
| 65 | + php_flag display_errors Off |
| 66 | +
|
| 67 | + </Directory> |
| 68 | +
|
| 69 | + <IfModule mod_headers.c> |
| 70 | + Header always set X-Content-Type-Options nosniff |
| 71 | + Header always set X-XSS-Protection "1; mode=block" |
| 72 | + Header always set X-Robots-Tag none |
| 73 | + Header always set X-Frame-Options SAMEORIGIN |
| 74 | + </IfModule> |
| 75 | +
|
| 76 | + SetEnv APP_ENV "production" |
| 77 | +</VirtualHost> |
| 78 | +``` |
| 79 | + |
| 80 | +Check the configuration and apply changes: |
| 81 | + |
| 82 | +```bash |
| 83 | +apachectl configtest |
| 84 | +sudo apachectl restart |
| 85 | +``` |
| 86 | + |
| 87 | + |
| 88 | +# 4. Database |
| 89 | + |
| 90 | +Secure the MariaDB installation and set a strong root password. |
| 91 | + |
| 92 | +```bash |
| 93 | +sudo mysql_secure_installation |
| 94 | +``` |
| 95 | + |
| 96 | +## 4.1 Create a database user |
| 97 | + |
| 98 | +Start MariaDB as root: |
| 99 | + |
| 100 | +```bash |
| 101 | +sudo mysql |
| 102 | +``` |
| 103 | + |
| 104 | +Create a new user for MONARC (please use more secured password): |
| 105 | + |
| 106 | +```sql |
| 107 | +CREATE USER 'monarc'@'%' IDENTIFIED BY 'password'; |
| 108 | +GRANT ALL PRIVILEGES ON monarc_cli.* TO 'monarc'@'%'; |
| 109 | +GRANT ALL PRIVILEGES ON monarc_common.* TO 'monarc'@'%'; |
| 110 | +FLUSH PRIVILEGES; |
| 111 | +``` |
| 112 | + |
| 113 | +## 4.2 Create 2 databases |
| 114 | + |
| 115 | +In your MariaDB interpreter: |
| 116 | + |
| 117 | +```sql |
| 118 | +CREATE DATABASE monarc_cli DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; |
| 119 | +CREATE DATABASE monarc_common DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; |
| 120 | +``` |
| 121 | + |
| 122 | +* monarc_common contains models and data created by CASES; |
| 123 | +* monarc_cli contains all client risk analyses. Each analysis is based on CASES model of monarc_common. |
| 124 | + |
| 125 | +## 4.3 Initialize the database |
| 126 | + |
| 127 | +```bash |
| 128 | +cd /var/lib/monarc/fo |
| 129 | +mysql -u monarc -ppassword monarc_common < db-bootstrap/monarc_structure.sql |
| 130 | +mysql -u monarc -ppassword monarc_common < db-bootstrap/monarc_data.sql |
| 131 | +``` |
| 132 | + |
| 133 | +## 4.4 Connect Monarc App to the database |
| 134 | + |
| 135 | +Create and edit the configuration file: |
| 136 | + |
| 137 | +```bash |
| 138 | +sudo cp ./config/autoload/local.php.dist ./config/autoload/local.php |
| 139 | +sudo nano ./config/autoload/local.php |
| 140 | +``` |
| 141 | + |
| 142 | +Configure the database connection (use the secured password set on the DB user creation step): |
| 143 | + |
| 144 | +```php |
| 145 | + return [ |
| 146 | + 'doctrine' => [ |
| 147 | + 'connection' => [ |
| 148 | + 'orm_default' => [ |
| 149 | + 'params' => [ |
| 150 | + 'host' => 'localhost', |
| 151 | + 'user' => 'monarc', |
| 152 | + 'password' => 'password', |
| 153 | + 'dbname' => 'monarc_common', |
| 154 | + ], |
| 155 | + ], |
| 156 | + 'orm_cli' => [ |
| 157 | + 'params' => [ |
| 158 | + 'host' => 'localhost', |
| 159 | + 'user' => 'monarc', |
| 160 | + 'password' => 'password', |
| 161 | + 'dbname' => 'monarc_cli', |
| 162 | + ], |
| 163 | + ], |
| 164 | + ], |
| 165 | + ], |
| 166 | + ]; |
| 167 | +``` |
| 168 | + |
| 169 | +## 4.5 Migrate the MONARC DB |
| 170 | + |
| 171 | +```bash |
| 172 | +bash ./scripts/upgrade-db.sh |
| 173 | +``` |
| 174 | + |
| 175 | +## 4.6 Create initial user |
| 176 | + |
| 177 | +```bash |
| 178 | +php ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/Monarc/FrontOffice/migrations/phinx.php |
| 179 | +``` |
| 180 | + |
| 181 | +The username is *admin@admin.localhost* and the password is *admin*. |
| 182 | + |
| 183 | + |
| 184 | +# 5. Statistics for Global Dashboard |
| 185 | + |
| 186 | +If you would like to use the global dashboard stats feature, you need to |
| 187 | +configure a Stats Service instance on your server. |
| 188 | + |
| 189 | +The architecture, installation instructions and GitHub project can be found here: |
| 190 | + |
| 191 | +- https://www.monarc.lu/documentation/stats-service/master/architecture.html |
| 192 | +- https://www.monarc.lu/documentation/stats-service/master/installation.html |
| 193 | +- https://github.com/monarc-project/stats-service |
| 194 | + |
| 195 | +The Virtual Machine installation script could be used to detail more steps in case of additional configuration necessity: |
| 196 | +https://github.com/monarc-project/monarc-packer/blob/ubuntu-22.04/scripts/bootstrap.sh |
| 197 | + |
| 198 | +The communication of access to the StatsService is performed on each instance of |
| 199 | +FrontOffice (clients). |
0 commit comments