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
    
  • 相关阅读:
    将地址转换为链接的正则表达式(regex url href)
    [收藏]中国惠普前总裁孙振耀谈人生
    沪江技术团队寻觅新成员,下一位会是你吗?
    来点圣诞气氛
    让VisualSVN Server支持匿名访问
    11月25日博客园南京园友聚会
    [上海俱乐部活动]博文视点与博客园系列图书作者见面会暨.NET技术交流会
    比尔·盖茨在微软的最后一天
    真让人兴奋
    博客园新服务器已下订单
  • 原文地址:https://www.cnblogs.com/otfsenter/p/7772613.html
Copyright © 2011-2022 走看看