• 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
    
  • 相关阅读:
    数据库操作语句大全(sql)
    尚未在 Web 服务器上注册ASP.NET 4.5。安装VS15后的问题(转)
    ASP.NET通过http/https的POST方式,发送和接受XML文件内容(转)
    C# 的关键字详细介绍(转)
    12个css高级技巧.html
    CentOS上安装elasticsearch
    springboot例子
    ajax的XmlHttpRequest对象常用方法
    阿里云oss操作
    Python出现Could not find a version that satisfies the requirement openpyxl (from versions: )
  • 原文地址:https://www.cnblogs.com/otfsenter/p/7772613.html
Copyright © 2020-2023  润新知