<commit_before># INSTALLATION INSTRUCTIONS for RHEL 7.x
-------------------------

## 0/ Overview and Assumptions
This document details the steps to install MISP on Red Hat Enterprise Linux 7.x (RHEL 7.x). At time of this writing it
was tested on version 7.4.

The following assumptions with regard to this installation have been made.

### 0.1/ A valid support agreement allowing the system to register to the Red Hat Customer Portal and receive updates
### 0.2/ The ability to enable additional RPM repositories, specifically the EPEL and Software Collections (SCL) repos
### 0.3/ This system will have direct or proxy access to the Internet for updates. Or connected to a Red Hat Satellite Server
### 0.4/ This document is to get a MISP instance up and running over HTTP. I haven't done a full test of all features

# 1/ OS Install and additional repositories

## 1.1/ Complete a minimal RHEL installation, configure IP address to connect automatically.

## 1.2/ Configure system hostname
```bash
hostnamectl set-hostname misp # You're choice, in a production environment, it's best to use a FQDN
```

## 1.3/ Register the system for updates with Red Hat Subscription Manager
```bash
subscription-manager register # register your system to an account
subscription-manager attach   # attach your system to a current subscription
```

## 1.4/ Enable the optional, extras and Software Collections (SCL) repos
```bash
subscription-manager repos --enable rhel-7-server-optional-rpms
subscription-manager repos --enable rhel-7-server-extras-rpms
subscription-manager repos --enable rhel-server-rhscl-7-rpms
```

### 1.5a/ OPTIONAL: Install the deltarpm package to help reduce download size when installing updates
```bash
yum install deltarpm
```

## 1.5/ Update the system and reboot
```bash
yum update
```

!!! note
    As time of writing performing a yum update results in the rhel-7-server-rt-beta-rpms being forbidden.<br />
    The repo can be disabled using the following command
    ```bash
    subscription-manager repos --disable rhel-7-server-rt-beta-rpms
    ```

## 1.6/ Install the EPEL repo
```bash
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
```

## 1.7/ Install the SCL repo
```bash
yum install centos-release-scl
```

# 2/ Install Dependencies
Once the system is installed and updated, the following steps can be performed as root

## 2.01/ Install some base system dependencies
```bash
yum install gcc git httpd zip python-devel libxslt-devel zlib-devel python-pip ssdeep-devel
```

## 2.02/ Install MariaDB 10.2 from SCL
```bash
yum install rh-mariadb102
```

## 2.03/ Start the MariaDB service and enable it to start on boot
```bash
systemctl start rh-mariadb102-mariadb.service
systemctl enable rh-mariadb102-mariadb.service
```

!!! note
    MISP 2.4 requires PHP 5.6 as a minimum, we need a higher version than base RHEL provides.<br />
    This guide installs PHP 7.1 from SCL

