Setting Up Python 3.7.2 and Related Services on CentOS 7

Install System Dependencies

Update the system and install required development libraries and tools:

yum -y update
yum -y install gcc openssl-devel zlib-devel readline-devel libffi-devel 
            bzip2-devel mysql-devel python-devel java wget 
            git redis nginx supervisor

Enable services to start automatically after a reboot:

systemctl enable redis nginx supervisord

Build and Install Python 3.7.2

Download the source package, extract it, and navigate into the directory:

wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
tar -xvf Python-3.7.2.tar.xz
cd Python-3.7.2

Configure the build with optimization enabled (this slows down compilation but improves runtime performance) and install:

./configure --prefix=/usr/local/py37 --enable-optimizations
make
make install

Create symbolic links for easy access and configure the environment variable:

ln -s /usr/local/py37/bin/python3 /usr/bin/py37
ln -s /usr/local/py37/bin/pip3 /usr/bin/pip37

# Append to /etc/profile
export PATH=/usr/local/py37/bin:$PATH

# Reload configuration
source /etc/profile

Upgrade pip and verify the installation:

pip37 install --upgrade pip

py37 --version
pip37 --version
whereis py37

Create a Python 3.7 Virtual Environment

Install pipenv and set up a project-specific environment:

pip37 install pipenv
mkdir my_project
cd my_project
pipenv --python 3.7

Edit the Pipfile to use an Aliyun mirror and define dependencies:

[[source]]
url = "https://mirrors.aliyun.com/pypi/simple/"
verify_ssl = true
name = "pypi"

[packages]
django = "*"

[dev-packages]

[requires]
python_version = "3.7"

Install packages within the virtual environment:

pipenv install django

Deploy Elasticsearch

Switch to a non-root user (Elasticsearch cannot run as root) and set up the service:

su - deployer
wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.6/elasticsearch-2.4.6.tar.gz
tar -xvf elasticsearch-2.4.6.tar.gz

Tags: CentOS 7 Python 3.7 System Administration elasticsearch Linux

Posted on Sat, 01 Aug 2026 16:54:54 +0000 by charp