Install Python3 and Django on Amazon Linux (EC2) and run your web server

Leave it instead of a memo. It is assumed that the instance is standing upright.

Install Python3

The original version of Python that comes with Amazon Linux is 2.7.12. That's why this time I will install Python 3 series. Fortunately, YUM's amzn-main repository has a collection of Python3.

# yum list | grep python35
python35.x86_64                        3.5.1-13.7.amzn1               @amzn-main
python35-devel.x86_64                  3.5.1-13.7.amzn1               @amzn-main
python35-libs.x86_64                   3.5.1-13.7.amzn1               @amzn-main
python35-pip.noarch                    6.1.1-1.23.amzn1               @amzn-main
python35-setuptools.noarch             12.2-1.32.amzn1                @amzn-main
python35-tools.x86_64                  3.5.1-13.7.amzn1               @amzn-main
python35-virtualenv.noarch             12.0.7-1.13.amzn1              @amzn-main
mod24_wsgi-python35.x86_64             3.5-1.23.amzn1                 amzn-main
python35-libs.i686                     3.5.1-13.7.amzn1               amzn-main
python35-test.x86_64                   3.5.1-13.7.amzn1               amzn-main

Select a package from this. In my case, I did the following.

# yum install python35-devel python35-libs python35-setuptools

** I didn't install pip here because I will install it later using easy_install. ** ** After the installation is complete, you can use Python 3.5 with the command python35.

# python35
Python 3.5.1 (default, Sep 13 2016, 18:48:37)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Next, install pip for Python3 series.

# /usr/bin/easy_install-3.5 pip

You can now use pip for python3 with the command pip3.

Django installation

For the time being, upgrade pip.

# pip3 install --upgrade pip

And install Django

# pip3 install django

Make sure you have installed it successfully.

# python35
Python 3.5.1 (default, Sep 13 2016, 18:48:37)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.10.2
>>>

If it looks like the above, you have successfully installed it.

Run web server

** If you check with a web browser, please allow the request to number 80 in the security group. ** **

For now, create a directory for Django.

# mkdir django
# cd django

Next, create a project.

# django-admin startproject pro1 #pro1 is the project name
# cd pro1 #Move to the project directory
# python35 manage.py migrate
# python35 manage.py createsuperuser #Create superuser

Run the web server.

# python35 manage.py runserver 0:80 #IP address:Specified by port. If the IP address is 0, it also works for the outside

Now, when you access the server from your web browser, you should see the page below.

スクリーンショット 2016-10-11 18.51.21.png

Thank you for your support.

Recommended Posts

Install Python3 and Django on Amazon Linux (EC2) and run your web server
Install Python 3.8, Pip 3.8 on EC2 (Amazon Linux 2)
Compile and install MySQL-python for python2.7 on amazon linux
Install django on python + anaconda and start the server
Install Python Pillow on Amazon Linux
Install pyenv on EC2 (Amazon Linux)
[Note] Run Django on Amazon Linux 2
I'll install Ruby on EC2 (Amazon Linux2) 2020
Install and Configure TigerVNC server on Linux
Dockerfile: Install Docker on your Linux server
Install and run Python3.5 + NumPy + SciPy on Windows 10
Run a batch of Python 2.7 with nohup on Amazon Linux AMI on EC2
Until you install Python with pythonbrew and run Flask on a WSGI server
Publish your Django app on Amazon Linux + Apache + mod_wsgi
[Part 2] Let's build a web server on EC2 Linux
Install Docker on Arch Linux and run it remotely
[AWS EC2] How to install Maven on Amazon Linux 2
Install Linux on your Chromebox
Install Python 3.7 and Django 3.0 (CentOS)
Python --Install MySQLDB on EC2
Install Django on your Mac
Install tomcat 5.5 on Amazon Linux.
Install strongSwan 5.9.1 on Amazon Linux 2
[AWS EC2] How to install only MySQL client on Amazon Linux 2 and connect to RDS
Install Python3 on Sakura server (FreeBSD)
Install oracle java8 on amazon linux2
Install and run dropbox on Ubuntu 20.04
Run a Linux server on GCP
[Note] Install Imagick on Amazon Linux2
Run docker-compose on Amazon Linux2 on ARM64
Introduce Python 3.5.2 environment on Amazon Linux
Run cron on Amazon Linux (set on Linux)
How to install OpenCV on Cloud9 and run it in Python
Install mecab on Sakura shared server and call it from python
Summary of installing PHP7.2 on EC2 (Amazon Linux 2) and setting php.ini
Install wsl2 and master linux on windows
Install and launch k3s on Manjaro Linux
Learn sshd_config and authorized_keys (on Amazon Linux 2)
5 reasons to install Linux on your laptop.
How to install Anisble on Amazon Linux 2
Run Keycloak on Amazon Linux 2 without Docker
Build a web server on your Chromebook
Install Python3 on mixhost server [Currently NG]
Install pyenv and Python 3.6.8 on Ubuntu 18.04 LTS
Run python wsgi server on NGINX Unit
Put Docker in Windows Home and run a simple web server with Python
[2020 version] How to install Python3 on AWS EC2
Effective and simple Web server security measures "Linux"
Run Python web apps on NGINX + NGINX Unit + Flask
Web server construction with Apache 2.4 (httpd 2.4.43) + PHP 7.4 on Linux ―― 4. Security (chown and firewalld)
Launch a web server with Python and Flask
Run pip install on MacOS Python 3.7 or later
Source compile Apache2.4 (httpd 2.4.43) + PHP7.4 on Linux and build a Web server ―― 1. Apache introduction
Install Python and libraries for Python on MacOS Catalina
Install ZIP version Python and pip on Windows 10
Source compile Apache2.4 (httpd 2.4.43) + PHP7.4 on Linux and build a Web server --2 PHP introduction
[Python3] Take a screenshot of a web page on the server and crop it further
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
Deploy a Python 3.6 / Django / Postgres web app on Azure
Install Python3 on Mac and build environment [Definitive Edition]
Take your own peak memory usage on Linux & Python