• 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
    
  • 相关阅读:
    不同浏览器对于js中for循环的判断
    png格式图片背景不透明问题解决
    qq登陆错误提示
    T职场人生系列之二十四:程序员如何增加收入
    if [ $# eq 0 ]该语句是什么含义?
    动态IP修改注册表降低PING值教程(XP系统)
    c# List列表数据转换成树形结构
    net core EF 链接mysql 数据库
    net core 部署到windows 服务
    IdentityServer4 密码模式认证
  • 原文地址:https://www.cnblogs.com/otfsenter/p/7772613.html
Copyright © 2020-2023  润新知