前面篇幅已经准备好了linux的环境,接下来我们将Pear Admin进行部署
创建conda虚拟环境
conda create -n pearadmin python=3.8.8 -y
[root@localhost ~]# conda create -n pearadmin python=3.8.8 -y
Channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- defaults
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /opt/miniconda/envs/pearadmin
added / updated specs:
- python=3.8.8
The following packages will be downloaded:
package | build
---------------------------|-----------------
_libgcc_mutex-0.1 | main 3 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
_openmp_mutex-5.1 | 1_gnu 21 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ca-certificates-2025.2.25 | h06a4308_0 129 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ld_impl_linux-64-2.40 | h12ee557_0 710 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libffi-3.3 | he6710b0_2 50 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libgcc-ng-11.2.0 | h1234567_1 5.3 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libgomp-11.2.0 | h1234567_1 474 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libstdcxx-ng-11.2.0 | h1234567_1 4.7 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ncurses-6.4 | h6a678d5_0 914 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
openssl-1.1.1w | h7f8727e_0 3.7 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pip-24.2 | py38h06a4308_0 2.2 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
python-3.8.8 | hdb3f193_5 50.0 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
readline-8.2 | h5eee18b_0 357 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
setuptools-75.1.0 | py38h06a4308_0 1.7 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
sqlite-3.38.2 | hc218d9a_0 1.0 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tk-8.6.11 | h1ccaba5_0 3.0 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
wheel-0.44.0 | py38h06a4308_0 108 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
xz-5.6.4 | h5eee18b_1 567 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zlib-1.2.11 | 0 109 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
------------------------------------------------------------
Total: 75.0 MB
The following NEW packages will be INSTALLED:
_libgcc_mutex anaconda/pkgs/main/linux-64::_libgcc_mutex-0.1-main
_openmp_mutex anaconda/pkgs/main/linux-64::_openmp_mutex-5.1-1_gnu
ca-certificates anaconda/pkgs/main/linux-64::ca-certificates-2025.2.25-h06a4308_0
ld_impl_linux-64 anaconda/pkgs/main/linux-64::ld_impl_linux-64-2.40-h12ee557_0
libffi anaconda/pkgs/main/linux-64::libffi-3.3-he6710b0_2
libgcc-ng anaconda/pkgs/main/linux-64::libgcc-ng-11.2.0-h1234567_1
libgomp anaconda/pkgs/main/linux-64::libgomp-11.2.0-h1234567_1
libstdcxx-ng anaconda/pkgs/main/linux-64::libstdcxx-ng-11.2.0-h1234567_1
ncurses anaconda/pkgs/main/linux-64::ncurses-6.4-h6a678d5_0
openssl anaconda/pkgs/main/linux-64::openssl-1.1.1w-h7f8727e_0
pip anaconda/pkgs/main/linux-64::pip-24.2-py38h06a4308_0
python anaconda/pkgs/main/linux-64::python-3.8.8-hdb3f193_5
readline anaconda/pkgs/main/linux-64::readline-8.2-h5eee18b_0
setuptools anaconda/pkgs/main/linux-64::setuptools-75.1.0-py38h06a4308_0
sqlite anaconda/pkgs/main/linux-64::sqlite-3.38.2-hc218d9a_0
tk anaconda/pkgs/main/linux-64::tk-8.6.11-h1ccaba5_0
wheel anaconda/pkgs/main/linux-64::wheel-0.44.0-py38h06a4308_0
xz anaconda/pkgs/main/linux-64::xz-5.6.4-h5eee18b_1
zlib anaconda/pkgs/free/linux-64::zlib-1.2.11-0
Downloading and Extracting Packages:
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate pearadmin
#
# To deactivate an active environment, use
#
# $ conda deactivate
[root@localhost ~]#
上传PearAdmin
通过winscp将pearadmin上传至/data目录
[root@localhost ~]# mkdir /data
解压上传的压缩包
cd /data
unzip pear-admin-flask-master.zip
mv pear-admin-flask-master pear-admin
安装pearadmin所需要的软件包
激活pearadmin的虚拟环境
conda activate pearadmin
配置pip源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
安装软件包
cd /data/pear-admin
pip install -r requirements.txt
(pearadmin) [root@localhost pear-admin]# pip install -r requirements.txt
Collecting alembic==1.11.1 (from -r requirements.txt (line 1))
Downloading alembic-1.11.1-py3-none-any.whl.metadata (7.2 kB)
Collecting APScheduler==3.10.1 (from -r requirements.txt (line 2))
Downloading APScheduler-3.10.1-py3-none-any.whl.metadata (5.7 kB)
Collecting blinker==1.6.2 (from -r requirements.txt (line 3))
Downloading blinker-1.6.2-py3-none-any.whl.metadata (2.0 kB)
Collecting cffi==1.15.1 (from -r requirements.txt (line 4))
Downloading cffi-1.15.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.1 kB)
Collecting click==8.1.6 (from -r requirements.txt (line 5))
Downloading click-8.1.6-py3-none-any.whl.metadata (3.0 kB)
Collecting colorama==0.4.6 (from -r requirements.txt (line 6))
Downloading colorama-0.4.6-py2.py3-none-any.whl.metadata (17 kB)
Collecting cryptography==41.0.2 (from -r requirements.txt (line 7))
Downloading cryptography-41.0.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.2 kB)
Collecting decorator==5.1.1 (from -r requirements.txt (line 8))
Downloading decorator-5.1.1-py3-none-any.whl.metadata (4.0 kB)
Collecting Flask==2.3.2 (from -r requirements.txt (line 9))
Downloading Flask-2.3.2-py3-none-any.whl.metadata (3.7 kB)
Collecting Flask-APScheduler==1.12.4 (from -r requirements.txt (line 10))
Downloading Flask-APScheduler-1.12.4.tar.gz (12 kB)
Preparing metadata (setup.py) ... done
Collecting Flask-Login==0.6.2 (from -r requirements.txt (line 11))
Downloading Flask_Login-0.6.2-py3-none-any.whl.metadata (5.8 kB)
Collecting Flask-Mail==0.9.1 (from -r requirements.txt (line 12))
Downloading Flask-Mail-0.9.1.tar.gz (45 kB)
Preparing metadata (setup.py) ... done
Collecting flask-marshmallow==0.15.0 (from -r requirements.txt (line 13))
Downloading flask_marshmallow-0.15.0-py2.py3-none-any.whl.metadata (5.7 kB)
Collecting Flask-Migrate==4.0.4 (from -r requirements.txt (line 14))
Downloading Flask_Migrate-4.0.4-py3-none-any.whl.metadata (3.1 kB)
Collecting Flask-Reuploaded==1.3.0 (from -r requirements.txt (line 15))
Downloading Flask_Reuploaded-1.3.0-py3-none-any.whl.metadata (11 kB)
Collecting Flask-SQLAlchemy==3.1.1 (from -r requirements.txt (line 16))
Downloading flask_sqlalchemy-3.1.1-py3-none-any.whl.metadata (3.4 kB)
Collecting greenlet==3.0.3 (from -r requirements.txt (line 17))
Downloading greenlet-3.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.8 kB)
Collecting importlib-metadata==6.8.0 (from -r requirements.txt (line 18))
Downloading importlib_metadata-6.8.0-py3-none-any.whl.metadata (5.1 kB)
Collecting itsdangerous==2.1.2 (from -r requirements.txt (line 19))
Downloading itsdangerous-2.1.2-py3-none-any.whl.metadata (2.9 kB)
Collecting Jinja2==3.1.2 (from -r requirements.txt (line 20))
Downloading Jinja2-3.1.2-py3-none-any.whl.metadata (3.5 kB)
Collecting Mako==1.2.4 (from -r requirements.txt (line 21))
Downloading Mako-1.2.4-py3-none-any.whl.metadata (2.9 kB)
Collecting MarkupSafe==2.1.3 (from -r requirements.txt (line 22))
Downloading MarkupSafe-2.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.0 kB)
Collecting marshmallow==3.20.1 (from -r requirements.txt (line 23))
Downloading marshmallow-3.20.1-py3-none-any.whl.metadata (7.8 kB)
Collecting marshmallow-sqlalchemy==0.29.0 (from -r requirements.txt (line 24))
Downloading marshmallow_sqlalchemy-0.29.0-py2.py3-none-any.whl.metadata (6.8 kB)
Collecting packaging==23.1 (from -r requirements.txt (line 25))
Downloading packaging-23.1-py3-none-any.whl.metadata (3.1 kB)
Collecting Pillow==10.0.0 (from -r requirements.txt (line 26))
Downloading Pillow-10.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (9.5 kB)
Collecting psutil==5.9.5 (from -r requirements.txt (line 27))
Downloading psutil-5.9.5-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (21 kB)
Collecting pycparser==2.21 (from -r requirements.txt (line 28))
Downloading pycparser-2.21-py2.py3-none-any.whl.metadata (1.1 kB)
Collecting PyMySQL==1.1.0 (from -r requirements.txt (line 29))
Downloading PyMySQL-1.1.0-py3-none-any.whl.metadata (4.4 kB)
Collecting python-dateutil==2.8.2 (from -r requirements.txt (line 30))
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl.metadata (8.2 kB)
Collecting pytz==2023.3 (from -r requirements.txt (line 31))
Downloading pytz-2023.3-py2.py3-none-any.whl.metadata (22 kB)
Collecting six==1.16.0 (from -r requirements.txt (line 32))
Downloading six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Collecting SQLAlchemy==2.0.21 (from -r requirements.txt (line 33))
Downloading SQLAlchemy-2.0.21-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (9.4 kB)
Collecting style==1.1.0 (from -r requirements.txt (line 34))
Downloading style-1.1.0-py2.py3-none-any.whl.metadata (2.8 kB)
Collecting typing_extensions==4.7.1 (from -r requirements.txt (line 35))
Downloading typing_extensions-4.7.1-py3-none-any.whl.metadata (3.1 kB)
Collecting tzdata==2023.3 (from -r requirements.txt (line 36))
Downloading tzdata-2023.3-py2.py3-none-any.whl.metadata (1.4 kB)
Collecting tzlocal==5.0.1 (from -r requirements.txt (line 37))
Downloading tzlocal-5.0.1-py3-none-any.whl.metadata (16 kB)
Collecting update==0.0.1 (from -r requirements.txt (line 38))
Downloading update-0.0.1-py2.py3-none-any.whl.metadata (696 bytes)
Collecting validators==0.20.0 (from -r requirements.txt (line 39))
Downloading validators-0.20.0.tar.gz (30 kB)
Preparing metadata (setup.py) ... done
Collecting Werkzeug==2.3.6 (from -r requirements.txt (line 40))
Downloading Werkzeug-2.3.6-py3-none-any.whl.metadata (4.1 kB)
Collecting zipp==3.16.2 (from -r requirements.txt (line 41))
Downloading zipp-3.16.2-py3-none-any.whl.metadata (3.7 kB)
Collecting flask_wtf==1.2.1 (from -r requirements.txt (line 42))
Downloading flask_wtf-1.2.1-py3-none-any.whl.metadata (3.4 kB)
Collecting wtforms~=3.1.1 (from -r requirements.txt (line 43))
Downloading wtforms-3.1.2-py3-none-any.whl.metadata (5.3 kB)
Collecting Flask-Session==0.5.0 (from -r requirements.txt (line 44))
Downloading flask_session-0.5.0-py3-none-any.whl.metadata (1.4 kB)
Collecting importlib-resources (from alembic==1.11.1->-r requirements.txt (line 1))
Downloading importlib_resources-6.4.5-py3-none-any.whl.metadata (4.0 kB)
Requirement already satisfied: setuptools>=0.7 in /opt/miniconda/envs/pearadmin/lib/python3.8/site-packages (from APScheduler==3.10.1->-r requirements.txt (line 2)) (75.1.0)
Collecting backports.zoneinfo (from tzlocal==5.0.1->-r requirements.txt (line 37))
Downloading backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl.metadata (4.7 kB)
Collecting cachelib (from Flask-Session==0.5.0->-r requirements.txt (line 44))
Downloading cachelib-0.13.0-py3-none-any.whl.metadata (2.0 kB)
Downloading alembic-1.11.1-py3-none-any.whl (224 kB)
Downloading APScheduler-3.10.1-py3-none-any.whl (59 kB)
Downloading blinker-1.6.2-py3-none-any.whl (13 kB)
Downloading cffi-1.15.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (442 kB)
Downloading click-8.1.6-py3-none-any.whl (97 kB)
Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Downloading cryptography-41.0.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 16.4 kB/s eta 0:00:00
Downloading decorator-5.1.1-py3-none-any.whl (9.1 kB)
Downloading Flask-2.3.2-py3-none-any.whl (96 kB)
Downloading Flask_Login-0.6.2-py3-none-any.whl (17 kB)
Downloading flask_marshmallow-0.15.0-py2.py3-none-any.whl (9.7 kB)
Downloading Flask_Migrate-4.0.4-py3-none-any.whl (20 kB)
Downloading Flask_Reuploaded-1.3.0-py3-none-any.whl (14 kB)
Downloading flask_sqlalchemy-3.1.1-py3-none-any.whl (25 kB)
Downloading greenlet-3.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (667 kB)
━━━━━━━━━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━ 262.1/667.4 kB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 667.4/667.4 kB 19.1 kB/s eta 0:00:00
Downloading importlib_metadata-6.8.0-py3-none-any.whl (22 kB)
Downloading itsdangerous-2.1.2-py3-none-any.whl (15 kB)
Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
Downloading Mako-1.2.4-py3-none-any.whl (78 kB)
Downloading MarkupSafe-2.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Downloading marshmallow-3.20.1-py3-none-any.whl (49 kB)
Downloading marshmallow_sqlalchemy-0.29.0-py2.py3-none-any.whl (16 kB)
Downloading packaging-23.1-py3-none-any.whl (48 kB)
Downloading Pillow-10.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 16.2 kB/s eta 0:00:00
Downloading psutil-5.9.5-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (282 kB)
Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
Downloading PyMySQL-1.1.0-py3-none-any.whl (44 kB)
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Downloading pytz-2023.3-py2.py3-none-any.whl (502 kB)
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Downloading SQLAlchemy-2.0.21-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB)
━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.3/3.0 MB ? eta -:--:--
━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.3/3.0 MB ? eta -:--:--
━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.3/3.0 MB ? eta -:--:--
━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.3/3.0 MB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.0/3.0 MB 13.3 kB/s eta 0:00:00
Downloading style-1.1.0-py2.py3-none-any.whl (6.4 kB)
Downloading typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Downloading tzdata-2023.3-py2.py3-none-any.whl (341 kB)
Downloading tzlocal-5.0.1-py3-none-any.whl (20 kB)
Downloading update-0.0.1-py2.py3-none-any.whl (2.9 kB)
Downloading Werkzeug-2.3.6-py3-none-any.whl (242 kB)
Downloading zipp-3.16.2-py3-none-any.whl (7.2 kB)
Downloading flask_wtf-1.2.1-py3-none-any.whl (12 kB)
Downloading flask_session-0.5.0-py3-none-any.whl (7.2 kB)
Downloading wtforms-3.1.2-py3-none-any.whl (145 kB)
Downloading backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl (74 kB)
Downloading cachelib-0.13.0-py3-none-any.whl (20 kB)
Downloading importlib_resources-6.4.5-py3-none-any.whl (36 kB)
Building wheels for collected packages: Flask-APScheduler, Flask-Mail, validators
Building wheel for Flask-APScheduler (setup.py) ... done
Created wheel for Flask-APScheduler: filename=Flask_APScheduler-1.12.4-py3-none-any.whl size=15717 sha256=a6acd3ed6859dcfa540351c37f75bedca1c6df66ef3a10545707f22c48ad9c61
Stored in directory: /root/.cache/pip/wheels/83/89/54/0f51ff73f88b28b6d0af3dad42efed206c732fd5edec3fcb08
Building wheel for Flask-Mail (setup.py) ... done
Created wheel for Flask-Mail: filename=Flask_Mail-0.9.1-py3-none-any.whl size=7579 sha256=0633b2fa08acee1402c0eb5d3b9667bc8c3b5dc2e2f01c69283d70c878019a72
Stored in directory: /root/.cache/pip/wheels/98/bc/8c/34c329e4d7efeaf7b9886db0c76d0b23170e54de443f688e3c
Building wheel for validators (setup.py) ... done
Created wheel for validators: filename=validators-0.20.0-py3-none-any.whl size=19572 sha256=a22cc96e8c04880c98b63bfc20488a947276b998dcd68ad845b4ed61e0bebfd6
Stored in directory: /root/.cache/pip/wheels/19/09/72/3eb74d236bb48bd0f3c6c3c83e4e0c5bbfcbcad7c6c3539db8
Successfully built Flask-APScheduler Flask-Mail validators
Installing collected packages: style, pytz, zipp, update, tzdata, typing_extensions, six, PyMySQL, pycparser, psutil, Pillow, packaging, MarkupSafe, itsdangerous, greenlet, decorator, colorama, click, cachelib, blinker, backports.zoneinfo, wtforms, Werkzeug, validators, tzlocal, SQLAlchemy, python-dateutil, marshmallow, Mako, Jinja2, importlib-resources, importlib-metadata, cffi, marshmallow-sqlalchemy, Flask, cryptography, APScheduler, alembic, flask_wtf, Flask-SQLAlchemy, Flask-Session, Flask-Reuploaded, flask-marshmallow, Flask-Mail, Flask-Login, Flask-APScheduler, Flask-Migrate
Successfully installed APScheduler-3.10.1 Flask-2.3.2 Flask-APScheduler-1.12.4 Flask-Login-0.6.2 Flask-Mail-0.9.1 Flask-Migrate-4.0.4 Flask-Reuploaded-1.3.0 Flask-SQLAlchemy-3.1.1 Flask-Session-0.5.0 Jinja2-3.1.2 Mako-1.2.4 MarkupSafe-2.1.3 Pillow-10.0.0 PyMySQL-1.1.0 SQLAlchemy-2.0.21 Werkzeug-2.3.6 alembic-1.11.1 backports.zoneinfo-0.2.1 blinker-1.6.2 cachelib-0.13.0 cffi-1.15.1 click-8.1.6 colorama-0.4.6 cryptography-41.0.2 decorator-5.1.1 flask-marshmallow-0.15.0 flask_wtf-1.2.1 greenlet-3.0.3 importlib-metadata-6.8.0 importlib-resources-6.4.5 itsdangerous-2.1.2 marshmallow-3.20.1 marshmallow-sqlalchemy-0.29.0 packaging-23.1 psutil-5.9.5 pycparser-2.21 python-dateutil-2.8.2 pytz-2023.3 six-1.16.0 style-1.1.0 typing_extensions-4.7.1 tzdata-2023.3 tzlocal-5.0.1 update-0.0.1 validators-0.20.0 wtforms-3.1.2 zipp-3.16.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
(pearadmin) [root@localhost pear-admin]#
修改app.py文件
(pearadmin) [root@localhost pear-admin]# cat app.py
from applications import create_app
app = create_app()
if __name__ == '__main__':
app.run(host='0.0.0.0', port=80, debug=True)
(pearadmin) [root@localhost pear-admin]#
防火墙配置
centos7默认防火墙并未放开80端口访问,对防火墙进行如下设置。
[root@localhost ~]# firewall-cmd --zone=public --add-service=http --permanent
[root@localhost ~]# firewall-cmd --reload
运行pearadmin
(pearadmin) [root@localhost pear-admin]# python app.py
* Serving Flask app '/data/pear-admin'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:80
* Running on http://192.168.11.200:80
Press CTRL+C to quit
* Restarting with stat
* Debugger is active!
* Debugger PIN: 791-988-710
测试
C:\Users\admin>tcping 192.168.11.200 80
Probing 192.168.11.200:80/tcp - Port is open - time=2.577ms
Probing 192.168.11.200:80/tcp - Port is open - time=1.836ms
Probing 192.168.11.200:80/tcp - Port is open - time=2.306ms
Probing 192.168.11.200:80/tcp - Port is open - time=1.700ms
Ping statistics for 192.168.11.200:80
4 probes sent.
4 successful, 0 failed. (0.00% fail)
Approximate trip times in milli-seconds:
Minimum = 1.700ms, Maximum = 2.577ms, Average = 2.105ms
设置开机自动运行pearadmin
[root@localhost ~]#vi /etc/systemd/system/pearadmin.service
[Unit]
Description=pearadmin
After=network.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/data/pear-admin
Environment="PATH=/opt/miniconda/envs/pearadmin/bin:/opt/miniconda/condabin:/usr/bin:/bin"
Environment="CONDA_PREFIX=/opt/miniconda/envs/pearadmin"
Environment="CONDA_DEFAULT_ENV=pearadmin"
ExecStart=/opt/miniconda/envs/pearadmin/bin/python /data/pear-admin/app.py
Restart=always
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
[root@localhost ~]#systemctl daemon-reload
[root@localhost ~]#systemctl enable pearadmin.service
[root@localhost ~]#systemctl start pearadmin.service
重启centos7系统,验证80端口正常启动。
Last login: Wed Jun 25 23:17:31 2025 from 192.168.11.1
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# netstat -anpt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1131/python
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1130/sshd
tcp 0 0 192.168.11.200:22 192.168.11.1:50864 ESTABLISHED 1577/sshd: root@pts
tcp 0 96 192.168.11.200:22 192.168.11.1:50868 ESTABLISHED 1602/sshd: root@not
tcp6 0 0 :::22 :::* LISTEN 1130/sshd
[root@localhost ~]#