在一台新的服务器上x需要先安装python3 ,git , 等
安装python3 之前博客写过
https://docs.python.org/3/library/venv.html
首先创建一个空目录
python3 -m venv DIR在linux 启动虚拟环境是
source bin/activatepip3安装各种Python包
pip3 install -r requirements.txt
note: requirements.txt 这个文件名不一定非是这个,只要内容符合要求就行
关于生成这个文件 的命令是
pip freeze > FILENAME.txt
退出虚拟环境
deactivatelinux安装mysql
参考
http://www.runoob.com/mysql/mysql-install.html
yum install -y mysql
yum install -y mysql-server
yum install -y devel
启动
service mysqld start部署nginx 和uwsgi安装uwsgipip3 install uwsgi安装nginxyum install nginx 在执行这个命令后发现错误信息, no valid packages nginx red hat/centos 发行版下,看过望山各种答案还是找不到故记录一下求助于nginx 官网https://nginx.org/en/linux_packages.html#stable按照官网的命令,先创建一个文件 vim /etc/yum.repos.d/nginx.repouwsgi 链接 https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html
To set up the yum repository for RHEL/CentOS, create the file named /etc/yum.repos.d/nginx.repo with the following contents:在这个文件下写入 [nginx] name=nginx repo baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/ gpgcheck=0 enabled=1标红部分要根据你的操作系统版本来改Replace “OS” with “rhel” or “centos”, depending on the distribution used, and “OSRELEASE” with “6” or “7”, for 6.x or 7.x versions, respectively.翻译是:将用rhel 或者centos 来替代'OS' ,这个取决于你的发行版,用6或者7来替代 “OSRELEASE”这个取决于是6.x 还是7.x 改完之后保存退出再执行命令 yum install nginx
就大功告成了
Currently, nginx packages are available for the following distributions and versions:
关于版本,可通过uname命令来看
如
[root@host yuyang]# uname -r 4.13.7-1.el6.elrepo.i686 [root@host yuyang]# uname -v #1 SMP Sat Oct 14 11:42:10 EDT 2017 [root@host yuyang]# uname -i i386
RHEL/CentOS:
VersionSupported Platforms6.xx86_64, i3867.4+x86_64, ppc64leDebian:
VersionCodenameSupported Platforms8.xjessiex86_64, i3869.xstretchx86_64, i386Ubuntu:
VersionCodenameSupported Platforms14.04trustyx86_64, i386, aarch64/arm6416.04xenialx86_64, i386, ppc64el, aarch64/arm6417.04zestyx86_64, i386SLES:
VersionSupported Platforms12x86_64 关于部署django几点注意点: settings.py ALLOWED_HOST 需要设置 * 或者对应ip DEBUG 改成False settings 设置STATIC_ROOT 在启动uwsgi前,收集静态文件,命令是python manage.py collectstatic ,这个命令回见django里面的静态文件全收集到STATIC_ROOT 所指定的目录下之前一晚上failed to open python.py 这个bug 是因为 --chdir --wsgi-file 的文件路径写的不对,写重复了。启动有mysql 的django 项目,报 nomudule package MySQLdb 需要 pip3 install mysqlclient在deug设置为false 后静态文件是从STATIC_ROOT 下面找的 uwsgi --http :9003 --chdir /root/s5/deploy1 --wsgi-file deploy1/wsgi.py --master --processes 1 --threads 2 --static-map /static=/root/s5/xxxxxx
也可以写成配置文件
转载于:https://www.cnblogs.com/yuyang26/p/7993934.html
