Tutorials  /  Python

Install Python 3.7 on Arch Linux with Apache or Nginx

Ccentron Redaktion · June 2025 ·4 min read ·Python, Tutorial

System Requirements

  • A server with the latest Arch Linux release (refer to the official setup guide).
  • A functional web server — either Apache or Nginx installed and configured.
  • Root-level access (sudo):

    Commands that require root privileges are marked with a #. The best practice is to use sudo with each root-level command as a non-root user.

  • An installed and familiar text editor such as vi, vim, nano, emacs, or any equivalent tool.
VM

Matching infrastructure at centron

Scripts and services eventually need an environment that keeps running: ccloud³ VMs from €3.12 per month, billed by the hour. Rent a cloud server →

Python 3.7 Installation on Web Server

Using Apache

It is not feasible to run both Python 2.x and 3.x Apache modules simultaneously on Arch Linux. However, this is generally not an issue.

To activate Python 3.x support:

Console
# pacman -S mod_wsgi

Next, modify the Apache configuration file at /etc/httpd/conf/httpd.conf. Scroll to the end of the LoadModule entries and append:

Code
LoadModule wsgi_module modules/mod_wsgi.so

Using Nginx

To enable Python 3.x with Nginx, execute:

Console
# pacman -S uwsgi-plugin-python

Validating Python Setup

In your desired directory, create a test.py file containing this script:

Python
#-*- coding: utf-8 -*-
def wsgi_app(environment, start_response):
    import sys
    output = sys.version.encode('utf8')
    status = '200 OK'
    headers = [('Content-type', 'text/plain'),
               ('Content-Length', str(len(output)))]
    start_response(status, headers)
    yield output

application = wsgi_app

Apache Configuration

To integrate the test application with Apache, append the following to /etc/httpd/conf/httpd.conf or insert it inside the appropriate <VirtualHost> block if using multiple hosts:

Code
WSGIScriptAlias /wsgi_app /srv/http/test.py

Restart Apache for changes to apply:

Console
# systemctl restart httpd

Now, open a web browser and navigate to http://YOUR-SERVER-WEB-ADDRESS-OR-IP/wsgi_app. A test page displaying your Python and GCC versions should appear.

Finally, clean up by removing the test.py file and deleting the related WSGIScriptAlias directive from the Apache configuration.

Then restart Apache again:

Console
# systemctl restart httpd

Configure Python 3.7 with uWSGI and Nginx on Arch Linux

Create the uWSGI Configuration

Begin by creating a new file at /etc/uwsgi/wsgi_app.ini and populate it with the configuration below:

Code
[uwsgi]
socket = /run/uwsgi/wsgi_app.sock
uid = http
gid = http
plugins = python
chdir = /usr/share/nginx/html/
wsgi-file=test.py
callable = application

To begin serving wsgi_app with uWSGI, execute:

Console
# systemctl start uwsgi@wsgi_app

Update Nginx Configuration

Edit /etc/nginx/nginx.conf. In every server block where testing is desired, add the following configuration. If you are using separate virtual host files, apply the change to each one individually:

Code
location ~ \wsgi_app {
    root /usr/share/nginx/html/;
    include uwsgi_params;
    uwsgi_pass unix:/run/uwsgi/wsgi_app.sock;
}

Restart Nginx to apply the changes:

Console
# systemctl restart nginx

Open your browser and go to http://YOUR-SERVER-WEB-ADDRESS-OR-IP/wsgi_app. You should see a test page displaying the current Python and GCC versions.

Cleanup

After confirming it works, remove the test.py file and the location block for wsgi_app from /etc/nginx/nginx.conf.

Restart Nginx once again:

Console
# systemctl restart nginx

Then, stop the uWSGI service for wsgi_app:

Console
# systemctl stop uwsgi@wsgi_app

Lastly, delete both the /etc/uwsgi/wsgi_app.ini and test.py files to complete the cleanup.

Conclusion

By following these steps, you’ve successfully configured Python 3.7 with uWSGI and Nginx on an Arch Linux server. This setup enables robust WSGI application serving while maintaining flexibility and performance. Don’t forget to clean up temporary test files and configurations to keep your server tidy and secure.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Python
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren