我已将Django Web应用程序部署到apache服务器中。但是我的问题是我可以通过服务器ip访问我的应用程序,但无法通过服务器域名访问它。我在服务器上部署了两个django应用程序,我正在使用virtualenv,在django settings.py文件中,我在allowed_hosts设置中包含了服务器IP和域名。 请找到以下配置文件: 000-default.conf
<VirtualHost *:80>
ServerAdmin xyz@gmail.com
ServerName domainname.com
ServerAlias www.domainname.com
DocumentRoot /var/www/html
Alias /demo_shopify_python/static /var/www/html/demo_shopify_python/static
<Directory /var/www/html/demo_shopify_python/static>
Require all granted
</Directory>
WSGIDaemonProcess demo_shopify_python python-home=/var/www/html/demo_shopify_python/virtual python-path=/var/www/html/demo_shopify_python
WSGIProcessGroup demo_shopify_python
WSGIScriptAlias /demo_shopify_python /var/www/html/demo_shopify_python/demo_shopify_python/wsgi.py process-group=demo_shopify_python application-group=%{GLOBAL}
<Directory /var/www/html/shopify_django_app-master>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static /var/www/html/myproject/static
<Directory /var/www/html/myproject/static>
Require all granted
</Directory>
WSGIDaemonProcess myproject python-home=/var/www/html/myproject/myprojectenv python-path=/var/www/html/myproject
WSGIProcessGroup myproject
WSGIScriptAlias /myproject /var/www/html/myproject/myproject/wsgi.py process-group=myproject application-group=%{GLOBAL}
<Directory /var/www/html/myproject/myproject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.domainname.com [OR]
RewriteCond %{SERVER_NAME} =domainname.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
https://domainname.com/myproject-> django项目应该显示,而是显示文件夹内文件的列表。 https:// ip / myproject->正常工作。
您能帮我解决我遗漏的问题吗? 谢谢!