!!! warning
    [PHP 5.6 will be EOL in December 2018](https://secure.php.net/supported-versions.php). Please update accordingly. In future only PHP7 will be supported.

## 2.04/ Install PHP 7.1 from SCL
```bash
yum install rh-php71 rh-php71-php-fpm rh-php71-php-devel rh-php71-php-mysqlnd rh-php71-php-mbstring rh-php71-php-xml rh-php71-php-bcmath rh-php71-php-opcache
```

!!! note
    If we want to use httpd from RHEL base we can use the rh-php71-php-fpm service instead

## 2.05/ Start the PHP FPM service and enable to start on boot
```bash
systemctl start rh-php71-php-fpm.service
systemctl enable rh-php71-php-fpm.service
```

## 2.06/ Install redis 3.2 from SCL
```bash
yum install rh-redis32
```

## 2.07/ Start redis service and enable to start on boot
```bash
systemctl start rh-redis32-redis.service
systemctl enable rh-redis32-redis.service
```

## 2.08/ Start a SCL shell with rh-mariadb102 rh-php71 and rh-redis32 enabled
```bash
scl enable rh-mariadb102 rh-php71 rh-redis32 bash
```

## 2.08/ Secure the MariaDB installation, run the following command and follow the prompts
```bash
mysql_secure_installation
```

## 2.10/ Update the PHP extension repository and install required package
```bash
pear channel-update pear.php.net
pear install Crypt_GPG
```

## 2.11/ Install haveged and enable to start on boot to provide entropy for GPG
```bash
yum install haveged
systemctl start haveged
systemctl enable haveged
```

## 2.12/ Install Python 3.6 from SCL
```bash
yum install rh-python36
```

# 3/ MISP Download
## 3.01/ Download MISP code using git in /var/www/ directory
```bash
cd /var/www
git clone https://github.com/MISP/MISP.git
git checkout tags/$(git describe --tags `git rev-list --tags --max-count=1`)
# if the last shortcut doesn't work, specify the latest version manually
# example: git checkout tags/v2.4.XY
# the message regarding a "detached HEAD state" is expected behaviour
# (you only have to create a new branch, if you want to change stuff and do a pull request for example)
```

## 3.02/ Make git ignore filesystem permission differences
```bash
git config core.filemode false
```

## 3.03/ Install Mitre's STIX and its dependencies by running the following commands
```bash
pip install importlib
yum install python-six
cd /var/www/MISP/app/files/scripts
git clone https://github.com/CybOXProject/python-cybox.git
git clone https://github.com/STIXProject/python-stix.git
cd /var/www/MISP/app/files/scripts/python-cybox
git config core.filemode false<commit_msg>chg: [docs] Minor regression, fixed.<commit_after># INSTALLATION INSTRUCTIONS for RHEL 7.x
-------------------------

## 0/ Overview and Assumptions
This document details the steps to install MISP on Red Hat Enterprise Linux 7.x (RHEL 7.x). At time of this writing it
was tested on version 7.5.

The following assumptions with regard to this installation have been made.

### 0.1/ A valid support agreement allowing the system to register to the Red Hat Customer Portal and receive updates
### 0.2/ The ability to enable additional RPM repositories, specifically the EPEL and Software Collections (SCL) repos
### 0.3/ This system will have direct or proxy access to the Internet for updates. Or connected to a Red Hat Satellite Server
### 0.4/ This document is to get a MISP instance up and running over HTTP. I haven't done a full test of all features

# 1/ OS Install and additional repositories

## 1.1/ Complete a minimal RHEL installation, configure IP address to connect automatically.

## 1.2/ Configure system hostname
```bash
hostnamectl set-hostname misp # You're choice, in a production environment, it's best to use a FQDN
```

## 1.3/ Register the system for updates with Red Hat Subscription Manager
```bash
subscription-manager register # register your system to an account
subscription-manager attach   # attach your system to a current subscription
```

## 1.4/ Enable the optional, extras and Software Collections (SCL) repos
```bash
subscription-manager repos --enable rhel-7-server-optional-rpms
subscription-manager repos --enable rhel-7-server-extras-rpms
subscription-manager repos --enable rhel-server-rhscl-7-rpms
```

### 1.5a/ OPTIONAL: Install the deltarpm package to help reduce download size when installing updates
```bash
yum install deltarpm
```

## 1.5/ Update the system and reboot
```bash
yum update
```

!!! note
    As time of writing performing a yum update results in the rhel-7-server-rt-beta-rpms being forbidden.<br />
    The repo can be disabled using the following command
    ```bash
    subscription-manager repos --disable rhel-7-server-rt-beta-rpms
    ```

## 1.6/ Install the EPEL repo
```bash
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
```

## 1.7/ Install the SCL repo
```bash
yum install centos-release-scl
```

# 2/ Install Dependencies
Once the system is installed and updated, the following steps can be performed as root

## 2.01/ Install some base system dependencies
```bash
yum install gcc git httpd zip python-devel libxslt-devel zlib-devel python-pip ssdeep-devel
```

## 2.02/ Install MariaDB 10.2 from SCL
```bash
yum install rh-mariadb102
```

## 2.03/ Start the MariaDB service and enable it to start on boot
```bash
systemctl start rh-mariadb102-mariadb.service
systemctl enable rh-mariadb102-mariadb.service
```

!!! note
    MISP 2.4 requires PHP 5.6 as a minimum, we need a higher version than base RHEL provides.<br />
    This guide installs PHP 7.1 from SCL

!!! warning
    [PHP 5.6 will be EOL in December 2018](https://secure.php.net/supported-versions.php). Please update accordingly. In future only PHP7 will be supported.

## 2.04/ Install PHP 7.1 from SCL
```bash
yum install rh-php71 rh-php71-php-fpm rh-php71-php-devel rh-php71-php-mysqlnd rh-php71-php-mbstring rh-php71-php-xml rh-php71-php-bcmath rh-php71-php-opcache
```

!!! note
    If we want to use httpd from RHEL base we can use the rh-php71-php-fpm service instead

## 2.05/ Start the PHP FPM service and enable to start on boot
```bash
systemctl start rh-php71-php-fpm.service
systemctl enable rh-php71-php-fpm.service
```

## 2.06/ Install redis 3.2 from SCL
```bash
yum install rh-redis32
```

## 2.07/ Start redis service and enable to start on boot
```bash
systemctl start rh-redis32-redis.service
systemctl enable rh-redis32-redis.service
```

## 2.08/ Start a SCL shell with rh-mariadb102 rh-php71 and rh-redis32 enabled
```bash
scl enable rh-mariadb102 rh-php71 rh-redis32 bash
```

## 2.08/ Secure the MariaDB installation, run the following command and follow the prompts
```bash
mysql_secure_installation
```

## 2.10/ Update the PHP extension repository and install required package
```bash
pear channel-update pear.php.net
pear install Crypt_GPG
```

## 2.11/ Install haveged and enable to start on boot to provide entropy for GPG
```bash
yum install haveged
systemctl start haveged
systemctl enable haveged
```

## 2.12/ Install Python 3.6 from SCL
```bash
yum install rh-python36
```

# 3/ MISP Download
## 3.01/ Download MISP code using git in /var/www/ directory
```bash
cd /var/www
git clone https://github.com/MISP/MISP.git
cd MISP
git checkout tags/$(git describe --tags `git rev-list --tags --max-count=1`)
# if the last shortcut doesn't work, specify the latest version manually
# example: git checkout tags/v2.4.XY
# the message regarding a "detached HEAD state" is expected behaviour
# (you only have to create a new branch, if you want to change stuff and do a pull request for example)
```

## 3.02/ Make git ignore filesystem permission differences
```bash
git config core.filemode false
```

## 3.03/ Install Mitre's STIX and its dependencies by running the following commands
```bash
pip install importlib
yum install python-six
cd /var/www/MISP/app/files/scripts
git clone https://github.com/CybOXProject/python-cybox.git
git clone https://github.com/STIXProject/python-stix.git
cd /var/www/MISP/app/files/scripts/python-cybox
git config core.filemode false
{'fraction_non_alphanumeric': 0.10127394372651452, 'fraction_numerical': 0.029694803409403354, 'mean_word_length': 3.937556561085973, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 10, 'lorem ipsum': 0, 'www.': 6, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5964026', 'n_tokens_mistral': 3697, 'n_tokens_neox': 3279, 'n_words': 1371}