unable to run django project under apache server












0















I have created one virtual environment in /var/www/python3 using pipenv and then created django project and installed all dependencies



my Pipfile is:



[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
django = "==2.1.4"
django-rest-swagger = "*"
mysqlclient = "*"
django-cors-headers = "*"
pillow = "*"
djangorestframework = "*"
django-extra-fields = "*"
djangorestframework-xml = "*"
django-filter = "*"

[requires]
python_version = "3.6"


my wsgi.py file is:



import os
from django.core.wsgi import get_wsgi_application


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "image_management.settings")

application = get_wsgi_application()


my urls.py is:



from django.contrib import admin
from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
from image_app import views as image_view
from django.urls import path, include
from rest_framework import routers
from django.conf.urls.static import static
from django.conf import settings
from rest_framework_swagger.views import get_swagger_view

schema_view = get_swagger_view(title='Pastebin API')

router = routers.DefaultRouter()
router.register(r'images', image_view.ImageViewSet)
router.register(r'albums', image_view.AlbumViewSet)

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include(router.urls)),
url(r'^swagger/$', schema_view)
]+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)


I have ran my apache using :



sudo service apache2 restart


when i try to access the admin page in django using http://10.75.12.254/admin/
I am getting the followinf error



Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.29 (Ubuntu) Server at 10.75.12.254 Port 80


I am getting the following logs if I open /var/log/apache2/error.log file:



[Fri Dec 28 17:05:36.782697 2018] [wsgi:error] [pid 9945:tid 140267535599360] [remote 10.50.10.133:43974] mod_wsgi (pid=9945): Target WSGI script '/var/www/python3/image_management/image_management/wsgi.py' cannot be loaded as Python module.
[Fri Dec 28 17:05:36.782770 2018] [wsgi:error] [pid 9945:tid 140267535599360] [remote 10.50.10.133:43974] mod_wsgi (pid=9945): Exception occurred processing WSGI script '/var/www/python3/image_management/image_management/wsgi.py'.


This is my 000-default.conf:



<VirtualHost *:80>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html



<Directory /var/www/python3/image_management/image_management>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

WSGIDaemonProcess image_management python-path=/var/www/python3/image_management:/home/test/.local/share/virtualenvs/shafiya-YlHOq6Kn/lib/python2.7/site-packages/
WSGIProcessGroup image_management
WSGIScriptAlias / /var/www/python3/image_management/image_management/wsgi.py


</VirtualHost>









share|improve this question

























  • Would you please post our apache.conf or httpd.conf file where the project alias and mod_wsgi.so is loaded?

    – SwapnilBhate
    Dec 28 '18 at 12:25
















0















I have created one virtual environment in /var/www/python3 using pipenv and then created django project and installed all dependencies



my Pipfile is:



[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
django = "==2.1.4"
django-rest-swagger = "*"
mysqlclient = "*"
django-cors-headers = "*"
pillow = "*"
djangorestframework = "*"
django-extra-fields = "*"
djangorestframework-xml = "*"
django-filter = "*"

[requires]
python_version = "3.6"


my wsgi.py file is:



import os
from django.core.wsgi import get_wsgi_application


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "image_management.settings")

application = get_wsgi_application()


my urls.py is:



from django.contrib import admin
from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
from image_app import views as image_view
from django.urls import path, include
from rest_framework import routers
from django.conf.urls.static import static
from django.conf import settings
from rest_framework_swagger.views import get_swagger_view

schema_view = get_swagger_view(title='Pastebin API')

router = routers.DefaultRouter()
router.register(r'images', image_view.ImageViewSet)
router.register(r'albums', image_view.AlbumViewSet)

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include(router.urls)),
url(r'^swagger/$', schema_view)
]+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)


I have ran my apache using :



sudo service apache2 restart


when i try to access the admin page in django using http://10.75.12.254/admin/
I am getting the followinf error



Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.29 (Ubuntu) Server at 10.75.12.254 Port 80


I am getting the following logs if I open /var/log/apache2/error.log file:



[Fri Dec 28 17:05:36.782697 2018] [wsgi:error] [pid 9945:tid 140267535599360] [remote 10.50.10.133:43974] mod_wsgi (pid=9945): Target WSGI script '/var/www/python3/image_management/image_management/wsgi.py' cannot be loaded as Python module.
[Fri Dec 28 17:05:36.782770 2018] [wsgi:error] [pid 9945:tid 140267535599360] [remote 10.50.10.133:43974] mod_wsgi (pid=9945): Exception occurred processing WSGI script '/var/www/python3/image_management/image_management/wsgi.py'.


This is my 000-default.conf:



<VirtualHost *:80>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html



<Directory /var/www/python3/image_management/image_management>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

WSGIDaemonProcess image_management python-path=/var/www/python3/image_management:/home/test/.local/share/virtualenvs/shafiya-YlHOq6Kn/lib/python2.7/site-packages/
WSGIProcessGroup image_management
WSGIScriptAlias / /var/www/python3/image_management/image_management/wsgi.py


</VirtualHost>









share|improve this question

























  • Would you please post our apache.conf or httpd.conf file where the project alias and mod_wsgi.so is loaded?

    – SwapnilBhate
    Dec 28 '18 at 12:25














0












0








0








I have created one virtual environment in /var/www/python3 using pipenv and then created django project and installed all dependencies



my Pipfile is:



[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
django = "==2.1.4"
django-rest-swagger = "*"
mysqlclient = "*"
django-cors-headers = "*"
pillow = "*"
djangorestframework = "*"
django-extra-fields = "*"
djangorestframework-xml = "*"
django-filter = "*"

[requires]
python_version = "3.6"


my wsgi.py file is:



import os
from django.core.wsgi import get_wsgi_application


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "image_management.settings")

