文章目录 前言 一、环境安装 * 1.更新系统 2.python安装 3.安装uwsgi和django 4.安装 Nginx 二、项目配置部署 * 1.项目上传 2.配置 uWSGI 注意 前言
CentOS7,Python3.6.8,Nginx1.17.8
一、环境安装 1.更新系统 yum update -y 2.python安装提前把python包放在服务器上
解压python安装包
tar -xvf Python-3.6.8.tar.xz进入安装路径
cd Python-3.6.8指定安装位置,配置python3环境
./configure --prefix=/usr/local/python3编译&编译安装
make && make install建立python3软链接(快捷方式)
ln -s /usr/local/python3/bin/python3 /usr/bin/python3建立pip3软链接(快捷方式)–任何路径下打开命令行安装
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3升级pip
pip3 install --upgrade pip检查Python3及pip3是否正常可用:
python3 -V pip3 -V 3.安装uwsgi和django安装uwsgi(用于启动Django),及建立软链接
pip3 install uwsgi ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi查看 uwsgi 版本
uwsgi --version pip3 install django==3.1.1看项目需求,下载其他依赖
4.安装 Nginx 安装在/usr/local/目录下 解压 tar -zxvf nginx-1.17.8.tar.gz 进入安装目录 cd nginx-1.17.8 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 编译及编译安装 make && make install 查看nginx版本 /usr/local/nginx/sbin/nginx -v 进入目录编辑配置nginx.conf文件 cd /usr/local/nginx/conf/ vim nginx.conf 检查配置文件nginx.conf的正确性命令: /usr/local/nginx/sbin/nginx –t 测试:linux环境下启动nginx /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 重新加载 /usr/local/nginx/sbin/nginx -s reloadnginx.conf 配置文件
server { listen 80; server_name localhost; location / { root /usr/local/projectName/vue-element-admin-master/dist; index index.html; } location /api { include uwsgi_params; uwsgi_pass 0.0.0.0:8000; } location /admin { include uwsgi_params; uwsgi_pass 0.0.0.0:8000; } location /static { alias /usr/local/projectName/vue-element-admin-master/dist/static; } }listen 后接端口,即设定访问的端口 server_name 为访问域名 location / 后描述前端 dist 项目文件夹的存放地址, dist 即为前端项目的根目录 location /api 后为后端项目运行端口 ,注意后端项目的路由是由/api /*开头 location /static 静态资源访问路径
二、项目配置部署 1.项目上传打包vue前端,生成的dist文件放在了django项目文件夹下,DJango项目文件直接上传到服务器上。
2.配置 uWSGI新建文件 uwsgi.ini,放置于 Django 项目的根目录下
[uwsgi] socket = 0.0.0.0:8000 chdir = /usr/local/projcetName/ wsgi-file = projcetName/wsgi.py processes = 16 threads = 10 cheaper = 4 idle = 3600 stats = 0.0.0.0:9191 memory-report = true reload-mercy = 10 auto-procname = true procname-prefix-spaced = projcetName reload-on-rss = 1024 vacuum = true master = true pidfile = uwsgi.pid到uwsgi.ini 文件所在目录下,启动 uWSGI
uwsgi --ini uwsgi.ini uwsgi -d --ini uwsgi.ini查看进程,是否成功。
ps -aux | grep uwsgi 注意1.若修改了后端 Django 内容或其它内容,须重启 uWSGI 和 Nginx 服务可以用kill方法把uwsgi进程杀死
killall -9 uwsgi2.关闭防火墙3.由于部署环境下,项目setting.py中 DEBUG = False,后台样式可以收集后放在dist/static文件下
Original: https://blog.csdn.net/qq_43515713/article/details/127127621Author: 飘灬渺Title: Linux上部署Django项目(Nginx +uwsgi+ Django + Vue)
相关阅读 Title: m1 python安装scipy失败安装成功seaborn后,在import seaborn提示没有安装scipy包,于是便开始了不断安装失败的过程。
介绍下环境:mac m1芯片,miniforge,python38
尝试过的方法:
pip install scipy sudo conda pip install scipy错误提示:
…… note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. pip3 install --pre -i https://pypi.anaconda.org/scipy-wheels-nightly/simple scipy同样报错
在pycharm配置号环境后,在【Pycharm】-【Perference】-【Project】-【Python Interpreter】
点击+号,查询scipy,点击install
报错:
Make sure that you use the correct version of ‘pip’ installed for your Python interpreter
找到这篇文章,了解到可以自行从网络上下载包的方法。
(1)了解到安装的版本号
pip debug --verboseCompatible tags: 296cp38-cp38-macosx_11_0_arm64cp38-cp38-macosx_11_0_universal2cp38-cp38-macosx_10_16_universal2cp38-cp38-macosx_10_15_universal2cp38-cp38-macosx_10_14_universal2cp38-cp38-macosx_10_13_universal2cp38-cp38-macosx_10_12_universal2
(2)下载安装包
上述问题只提供了window的安装地址,未知mac安装包在下载。
在pycham的scipy的安装页面存在网址:https://www.scipy.org
进入这个页面,点击页面上方的【Download】-【PyPI page for SciPy (all)】-【Download files】可以看到所有scipy版本,单在页面中没有找到完全符合可用版本的包。
于是下载了一个近似的:
(3)安装
cd /Users/用户名/Downloads/chrome //安装包所在位置 pip install scipy-1.8.0-cp38-cp38-macosx_12_0_arm64.whl报错,提示版本不正确。
Defaulting to user installation because normal site-packages is not writeable ERROR: scipy-1.8.0-cp38-cp38-macosx_12_0_arm64.whl is not a supported wheel on this platform.于是从Compatible tags中挑选一个近似的cp38-abi3-macosx_11_0_arm64,修改下载的文件名为
scipy-1.8.0-cp38-abi3-macosx_11_0_arm64.whl
pip install scipy-1.8.0-cp38-abi3-macosx_11_0_arm64.whl终于安装成功!!
Defaulting to user installation because normal site-packages is not writeable Processing ./scipy-1.8.0-cp38-abi3-macosx_11_0_arm64.whl Requirement already satisfied: numpy=1.17.3 in /Users/buzhidao/miniforge3/envs/python38/lib/python3.8/site-packages (from scipy==1.8.0) (1.22.0) Installing collected packages: scipy Successfully installed scipy-1.8.0python新手,记录一次问题的解决,如有问题,欢迎大家指出。
Original: https://blog.csdn.net/kl_lk/article/details/123246514Author: 不知岛772Title: m1 python安装scipy失败