Skip to content

Instantly share code, notes, and snippets.

@ezyatev
Last active March 13, 2019 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezyatev/4f8be8618e610d0413883d33278bc6fa to your computer and use it in GitHub Desktop.
Save ezyatev/4f8be8618e610d0413883d33278bc6fa to your computer and use it in GitHub Desktop.
How to Deploy Speed Friending and Dating Matcher on CentOS 7.6 with Apache server

How to Deploy Speed Friending and Dating Matcher on CentOS 7.6 with Apache server

Specially for Mikula :)

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 (but not in the case of Contabo VPS):

  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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment