How To Install Puthon 3.7 on Arch Linux Web Server

This guide will help you install Python on Arch Linux. For this you need: Hostry vps Server running on Arch Linux, running Apache or Nginx web server, access to sudo and also installed text editor.

Install Python 3.7 on your web server

On Nginx

To use Python 3.x (any version), you must enter the following:

# pacman -S uwsgi-plugin-python

Test python

In the appropriate test.py directory, the contents are listed below:

#-*- 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

On Apache

Add /etc/httpd/conf/httpd.conf to the end or edit the corresponding configuration file and then add to the corresponding <VirtualHost> block:

WSGIScriptAlias /wsgi_app /srv/http/test.py

Restart Apache

# systemctl restart httpd

Follow the link in the browser http:// YOUR-SERVER-WEB-ADDRESS-OR-IP/wsgi_app and you can see a text page with all versions of Python and GCC.

Delete the test.py test file you just created and WSGIScriptAlias ​​in your Apache configuration.

On Nginx

Create the file /etc/uwsgi/wsgi_app.ini with the following contents:

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

Start service uWSGI wsqi_app:

# systemctl start uwsgi@wsgi_app

You need to give Nginx permission to use uWSGI by editing /etc/nginx/nginx.conf, and for each server block that you want to test, add the following. Alternatively, if you use virtual hosts, edit the configuration file for each host:

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

Restart Nginx:

# systemctl restart nginx

Visit your web browser, http://YOUR-SERVER-WEB-ADDRESS-OR-IP/wsgi_app and you will see a test page with versions of Python and GCC.

Delete the test.py file you just created and the location block you just added /etc/nginx/nginx.conf to wsgi_app.

Restart Nginx

# systemctl restart nginx

Stop serving uWSGI wsgi_app:

# systemctl stop uwsgi@wsgi_app

In the final episode, you need to delete /etc/uwsgi/wsgi_app.ini, test files, who you created earlier.

Was this article helpful?

Related Articles

Leave A Comment?