centos7搭建django开发环境

1、系统环境更新
yum update -y
yum -y groupinstall "Development tools"
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
psmisc libffi-devel
yum install libffi-devel -y
2、centos安装
3、python3.7安装
下载python3.7.4:wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
解压下载文件:tar -zxvf Python-3.7.4.tgz
进入解压后的目录:cd Python-3.7.4
编译安装到指定路径:./configure --prefix=/usr/local/python3
安装python3.7.4:make && make install
建立python3软连接:ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
建立pip3软连接:ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
安装virtualenv:pip3 install virtualenv
建立virtualenv软连接:ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv
根目录下创建env文件夹存放虚拟环境:mkdir -p /data/env
根文件目录下创建www文件夹存放网站文件:mkdir -p /data/www

4、uwsgi安装
系统环境下安装uwsgi:pip3 install uwsgi
建立uwsig软连接:ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi
5、django安装
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple django
6、nginx安装
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
sudo yum install -y nginx
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
7、myql5.7安装
下载并安装MySQL官方的 Yum Repository:wget -i -c http://dev.mysql.com/get/mysql57-
community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
systemctl start mysqld.service
systemctl enable mysqld.service
systemctl status mysqld.service
grep "password" /var/log/mysqld.log
mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
yum -y remove mysql57-community-release-el7-10.noarch
8、开通80端口,允许通过外部电脑访问服务器地址
firewall-cmd --zone=public --add-port=80/tcp --permanent

你可能感兴趣的:(centos7搭建django开发环境)