2015-08-26 40 views
2

我收到404錯誤試圖訪問在生產環節上EC2我Django應用程序靜態文件的時候,雖然它在同Bitnami堆在VBOX上演絕精細。我的Alias條目httpd.conf正常工作robots.txtfavicon.ico - 我可以正確訪問它們。然而,我不能使用它的Alias條目(即在所有頁面上)訪問/static中特定的任何內容。404錯誤與靜態文件通過Django的/阿帕奇(Bitnami)擔任

我在我的apache日誌中沒有發現有關被服務器配置/ etc阻止的錯誤,並且我的static文件夾的權限被(臨時)設置爲777,並沒有幫助。我究竟做錯了什麼?

我STATIC_ROOT是/opt/bitnami/apps/django/django_projects/data_dashboard/project/static

httpd.conf文件看起來像這樣:

<Directory /opt/bitnami/apps/django/django_projects/data_dashboard/project/project> 
<Files wsgi.py> 
Require all granted 
</Files> 
</Directory> 

WSGIScriptAlias//opt/bitnami/apps/django/django_projects/data_dashboard/project/project/wsgi.py 

<Directory "/opt/bitnami/apps/django/django_projects/data_dashboard/project/static"> 
    Require all granted 
</Directory> 


Alias /static /opt/bitnami/apps/django/django_projects/data_dashboard/project/static 
Alias /robots.txt /opt/bitnami/apps/django/django_projects/data_dashboard/project/static/robots.txt 
Alias /favicon.ico /opt/bitnami/apps/django/django_projects/data_dashboard/project/static/favicon.ico 

httpd-vhosts.conf

<VirtualHost *:80> 
ServerName ec2-xx-xx-xxx-xx.eu-west-1.compute.amazonaws.com 

Include "/opt/bitnami/apps/django/django_projects/data_dashboard/project/conf/httpd-app.conf" 
</VirtualHost> 

<VirtualHost *:443> 
ServerName ec2-xx-xx-xxx-xx.eu-west-1.compute.amazonaws.com 
SSLEngine on 
SSLCertificateFile "/opt/bitnami/apps/django/django_projects/data_dashboard/project/conf/certs/server.crt" 
SSLCertificateKeyFile "/opt/bitnami/apps/django/django_projects/data_dashboard/project/conf/certs/server.key" 

Include "/opt/bitnami/apps/django/django_projects/data_dashboard/project/conf/httpd-app.conf" 

http-app.conf

<IfDefine !IS_DJANGOSTACK_LOADED> 
Define IS_DJANGOSTACK_LOADED 
WSGIDaemonProcess wsgi-djangostack processes=2 threads=15 display-name=%{GROUP} 
</IfDefine> 

<Directory  "/opt/bitnami/apps/django/django_projects/data_dashboard/project/project"> 
Options +MultiViews 
AllowOverride All 
<IfVersion <2.3> 
    Order allow,deny 
    Allow from all 
</IfVersion> 
<IfVersion >= 2.3> 
    Require all granted 
</IfVersion> 

WSGIProcessGroup wsgi-djangostack 

WSGIApplicationGroup %{GLOBAL} 
<IfVersion <2.3> 
    Order allow,deny 
    Allow from all 
</IfVersion> 
<IfVersion >= 2.3> 
    Require all granted 
</IfVersion> 

</Directory> 



<Directory "/opt/bitnami/python/lib/python2.7/site-packages/django"> 
Options +MultiViews 
AllowOverride All 
<IfVersion <2.3> 
    Order allow,deny 
    Allow from all 
</IfVersion> 
<IfVersion >= 2.3> 
    Require all granted 
</IfVersion> 

</Directory> 

回答

0

我已經解決了這個既包括該版本和一個,雖然不是。我使用相同的堆棧創建了一個空白的EC2服務器,從所有級別獲取了Apache conf文件,並添加了我相信添加的參數。因此有效地從頭開始了conf。

0

從文檔(https://wiki.bitnami.com/BitNami_Cloud_Hosting/Base_stack),它看起來像亞馬遜EC2使用Apache版本2.2.29。你應該遺憾的是找出確切的問題改變httpd.conf在其他設置

<Directory /opt/bitnami/apps/django/django_projects/data_dashboard/project/static> 
    <IfVersion <2.3> 
     Order allow,deny 
     Allow from all 
    </IfVersion> 
    <IfVersion >= 2.3> 
     Require all granted 
    </IfVersion> 
</Directory> 
+0

感謝您的支持。不幸的是我的堆棧使用2.4.12。無論如何我已經嘗試了這個清晰度,同樣的問題仍然存在。 – samg86