vim /etc/selinux/config
yum groupinstall "Development Tools"
yum update
/usr/libexec/urlgrabber-ext-down
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel
wget https://www.sqlite.org/2020/sqlite-autoconf-3330000.tar.gz
tar -zxvf sqlite-autoconf*
./configure --prefix=/usr/local
make && make install
find /usr/ -name sqlite3
export LD_LIBRARY_PATH=/usr/local/sqlite38
export LD_LIBRARY_PATH="/usr/local/lib"
wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz
./configure --prefix=/usr/local/python3 ####--enable-optimizations
make && make install
ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
ln -s /usr/local/python3/bin/python3.8 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
pip3 install --upgrade pip
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
python setup.py build
python setup.py install
wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
#wget http://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
#yum repolist enabled | grep "mysql.*-community.*"
#yum install mysql-community-server -y
yum install mariadb -y
yum install -y mariadb-server
systemctl enable mariadb.service
mysql_secure_installation rootsssgaj@2020
mysql -uroot -p
CREATE DATABASE `gaj` CHARACTER SET utf8 COLLATE utf8_general_ci;
show databases;
pip3 install PyMySQL
SET FOREIGN_KEY_CHECKS=0
SET FOREIGN_KEY_CHECKS=1
python manage.py migrate myapp --fake
import pymysql
pymysql.install_as_MySQLdb()
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y nginx
systemctl start nginx.service
systemctl enable nginx.service
systemctl start nginx //重启restart、关闭stop;默认端口为80,可以使用ss -lnt命令查看是否监听
pip3 install django==2.1.15
ln /usr/local/python3/bin/django-admin /usr/local/bin/django-admin
django-admin startproject mysitename
python manage.py makemigrations
python manage.py migrate
python manage.py collectstatic
python manage.py startapp myapp
python3 manage.py createsuperuser
查看防火墙所有开放的端口
firewall-cmd --zone=public --list-ports
firewall-cmd --zone=public --add-port=80/tcp --permanent # 开放80端口
firewall-cmd --zone=public --remove-port=5672/tcp --permanent #关闭5672端口
firewall-cmd --reload # 配置立即生效
firewall-cmd --state #查看防火墙状态
systemctl stop firewalld.service #关闭防火墙
netstat -lnpt
/etc/nginx/nginx.conf
pip3 install uwsgi
[uwsgi]
chdir=/path/to/your/project
module=mysite.wsgi:application
master=True
pidfile=/tmp/project-master.pid
vacuum=True
max-requests=5000
daemonize=/var/log/uwsgi/yourproject.log
- 例子
[uwsgi]
socket = 127.0.0.1:8000
chdir = /opt/www/myproject/
module = myproject.wsgi
enable-threads = true
master = true
processes = 4
worker = 4
threads = 4
listen = 1000
timeout = 60*30
pidfile = uwsgi.pid
vacuum = true
max-requests=5000
daemonize=/var/log/uwsgi/tian.log
py-autoreload = 1 #uwsgi自动加载代码更新
----
uwsgi --ini uwsgi.ini
http:
'''
server_tokens off;#不显示服务器版本信息
add_header X-Frame-Options DENY;#禁iframe调用页面
#uwsgi的一个参数
upstream django {
server 127.0.0.1:8000;
}
'''
server:
'''
location /static/ {
alias /home/lanlan/BinglanProject/static/;
}
location / {
uwsgi_pass django;
include /usr/local/nginx/conf/uwsgi_params;
}
'''
加一个server限制只能以域名形式访问服务器
'''
server{ #禁止ip直接访问
listen 80 default;
server_name _;
return 404;
}
'''
--------
CentOS脚本开机启动
autostart.sh
'''
#!/bin/bash
# chkconfig: 2345 10 90
#description:开机自启脚本
uwsgi --ini /opw/www/runuwsgi.sh
'''
放到这个下面
/etc/rc.d/init.d
增加可执行权限
cd /etc/rc.d/init.d
chkconfig --add autostart.sh#加入自启列
chkconfig autostart.sh on#启用自启
> Listen queue size is greater than the system max net.core.somaxconn (128)解决
'''
uwsgi的配置文件中的listen的值设置太大了,超过系统默认值128,报错
修改/proc/sys/net/ipv4/tcp_max_syn_backlog /proc/sys/net/core/somaxconn这两个文件,重启又会复原
Linux中可以工具syctl来动态调整所有的kernel参数 # sysctl -a
修改参数值的语法 # sysctl -w net.core.somaxconn=65535 改动虽然可以立即生效,但是重启机器后会恢复默认值
永久保留改动,需要用vi在/etc/sysctl.conf中增加一行
net.core.somaxconn= 65535
然后执行命令
# sysctl -p
'''
> mysql添加可访问ip
'''
mysql -u root -p
use mysql;
select host,user from user;
grant all privileges on *.* to "root"@"yourip" identified by 'passwordtoyou' with grant option;
flush privileges;
'''
Centos7+Nginx+Django+MariaDB+python3超级抽象但完整笔记
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 系统版本 centos7 python版本 使用官方python3.6.3正式版 django版本 使用本文发布时...
- 部署代码后uWSGI需要重新启动,关闭系统防火墙或者开放端口 系统版本:CentOS7.0 Python版本:Py...
- 一.安装python3.6 1. 获取 wget https://www.python.org/ftp/pytho...
- 说明:这是转载[https://www.cnblogs.com/lvye001/p/10631276.html]的...
- python版本:Python3.6Centos版本:Centos7Django版本:为安装时候的最新版本(下面文...