在CentOS7上安装python3x+django1.8的运行环境

第一步:在CentOS7中安装Python3.4 yum groupinstall "Development tools" yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz tar -zxvf Python-3.4.3.tgz cd Python-3.4.3 mkdir /usr/local/python3.4 ./configure --prefix=/usr/local/python3.4 make make altinstall ln -sf /usr/local/python3.4/bin/python3.4 /usr/bin/python yum不支持3x所以 #vim /usr/bin/yum 把第一行的 #! /usr/bin/python 改为 #! /usr/bin/python2.7 保存 #python 命令如果出现以下错误 python: error while loading shared libraries: libpython3.4m.so.1.0: cannot open shared object file: No such file or directory #vim /etc/ld.so.conf 添加/usr/local/python3.4/lib/ 保存,#ldconfig 使之生效 #python 应该能正确进入3x的控制台 第二步:安装uwsgi #wget http://projects.unbit.it/downloads/uwsgi-latest.tar.gz #tar -zxvf uwsgi-latest.tar.gz #cd uwsgi-2.0.10 #python uwsgiconfig.py --build #cp uwsgi /usr/sbin/uwsgi 第三步:安装Django #wget https://www.djangoproject.com/m/releases/1.8/Django-1.8.2.tar.gz #tar -zxvf Django-1.8.2.tar.gz #cd Django-1.8.2 #python setup.py install 验证 [root@li863-202 Django-1.8.2]# python Python 3.4.3 (default, Jun 20 2015, 19:39:58) [GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> django.VERSION (1, 8, 2, 'final', 0) >>>   第四步:新建一个Django可运行的工程 #cd /home/wwwroot/ #python /usr/local/python3.3/bin/django-admin.py startproject monitor #cd monitor # python manage.py runserver Performing system checks... System check identified no issues (0 silenced). You have unapplied migrations; your app may not work properly until they are applied. Run 'python manage.py migrate' to apply them. June 20, 2015 - 13:00:35 Django version 1.8.2, using settings 'monitor.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. 表明server已启动,端口为8000 第五步:安装Mysql驱动 #wget https://codeload.github.com/PyMySQL/PyMySQL/legacy.tar.gz/pymysql-0.6 #mv pymysql-0.6 pymysql-0.6.tar.gz #tar -zxvf pymysql-0.6.tar.gz #cd PyMySQL* # python setup.py install 第六步:设置nginx upstream django { server 127.0.0.1:8000; # for a web port socket } server { listen 80; #listen [::]:80 default ipv6only=on; server_name monitor.yfsun.net; index index.html index.htm index.php; #error_page 404 /404.html; location / { root /home/wwwroot/monitor; uwsgi_pass django; include uwsgi_params; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } access_log /home/wwwlogs/access.log access; }

转载于:https://my.oschina.net/wowlinda/blog/550811

你可能感兴趣的:(python,操作系统,数据库)