zoukankan      html  css  js  c++  java
  • django apache httpd centos

    There are som errors below

    sudo yum update -y
    sudo yum install epel-release -y
    sudo yum install python2-pip httpd mod_wsgi -y
    sudo pip install virtualenv
    sudo mkdir /opt/djangoproject
    cd /opt/djangoproject
    sudo virtualenv djangoprojectenv
    sudo source djangoprojectenv/bin/activate
    (djangoprojectenv) [root@centOS-7 djangoproject]# pip install django
    (djangoprojectenv) [root@centOS-7 djangoproject]# django-admin --version
    1.10.5
    (djangoprojectenv) [root@centOS-7 djangoproject]#django-admin.py startproject myfirstproject .
    nano myfirstproject/settings.py
    STATIC_ROOT = os.path.join(BASE_DIR, "static/")
    (djangoprojectenv) [root@centOS-7 djangoproject]#./manage.py migrate
    (djangoprojectenv) [root@centOS-7 djangoproject]#./manage.py createsuperuser
    	Username (leave blank to use 'root'): djangoadmin
    	Email address: email@domain.tld
    	Password:
    	Password (again):
    	Superuser created successfully.
    (djangoprojectenv) [root@centOS-7 djangoproject]#./manage.py collectstatic
    
    # it do not work
    (djangoprojectenv) [root@centOS-7 djangoproject]#nano djangoprojectenv/lib64/python2.7/site-packages/django/http/request.py
        allowed_hosts = ['localhost', '192.168.15.193', '[::1]']
    (djangoprojectenv) [root@centOS-7 djangoproject]#./manage.py runserver 0.0.0.0:8989
    firewall-cmd --zone=public --add-port=8989/tcp
    (djangoprojectenv) [root@centOS-7 djangoproject]# deactivate
    ### Apache
    sudo nano /etc/httpd/conf.d/django.conf
    	Alias /static /opt/djangoproject/static
    	<Directory /opt/djangoproject/static>
    	 Require all granted
    	</Directory>
    	
    	<Directory /opt/djangoproject/myfirstproject>
    	   <Files wsgi.py>
    	       Require all granted
    	   </Files>
    	</Directory>
    	
    	WSGIDaemonProcess myfirstproject python-path=/opt/djangoproject:/opt/djangoproject/djangoprojectenv/lib/python2.7/site-packages
    	WSGIProcessGroup myfirstproject
    	WSGIScriptAlias / /opt/djangoproject/myfirstproject/wsgi.py
    
    sudo systemctl restart httpd
    sudo systemctl enable httpd
    firewall-cmd --zone=public --permanent --add-port=80/tcp
    sudo chown -R apache:apache /opt/djangoproject
    http://192.168.15.193/admin
    
  • 相关阅读:
    常用的android弹出对话框
    AutoCompleteTextView与TextWatcher的结合
    As of ADT 14, resource fields cannot be used as switch cases
    Linux中tshark(wireshark)抓包工具使用方法详解
    php模板引擎
    php中实现精确设置session过期时间的方法
    什么情况下会调用到session_destroy()
    PHPSession-完全PHP5之session篇
    彻底理解PHP的SESSION机制
    闪迪U3利用工具U3-Pwn
  • 原文地址:https://www.cnblogs.com/otfsenter/p/7772613.html
Copyright © 2011-2022 走看看