application = get_wsgi_application()


my urls.py is:



from django.contrib import admin
from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
from image_app import views as image_view
from django.urls import path, include
from rest_framework import routers
from django.conf.urls.static import static
from django.conf import settings
from rest_framework_swagger.views import get_swagger_view

schema_view = get_swagger_view(title='Pastebin API')

router = routers.DefaultRouter()
router.register(r'images', image_view.ImageViewSet)
router.register(r'albums', image_view.AlbumViewSet)

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include(router.urls)),
url(r'^swagger/$', schema_view)
]+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)


I have ran my apache using :



sudo service apache2 restart


when i try to access the admin page in django using http://10.75.12.254/admin/
I am getting the followinf error



Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.29 (Ubuntu) Server at 10.75.12.254 Port 80


I am getting the following logs if I open /var/log/apache2/error.log file:



[Fri Dec 28 17:05:36.782697 2018] [wsgi:error] [pid 9945:tid 140267535599360] [remote 10.50.10.133:43974] mod_wsgi (pid=9945): Target WSGI script '/var/www/python3/image_management/image_management/wsgi.py' cannot be loaded as Python module.
[Fri Dec 28 17:05:36.782770 2018] [wsgi:error] [pid 9945:tid 140267535599360] [remote 10.50.10.133:43974] mod_wsgi (pid=9945): Exception occurred processing WSGI script '/var/www/python3/image_management/image_management/wsgi.py'.


This is my 000-default.conf:



<VirtualHost *:80>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html



<Directory /var/www/python3/image_management/image_management>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

WSGIDaemonProcess image_management python-path=/var/www/python3/image_management:/home/test/.local/share/virtualenvs/shafiya-YlHOq6Kn/lib/python2.7/site-packages/
WSGIProcessGroup image_management
WSGIScriptAlias / /var/www/python3/image_management/image_management/wsgi.py


</VirtualHost>









share|improve this question
















I have created one virtual environment in /var/www/python3 using pipenv and then created django project and installed all dependencies



my Pipfile is:



[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
django = "==2.1.4"
django-rest-swagger = "*"
mysqlclient = "*"
django-cors-headers = "*"
pillow = "*"
djangorestframework = "*"
django-extra-fields = "*"
djangorestframework-xml = "*"
django-filter = "*"

[requires]
python_version = "3.6"


my wsgi.py file is:



import os
from django.core.wsgi import get_wsgi_application


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "image_management.settings")

application = get_wsgi_application()


my urls.py is:



from django.contrib import admin
from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
from image_app import views as image_view
from django.urls import path, include
from rest_framework import routers
from django.conf.urls.static import static
from django.conf import settings
from rest_framework_swagger.views import get_swagger_view

schema_view = get_swagger_view(title='Pastebin API')

router = routers.DefaultRouter()
router.register(r'images', image_view.ImageViewSet)
router.register(r'albums', image_view.AlbumViewSet)

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include(router.urls)),
url(r'^swagger/$', schema_view)
]+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)


I have ran my apache using :



sudo service apache2 restart


when i try to access the admin page in django using http://10.75.12.254/admin/
I am getting the followinf error



Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.29 (Ubuntu) Server at 10.75.12.254 Port 80


I am getting the following logs if I open /var/log/apache2/error.log file:



[Fri Dec 28 17:05:36.782697 2018] [wsgi:error] [pid 9945:tid 140267535599360] [remote 10.50.10.133:43974] mod_wsgi (pid=9945): Target WSGI script '/var/www/python3/image_management/image_management/wsgi.py' cannot be loaded as Python module.
[Fri Dec 28 17:05:36.782770 2018] [wsgi:error] [pid 9945:tid 140267535599360] [remote 10.50.10.133:43974] mod_wsgi (pid=9945): Exception occurred processing WSGI script '/var/www/python3/image_management/image_management/wsgi.py'.


This is my 000-default.conf:



<VirtualHost *:80>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html



<Directory /var/www/python3/image_management/image_management>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

WSGIDaemonProcess image_management python-path=/var/www/python3/image_management:/home/test/.local/share/virtualenvs/shafiya-YlHOq6Kn/lib/python2.7/site-packages/
WSGIProcessGroup image_management
WSGIScriptAlias / /var/www/python3/image_management/image_management/wsgi.py


</VirtualHost>






django apache django-rest-framework






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 28 '18 at 12:50







L Shafiya

















asked Dec 28 '18 at 11:38









L ShafiyaL Shafiya

62




62













  • Would you please post our apache.conf or httpd.conf file where the project alias and mod_wsgi.so is loaded?

    – SwapnilBhate
    Dec 28 '18 at 12:25



















  • Would you please post our apache.conf or httpd.conf file where the project alias and mod_wsgi.so is loaded?

    – SwapnilBhate
    Dec 28 '18 at 12:25

















Would you please post our apache.conf or httpd.conf file where the project alias and mod_wsgi.so is loaded?

– SwapnilBhate
Dec 28 '18 at 12:25





Would you please post our apache.conf or httpd.conf file where the project alias and mod_wsgi.so is loaded?

– SwapnilBhate
Dec 28 '18 at 12:25












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53958004%2funable-to-run-django-project-under-apache-server%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53958004%2funable-to-run-django-project-under-apache-server%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Angular Downloading a file using contenturl with Basic Authentication

Olmecas

Can't read property showImagePicker of undefined in react native iOS