I have recently uploaded my app on EC2 server running Ubuntu, Python 2.7.3, django.VERSION 1.5.1. I have managed to successfully launch it without any CSS/Images or JS. I can view templates and navigate them means template directory settings are working.
Looks like I am missing some setting for static/media files.
Can anyone please advise?
Content of "cat /etc/apache2/httpd.conf"
WSGIScriptAlias / /home/ubuntu/site/ProjectName/ProjectName/wsgi.py
WSGIPythonPath /home/ubuntu/site/ProjectName
<Directory /home/ubuntu/site/ProjectName/ProjectName>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
Content of settings.py
MEDIA_ROOT = '/var/www/media/'
MEDIA_URL = ''
STATIC_ROOT = ''
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/var/www/static/admin/'
STATICFILES_DIRS = (
'/var/www/static',
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
TEMPLATE_DIRS = ('/var/www/templates',)
**$ ls -ltr /var/www**
total 16
-rw-r--r-- 1 root root 177 Jul 26 20:21 index.html
drwxr-xr-x 3 www-data root 4096 Jul 28 04:20 static
drwxr-xr-x 5 www-data root 4096 Jul 28 04:20 media
drwxr-xr-x 20 www-data root 4096 Jul 28 16:29 templates
Errors in apache2/access.log
[29/Jul/2013:13:41:36 -0500] "GET /static/neatadmin/css/bootstrap.css HTTP/1.1" 404 1798
[29/Jul/2013:13:41:36 -0500] "GET /static/neatadmin/css/jquery.fancybox.css HTTP/1.1" 404 1806
[29/Jul/2013:13:41:36 -0500] "GET /static/neatadmin/js/jquery.js HTTP/1.1" 404 1798
[29/Jul/2013:13:41:36 -0500] "GET /static/neatadmin/js/jquery.metadata.js HTTP/1.1" 404 1804
[29/Jul/2013:13:41:36 -0500] "GET /static/neatadmin/css/login.css HTTP/1.1" 404 1794
[29/Jul/2013:13:41:36 -0500] "GET /static/neatadmin/js/error.js HTTP/1.1" 404 1794
Errors in apache2/error.log (I dont think it's relevant but just FYI)
[Mon Jul 29 13:41:29 2013] [error] /usr/local/lib/python2.7/dist-packages/django/conf/init.py:221: DeprecationWarning: You have no filters defined on the 'mail_admins' logging handler: adding implicit debug-false-only filter. See http://docs.djangoproject.com/en/dev/releases/1.4/#request-exceptions-are-now-always-logged
[Mon Jul 29 13:41:29 2013] [error] DeprecationWarning)
[Mon Jul 29 13:41:29 2013] [error]
[Mon Jul 29 13:41:35 2013] [error] /usr/local/lib/python2.7/dist-packages/django/conf/init.py:221: DeprecationWarning: You have no filters defined on the 'mail_admins' logging handler: adding implicit debug-false-only filter. See http://docs.djangoproject.com/en/dev/releases/1.4/#request-exceptions-are-now-always-logged
[Mon Jul 29 13:41:35 2013] [error] DeprecationWarning)
[Mon Jul 29 13:41:35 2013] [error]
Your settings are confusing the purpose of STATICFILES_DIRS and STATIC_ROOT. STATICFILES_DIRS holds additional static resources that are global to your project. This mirrors the TEMPLATE_DIRS setting. This directory would be included in your source repository.
STATIC_ROOT is a collection point for serving static files in production. Files from all the installed apps and STATICFILES_DIRS are copied here when you run collectstatic. This does not need to be set for local development. This directory would not be included in the repo as it only contains generated content. Your webserver configuration should have an alias to serve STATIC_ROOT as STATIC_URL For an example using Apache you should see the docs https://docs.djangoproject.com/en/stable/howto/deployment/wsgi/modwsgi/#serving-files
Related
I'm using Centos 7. I create a django project under /home/WEFORUM/admshapersdev/stargate/ and create a wsgi file in /home/WEFORUM/admshapersdev/stargate/stargate
The Django.conf
Alias /static /home/WEFORUM/admshapersdev/stargate/landingpage/static
<Directory /home/WEFORUM/admshapersdev/stargate/landingpage/static>
Require all granted
</Directory>
<Directory /home/WEFORUM/admshapersdev/stargate/stargate>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess stargate python-path=/home/WEFORUM/admshapersdev/stargate:/home/WEFORUM/admshapersdev/stargate/stargateenv/lib/python3.6/site-packages
WSGIProcessGroup stargate
WSGIScriptAlias / /home/WEFORUM/admshapersdev/stargate/stargate/wsgi.py
The structure and rights of the project folder:
../stargate
drwxr-xr-x. 6 admshapersdev apache 4096 Aug 17 22:47 landingpage/
-rwxr-xr-x. 1 admshapersdev apache 806 Aug 17 21:42 manage.py*
-rw-r--r--. 1 admshapersdev apache 464 Aug 17 22:42 requirements.txt
drwxr-xr-x. 4 admshapersdev apache 4096 Aug 18 01:08 stargate/
drwxr-xr-x. 5 admshapersdev apache 77 Aug 17 21:41 stargateenv/
drwxr-xr-x. 2 admshapersdev apache 6 Aug 17 21:52 static/
../stargate/stargate
-rw-r--r--. 1 admshapersdev apache 0 Aug 17 21:42 __init__.py
drwxr-xr-x. 2 admshapersdev apache 4096 Aug 18 01:09 __pycache__/
-rw-r--r--. 1 admshapersdev domain users 3555 Aug 18 01:08 settings.py
-rw-r--r--. 1 admshapersdev apache 3676 Aug 18 01:05 settings.py_1
drwxr-xr-x. 9 admshapersdev apache 91 Aug 17 22:49 static/
-rw-r--r--. 1 admshapersdev apache 259 Aug 17 22:38 urls.py
-rwxr--r--. 1 admshapersdev apache 394 Aug 18 00:49 wsgi.py*
But each time I try to reach my page, I am having this error in apache log:
[core:error] [pid 22477] (13)Permission denied: [client 192.168.140.179:63696] AH00035: access to /favicon.ico denied (filesystem path '/home/WEFORUM/admshapersdev/stargate') because search permissions are missing on a component of the path, referer: http://stargate0.weforum.local/admin
Does anyone know how to handle this? thank you for suggestions.
I move the project to /var/www but now I am having this:
[Sat Aug 18 07:43:49.987481 2018] [core:notice] [pid 20202] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sat Aug 18 07:58:19.927287 2018] [core:error] [pid 20205] (13)Permission denied: [client 192.168.140.179:49188] AH00035: access to /admin/ denied (filesystem path '/var/www/stargate') because search permissions are missing on a component of the path, referer: http://stargate0.weforum.local/admin/login/?next=/admin/
[Sat Aug 18 07:58:24.840377 2018] [core:error] [pid 20205] (13)Permission denied: [client 192.168.140.179:49188] AH00035: access to / denied (filesystem path '/var/www/stargate') because search permissions are missing on a component of the path
[Sat Aug 18 07:58:29.481225 2018] [core:error] [pid 20205] (13)Permission denied: [client 192.168.140.179:49188] AH00035: access to /admin/ denied (filesystem path '/var/www/stargate') because search permissions are missing on a component of the path, referer: http://stargate0.weforum.local/admin/login/?next=/admin/
I created a django project under /home/toto/Desktop named dash_test and I wanted to serve my Django application with Apache2 and mod_wsgi.
I installed the Apache web server, the mod_wsgi, and pip using this command sudo apt-get install python-pip apache2 libapache2-mod-wsgi. And I created a python virtual environment within the project directory named developer.
The allowed_hosts in the settings.py looks like this :
ALLOWED_HOSTS = ['xxx.xxx.xxx.xxx', 'localhost', '127.0.0.1']`
I added the static_url and the static_root:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
I did run a collectstatic
And I configured apache by editing the 000-default.conf :
<VirtualHost *:80>
Alias /static /home/toto/Desktop/dash_test/static
<Directory /home/toto/Desktop/dash_test/static>
Require all granted
</Directory>
<Directory /home/toto/Desktop/dash_test/dash_test>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess dash_test python-home=/home/toto/Desktop/dash_test/developer python-path=/home/toto/Desktop/dash_test
WSGIProcessGroup dash_test
WSGIScriptAlias / /home/toto/Desktop/dash_test/dash_test/wsgi.py
</VirtualHost>
when I try to access the localhost I get this 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 [no address given] 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.18 (Ubuntu) Server at localhost Port 80
Here is the content of the apache2 error.log:
[Thu Jun 14 13:25:48.134132 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] mod_wsgi (pid=21611): Target WSGI script '/home/toto/Desktop/dash_test/dash_test/wsgi.py' cannot be loaded as Python module.
[Thu Jun 14 13:25:48.134152 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] mod_wsgi (pid=21611): Exception occurred processing WSGI script '/home/toto/Desktop/dash_test/dash_test/wsgi.py'.
[Thu Jun 14 13:25:48.134167 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] Traceback (most recent call last):
[Thu Jun 14 13:25:48.134182 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] File "/home/toto/Desktop/dash_test/dash_test/wsgi.py", line 11, in <module>
[Thu Jun 14 13:25:48.134203 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] from django.core.wsgi import get_wsgi_application
[Thu Jun 14 13:25:48.134216 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] ImportError: No module named django.core.wsgi
I am using MySQL and phpMyAdmin instead of db.sqlite3
Thanks a lot.
Instead of:
<Directory /home/toto/Desktop/dash_test/dash_test>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
use:
<Directory /home/toto/Desktop/dash_test>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
You were using the wrong directory.
That or you have:
WSGIScriptAlias / /home/toto/Desktop/dash_test/wsgi.py
wrong and it is meant to be:
WSGIScriptAlias / /home/toto/Desktop/dash_test/dash_test/wsgi.py
The location of the wsgi.py doesn't actually look quite right if this is a Django app.
What is the actual path to the wsgi.py file.
The directory argument above should be the directory it is in.
I use Django 3.x and Apache 2.4 for upload my project in local host,indeed I going to test my project and Apache but I faced with same problem and when I check my Apache error.log it was : "ModuleNotFoundError: No module named 'django'"
And config file seems ok and when I check it with :"sudo apache2ctl configtest"
But I use this 2 commands for solve the problem
sudo a2dissite 000-default
sudo a2ensite 000-default
and
sudo systemctl reload apache2
When I am loading my class directly from some location I am able to load it.
>>> import sys
>>> sys.path.append('/path/to/my/flask/application')
>>> from myfile import app as application
>>>
Now from wsgi when I am doing the same thing.. it's not loading.
[Sat Aug 19 07:41:18 2017] [info] mod_wsgi (pid=29177): Imported 'mod_wsgi'.
[Sat Aug 19 07:41:24 2017] [error] [client 129.91.63.143] mod_wsgi (pid=29172): Target WSGI script '/var/www/flask-prod/webtool.wsgi' cannot be loaded as Python module.
[Sat Aug 19 07:41:24 2017] [error] [client 129.91.63.143] mod_wsgi (pid=29172): Exception occurred processing WSGI script '/var/www/flask-prod/webtool.wsgi'.
[Sat Aug 19 07:41:24 2017] [error] [client 129.91.63.143] Traceback (most recent call last):
[Sat Aug 19 07:41:24 2017] [error] [client 129.91.63.143] File "/var/www/flask-prod/webtool.wsgi", line 6, in <module>
[Sat Aug 19 07:41:24 2017] [error] [client 129.91.63.143] from myfile import app as application
[Sat Aug 19 07:41:24 2017] [error] [client 129.91.63.143] ImportError: No module named myfile
wsgi virtual host configuration below:
WSGIPythonHome /pathto/condadir
WSGIPythonPath /pathto/condadir/lib/python2.7
<virtualhost *:80>
ServerName myhost.example.com
WSGIDaemonProcess webtool user=apache group=root threads=5 home=/var/www/flask-prod/
WSGIScriptAlias / /var/www/flask-prod/webtool.wsgi
<directory /var/www/flask-prod>
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Order allow,deny
Allow from all
</directory>
</virtualhost>
Below is the wsgi file.
#!/pathto/condadir/bin/python
import sys
sys.path.append('/path/to/my/flask/application')
from myfile import app as application
Server mount status:
$ df -hP
/dev/xvda1 494M 29M 440M 7% /boot
tmpfs 5.0G 0 5.0G 0% /dev/shm
/dev/xvdc1 50G 3.2G 44G 7% /path
/dev/mapper/vg_apol-lv_var 1.5G 164M 1.3G 12% /var
My Application:
$ ls -lrt /path/to/my/flask/
-rwxrwx--- 1 root root 109 Aug 9 11:16 README
drwxrwx--- 4 root root 4096 Aug 19 08:24 application
-rw------- 1 root root 0 Aug 19 08:25 __init__.py
$ ls -lrt /path/to/my/flask/application
-rwxrwx--- 1 root root 23 Jun 4 05:19 __init__.py
drwxrwx--- 6 root root 4096 Aug 7 15:24 static
-rwxrwx--- 1 root root 7168 Aug 9 11:45 users_sqlite.db
-rwxrwx--- 1 root root 9670 Aug 9 12:06 myfile.py
drwxrwx--- 5 root root 4096 Aug 10 14:50 templates
-rwxrwx--- 1 root root 448 Aug 10 14:51 myfile.pyc
httpd app portion:
$ pwd
/var/www
$ ls -ld flask-prod
drwxr-xr-x 2 root root 4096 Aug 19 08:21 flask-prod
$ ls -rlt flask-prod/
total 28
-rw------- 1 root root 0 Aug 18 15:54 __init__.py
-rwxr-xr-x 1 root root 258 Aug 19 08:21 webtool.wsgi
I was following this tutorial:
https://pythonprogramming.net/creating-first-flask-web-app/?completed=/flask-web-development-introduction/
On my local server (home machine on local network).
Flask itself starts properly
>>> python /var/www/FlaskApp/FlaskApp/__init__.py
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [31/Oct/2016 22:56:29] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [31/Oct/2016 22:56:29] "GET /favicon.ico HTTP/1.1" 404 -
flask starts
But Apache is showing its default webpage no matter what.
sudo a2enmod wsgi
Module wsgi already enabled
cat /var/www/FlaskApp/FlaskApp/init.py
from flask import Flask
app = Flask(__name__)
#app.route('/')
def homepage():
return "Hi There, how you're doin?"
if __name__ == "__main__":
app.run()(debug=True)
cat /etc/apache2/sites-available/FlaskApp.conf
<VirtualHost *>
ServerName dagzserv
ServerAdmin my#email.com
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Require all granted
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite FlaskApp
Site FlaskApp already enabled
I have tried adding app.run(host='0.0.0.0', port=5000)
I do have /etc/hosts dagserv as my ip in localnetwork (10.0.1.xxx)
Also tried ServerName as localhost.
One thing i did not understood is how exactly Apache is finding that "FlaskApp.conf" but i assumed that it is scanning its config directory
(/etc/apache2/sites-available/FlaskApp.conf)
I am getting no errors in /var/logs/apache2
cat access.log
10.0.1.14 - - [31/Oct/2016:22:46:52 -0700] "GET / HTTP/1.1" 200 3524 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36"
10.0.1.14 - - [31/Oct/2016:22:49:14 -0700] "GET / HTTP/1.1" 200 3524 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36"
10.0.1.14 - - [31/Oct/2016:22:49:15 -0700] "GET / HTTP/1.1" 200 3523 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36"
10.0.1.101 - - [31/Oct/2016:22:56:18 -0700] "GET /favicon.ico HTTP/1.1" 404 499 "-" "Mozilla/5.0 (X11; Ubuntu; Linux armv7l; rv:49.0) Gecko/20100101 Firefox/49.0"
cat error.log
[Mon Oct 31 22:45:47.288264 2016] [wsgi:warn] [pid 982] mod_wsgi: Compiled for Python/2.7.11.
[Mon Oct 31 22:45:47.288623 2016] [wsgi:warn] [pid 982] mod_wsgi: Runtime using Python/2.7.12.
[Mon Oct 31 22:45:47.314433 2016] [mpm_prefork:notice] [pid 982] AH00163: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Mon Oct 31 22:45:47.314616 2016] [core:notice] [pid 982] AH00094: Command line: '/usr/sbin/apache2'
[Mon Oct 31 22:48:52.171206 2016] [mpm_prefork:notice] [pid 982] AH00169: caught SIGTERM, shutting down
[Mon Oct 31 22:48:53.766824 2016] [wsgi:warn] [pid 2360] mod_wsgi: Compiled for Python/2.7.11.
[Mon Oct 31 22:48:53.766940 2016] [wsgi:warn] [pid 2360] mod_wsgi: Runtime using Python/2.7.12.
[Mon Oct 31 22:48:53.775947 2016] [mpm_prefork:notice] [pid 2360] AH00163: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Mon Oct 31 22:48:53.776083 2016] [core:notice] [pid 2360] AH00094: Command line: '/usr/sbin/apache2'
1. How Apache is finding that "FlaskApp.conf"
There one line in /etc/apache2/apache2.conf to include virtual host configurations:
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
Apache2 server will load apache2.conf and also include the virtual host configurations.
2. Why Apache is showing its default webpage no matter what.
If you access the server via IP address, Apache will return based on its default site configuration in /etc/sites-available/000-default.conf. So if you want to access your WSGI server via IP address, you should disable the Apache default site configuration first:
sudo a2dissite 000-default.conf
service apache2 restart
I am facing problem with static files(Django1.3) when tried to deploy it in my local apache server(apache2+mod_wsgi), the problem only for the static contents other parts ok[its worked in the devlopment server].
My project now in a folder 'testcloud' in Ubandu Desktop,My project
name is DjangoApis,Following is my project structure:
Desktop->testcloud:
DjangoApis
...
mywebapp
static
templates
templatetags
urls.py
views.py
myapis
.....
Settings.py
STATIC_ROOT = '/home/jisson/Desktop/testcloud.aws/DjangoApis/
teststaticfiles/'
STATIC_URL = '/static/'
TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.media",
"django.core.context_processors.static",
)
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__),'templates').replace('\
\','/'),
)
INSTALLED_APPS = (
'DjangoApis.mywebapp',
'DjangoApis.myapis',
)
STATICFILES_DIRS = (
os.path.join(os.path.dirname(__file__),'static').replace('\
\','/'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
/etc/apache2/sites/enabled/DjangoApis:
Alias /favicon.ico /home/jisson/Desktop/testcloud.aws/DjangoApis/
static/favicon.ico
AliasMatch ^/([^/]*\.css) /home/jisson/Desktop/testcloud.aws/
DjangoApis/static/styles/$1
Alias /static/ /home/jisson/Desktop/testcloud.aws/DjangoApis/static/
<Directory /home/jisson/Desktop/testcloud.aws/DjangoApis/static>
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /home/jisson/Desktop/testcloud.aws/DjangoApis/
django.wsgi
apache errorlog:
tail /var/log/apache2/error.log
[Sat Dec 10 03:16:36 2011] [error] [client 127.0.0.1] File does not
exist: /home/jisson/Desktop/testcloud.aws/DjangoApis/staticjs,
referer: http://test.webapp/
[Sat Dec 10 03:16:36 2011] [error] [client 127.0.0.1] File does not
exist: /home/jisson/Desktop/testcloud.aws/DjangoApis/staticjs,
referer: http://test.webapp/
[Sat Dec 10 03:16:36 2011] [error] [client 127.0.0.1] File does not
exist: /home/jisson/Desktop/testcloud.aws/DjangoApis/staticjs,
referer: http://test.webapp/
[Sat Dec 10 03:16:36 2011] [error] [client 127.0.0.1] File does not
exist: /home/jisson/Desktop/testcloud.aws/DjangoApis/staticjs,
referer: http://test.testapp/
[Sat Dec 10 03:16:45 2011] [error] [client 127.0.0.1] File does not
exist: /home/jisson/Desktop/testcloud.aws/DjangoApis/staticimages,
referer: http://test.webapp/
[Sat Dec 10 03:16:45 2011] [error] [client 127.0.0.1] File does not
exist: /home/jisson/Desktop/testcloud.aws/DjangoApis/staticimages,
referer: http://test.webapp/
[Sat Dec 10 03:16:45 2011] [error] [client 127.0.0.1] File does not
exist: /home/jisson/Desktop/testcloud.aws/DjangoApis/staticimages,
referer: http://test.webapp/
[Sat Dec 10 03:16:45 2011] [error] [client 127.0.0.1] File does not
exist: /home/jisson/Desktop/testcloud.aws/DjangoApis/staticimages,
referer: http://test.webapp/
[Sat Dec 10 03:16:45 2011] [error] [client 127.0.0.1] File does not
exist: /home/jisson/Desktop/testcloud.aws/DjangoApis/staticimages,
referer: http://test.webapp/
[Sat Dec 10 03:16:45 2011] [error] [client 127.0.0.1] File does not
exist: /home/jisson/Desktop/testcloud.aws/DjangoApis/staticimages,
referer: http://testwebapp/
errorlog of firebug:
test.webapp (line 62)
"NetworkError: 404 NOT FOUND - http://test.webapp/css/styles/index.css/"
/css/s...ex.css/
"NetworkError: 404 Not Found - http://test.webapp/static/images/logo.jpg"
logo.jpg
"NetworkError: 404 Not Found - http://test.webapp/static/images/line.jpg"
line.jpg
"NetworkError: 404 Not Found - http://test.webapp/static/images/banner_phone.jpg"
.........................
Note I used collectstatic command.
Please help me to solve the issue,Thanks in advace.
Look closely, Apache tries to load files from /home/jisson/Desktop/testcloud.aws/DjangoApis/staticjs, not /home/jisson/Desktop/testcloud.aws/DjangoApis/static/js like you wanted.
If files are correctly collected by collectstatic command (they appear in STATIC_ROOT directory after running that command), then problem is not in Django side, but rather in Apache, so you should check your Apache configuration files.