Appearance
Horilla Deployment using a Single Service File on Linux
Step 1: Set Up the Horilla Application
Pull the Horilla Source Code
Clone or pull the Horilla source code to/opt/Horilla_Main:bashsudo git pull https://github.com/horilla-opensource/horilla.git masterSet Directory Ownership
Change the ownership of the/opt/Horilla_Maindirectory toec2-user:bashsudo chown -R ec2-user:ec2-user /opt/Horilla_MainCreate a Virtual Environment
Navigate to the project directory and create a virtual environment for Horilla:bashcd /opt/Horilla_Main python3 -m venv horillavenvActivate the Virtual Environment and Install Dependencies
Activate the virtual environment and install the necessary dependencies fromrequirements.txt:bashsource horillavenv/bin/activate pip install -r requirements.txt
After completing these steps, continue with setting up the systemd service.
Step 2: Create a Service File for Horilla
Create the Service File
Create a systemd service file to manage the Horilla application:bashsudo nano /etc/systemd/system/horilla.serviceAdd Configuration
Add the following configuration to the service file, specifying the port (default here is8000):ini[Unit] Description=Horilla Development Server After=network.target [Service] User=ec2-user Group=ec2-user WorkingDirectory=/opt/Horilla_Main Environment="DJANGO_SETTINGS_MODULE=horilla.settings" ExecStart=/opt/Horilla_Main/horillavenv/bin/python3 manage.py runserver 0.0.0.0:8000 Restart=always [Install] WantedBy=multi-user.target
Step 3: Reload Systemd and Start the Horilla Service
Reload systemd to recognize the new service file, enable the service to start on boot, and start the Horilla service:
bash
sudo systemctl daemon-reload
sudo systemctl enable horilla.service
sudo systemctl start horilla.serviceTo check if Horilla is running correctly:
bash
sudo systemctl status horilla.serviceStep 4: Activate the Virtual Environment and Collect Static Files
If Horilla is running successfully, activate the virtual environment and collect static files.
bash
cd /opt/Horilla_Main
. horillavenv/bin/activate
python3 manage.py collectstaticStep 5: Configure for Production
Update Settings for Production
Opensettings.pyand setDEBUGtoFalse:bashsudo nano horilla/settings.pyInside
settings.py:pythonDEBUG = FalseSet ALLOWED_HOSTS
Update theALLOWED_HOSTSlist insettings.pywith your domain or IP address:pythonALLOWED_HOSTS = ['your-domain.com', 'your-ip-address']
Step 6: Configure Media File Serving
If media files are not loading, add a route in urls.py to serve them.
Edit URLs for Media Files
Openurls.py:bashsudo nano horilla/urls.pyAdd Media Route
Import theservefunction and configure the URL pattern for media files:pythonfrom django.conf import settings from django.views.static import serve urlpatterns = [ # Other paths ] if not settings.DEBUG: urlpatterns += [ path('media/<path:path>', serve, {'document_root': settings.MEDIA_ROOT}), ]
Step 7: Restart the Horilla Service
After making all changes, restart the Horilla service to apply updates:
bash
sudo systemctl restart horilla.serviceSummary
This guide should set up Horilla as a systemd service with static and media file serving in a production-like environment. You should now have Horilla running on your specified port, ready to handle requests.

