How to Deploy Matching Software for Speed Friending and Dating Events on CentOS 7.6

Recently Mikula Byutil asking me to set up a CentOS web server with Apache to share Matching Software for Speed Friending and Dating Events. I want to share step-by-step guide — willl be useful for dummies.

In this tutorial the domain name matcher.ml used for example. This is a free domain name from freenom.com.

You can use another domain name, of course.

Tested with clean installation of CentOS.

  1. Check CentOS version:

    $ cat /etc/centos-release
    

    CentOS Linux release 7.6.1810 (Core)

  2. Update system packages:

    # yum update -y
    
  3. Install dependencies:

    # yum install nano httpd python36 git -y
    
  4. Enable HTTP service:

    # systemctl enable httpd.service
    
  5. Create user 'matcher':

    # adduser matcher
    
  6. Switch to user 'matcher':

    # su matcher
    $ cd
    
  7. Create Python 3 virtual environment for the app: $ python36 -mvenv venv
  8. Activate virtual environment: $ source venv/bin/activate
  9. Install app from git repo branch:

    $ pip install git+https://github.com/machinekoder/speed-friending-and-dating-matcher.git@master
    

    A reason to use git repo: speed-friending-and-dating-matcher not available from PyPi.

  10. Install application server:

    $ pip install gunicorn
    
  11. Create WSGI file:

    $ nano wsgi.py
    

    with content:

    from speed_friending_matcher import server
    from speed_friending_matcher.server import app as application
    
    server.configure(
      input_plugin='csv:{}',
      output_plugin='todo:{}:{}',
      matchmaker='simple'
    )
    
  12. Close user session:

    $ exit
    
  13. Create and open a Systemd service file for Gunicorn

    # nano /etc/systemd/system/gunicorn.service
    

    with content:

    [Unit]
    Description=gunicorn daemon
    After=network.target
    
    [Service]
    User=matcher
    Group=matcher
    WorkingDirectory=/home/matcher
    ExecStart=/home/matcher/venv/bin/gunicorn --workers 2 --bind 127.0.0.1:8000 wsgi:application
    
    [Install]
    WantedBy=multi-user.target
    
  14. We can now start the Gunicorn service we created and enable it so that it starts at boot:

    # systemctl start gunicorn
    # systemctl enable gunicorn
    
  15. Create config file for Apache:

    # nano /etc/httpd/conf.d/matcher.conf 
    

    with content:

    <VirtualHost *:80>
        DocumentRoot "/home/matcher"
        ServerName matcher.ml
    
        ProxyPass / http://localhost:8000/
    
        <Directory /home/matcher/>
        Require all granted
        </Directory>
    </VirtualHost>
    
  16. Restart Apache:

    # systemctl restart httpd
    
  17. Go to http://matcher.ml and enjoy!

Sometimes also requred...

  1. Add HTTP service or port 80 with the following command:

    # firewall-cmd --add-service=http --permanent
    
  2. Once you’re done, restart firewalld with the following command:

    # firewall-cmd --reload
    

Have a good day!


Specially for Mikula Byutil :)