Skip to content

Latest commit

 

History

History
270 lines (152 loc) · 6.57 KB

INSTALLATION.md

File metadata and controls

270 lines (152 loc) · 6.57 KB

Create a virtual environment for the project

$ python -m venv venv

* Note: Make sure you are using python v3

Activate the virtual environment

$ source venv/bin/activate

For Windows OS:

$ .\venv\Scripts\activate

Install the required python modules (while inside the virtual environment)

(venv) $ pip install -r requirements.txt

Start the project (while inside the virtual environment)

(venv) $ python app.py

* Note: This way of running the project is good for development and testing only, for production deployment you better use a WSGI server

To leave the virtual environment

(venv) $ deactivate


Apache configuration on Debian & RHEL/CentOS based systems and needed modules

1- Install and enable Apache

Debian

$ sudo apt-get install apache2

RHEL/CentOS

$ sudo yum install httpd

$ sudo systemctl --now enable httpd

* Note: Make sure that the Apache web server has been properly set-up open your web browser and point it to the server IP address. You should see a simple "It works!" page. * Note: Enable the ports used

2- Install and Enable mod_wsgi

Debian

$ sudo apt-get install libapache2-mod-wsgi

$ sudo a2enmod wsgi

RHEL/CentOS

$ sudo yum install mod_wsgi

$ sudo systemctl restart httpd

3-Place CVE-Monitor app in apache directory

Debian & RHEL/CentOS

$ sudo mv /path/CVE-Monitor /var/www/html/CVE-Monitor

4-Edit the path in app.wsgi File

Debian & RHEL/CentOS

$ sudo nano /var/www/html/CVE-Monitor/app.wsgi

The file should look something like this:

#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/html/CVE-Monitor/")
from app import app as application

5-Configure and Enable a New Virtual Host

Debian

$ sudo nano /etc/apache2/sites-available/CVE-Monitor.conf

RHEL/CentOS

$ sudo nano /etc/httpd/conf.d/CVE-Monitor.conf

<VirtualHost *:80>
                # Be sure to change the ServerName to your domain or IP address
                ServerName  domain.com
                # If you’re using global Python installation, no need to include python-path directive
                WSGIDaemonProcess CVE-Monitor python-path=/var/www/html/CVE-Monitor: /path/lib/python3/site-packages
                WSGIProcessGroup CVE-Monitor
                # Give an alias (/cve) to start the website url with
                WSGIScriptAlias /cve    /var/www/html/CVE-Monitor/app.wsgi
                <Directory /var/www/html/CVE-Monitor/>
                        # Set permissions as per apache2.conf file
                        Require all granted
                </Directory>
                Alias /static /var/www/html/CVE-Monitor/static
                <Directory  /var/www/html/CVE-Monitor/static/>
                        Require all granted
                </Directory>
                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Enable the new virtual host

Debian

$ sudo a2ensite CVE-Monitor.conf

6- Restart Apache

Debian

$ sudo service apache2 restart

RHEL/CentOS

$ sudo systemctl restart httpd

Notes:

  • Make sure to open the needed ports for apache on your server firewall (port 80 for http or port 443 for https)
  • If you are using SELinux then allow apache to access the network since it needs it to get the cve data from the internet.
  • The errors from the python code will be stored in apache error file under /var/log/

Apache configuration on Windows and needed modules

1- Install Apache

It's recommended to install the Apache distribution from Apache Lounge (www.apachelounge.com).

After downloading Apache, extract the file contents to a suitable location on your server. By default, Apache configuration file assumes that Apache is extracted to “C:\Apache24” directory.

  • If it’s not extracted there, you need to update the ${SRVROOT} variable in "Apache24\conf\httpd.conf" file

$ Define SRVROOT “c:/path/Apache24”

Install Apache Server as a Windows Service:

Open a command prompt and Run as Administrator, move to “bin” folder

$ cd c:\Apache24\bin

$ httpd.exe -k install

Start Apache Service

$ httpd.exe -k start

* Note: Make sure that the Apache web server has been properly set-up open your web browser and point it to the server IP address. You should see a simple "It works!" page

2-Install mod_wsgi

* Note: Microsoft Visual C++ compiler need to be installed in order to install mod_wsgi

You can download and install “Build tools for Visual Studio” from https://visualstudio.microsoft.com/downloads/

* Note: If the Apache is installed in a path other than"c:/Apach24" you need to set the path

$ set "MOD_WSGI_APACHE_ROOTDIR= path\Apache24"

$ pip install mod_wsgi

Configure mod_wsgi

$ mod-wsgi-express module-config

The output should be something like this:

LoadFile "c:/...../local/programs/python/python36/python36.dl"
LoadModule wsgi_module  "c:/...../lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd"
WSGIPythonHome "c:/...../local/programs/python/python36"

Copy the output and paste it at the end of "Apache24\conf\httpd.conf" file

3-Place CVE-Monitor app in apache directory

Place CVE-Monitor app in "path\Apache24\htdocs"

4-Edit the path in app.wsgi File

Go to "path\Apache24\htdocs\CVE-Monitor\app.wsgi"

The file should look something like this:

#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"htdocs/CVE-Monitor/")
from app import app as application

5- Configure a new Virtual Host

Go to "path\Apache24\conf\extra\httpd-vhosts.conf" and add the following:

<VirtualHost *:80>
 
        ServerName (domain.com)
        WSGIScriptAlias /cve "htdocs/CVE-Monitor/app.wsgi"
        DocumentRoot "htdocs/CVE-Monitor/"
        <Directory "htdocs/CVE-Monitor">
                Require all granted
        </Directory>
        ErrorLog "logs/error.log"
        CustomLog "logs/access.log" common

</VirtualHost>

* Note: If you're not using port 80 make sure to add the port number to "path\Apache24\conf\httpd.conf"

Listen <port No>

6- Include the virtual-hosts file

Go to "path\Apache24\conf\httpd.conf", uncomment the "Include" line

 # Virtual hosts
 Include conf/extra/httpd-vhosts.conf

7- Restart Apache

$httpd.exe -k restart

Note: The implemented SSE (server sent events) technology is not supported by Microsoft's Internet Explorer or Edge.