Django + Apache: make project accessible from WWW [closed] - django

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I've developed a Django project running on dev server. Now I am struggling in using Apache as the web server to run this project.
I've changed the port (say, 8088) at Router, and also edited http.conf in Apache dir to listen this port 8088.
Now I can view apache page at http://XX.XX.XX.XX:8088 (using ip) which shows 'It works'..
however, when I tried to run Django project using 'python manage.py runserver 0.0.0.0:8088', it says 'ERROR 10013: An attempt was made to access a socket in a way forbidden by its access permissons'.
It seems that the connection between Django and Apache doesn't work out, since I can view Apache working page but I can't get the project page...
I did configurate mod_wsgi.
maybe there are other silly stuff I've mistakenly done.
if anybody has some advice, that would be much appreciated!

If you've configured mod_wsgi properly, you don't need to run python manage.py runserver. Simply running the Apache daemon will make it listen on the port configured and will make it use the mod_wsgi file you've defined in the site-available.
Re-read this Django - how to use Django with Apache and mod_wsgi to verify you have it set up appropriately. You cannot run python manage.py runserver on a port that is already being listened to by Apache. Hence, the error attempting to access a socket (on port 8088) in a forbidden way.

Related

Host flask api on server locally [duplicate]

This question already has answers here:
Are a WSGI server and HTTP server required to serve a Flask app?
(3 answers)
Closed 2 years ago.
I need to host my API on the server. How is it possible? I have done by virtualenv on my computer but I need to host it now on my company server I need to host exactly like virtualenv ? Or there is some other way as in PHP we use xamp?
You simply install flask in a virtualenv or not, and do flask run app.py to run the server, just like the documentation says.
Alternatively, if you want a feature set similar to Apache HTTPd, then you can look into uWSGI

Amazon AWS throwing 403 Forbidden after deploying django from different system [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have used Ubuntu 14.04 and python 3.4 as development machine for Django.
The deployment to Amazon AWS was successful using eb deploy and website running without problem.
Somehow later I need to change my system and used another laptop for deployment. I copied my Virtualenv django project folder and pasted into my new system with same configuration. But now when I deploying using eb deploy with same security access id in AWS, it deployed succesfully but when accessing the website I am getting error as
Forbidden - You don't have permission to access / on this server.
But When I again deploy from old system it works but from new it doesn't.
I did following steps and it worked from my new machine.
1. I used mysql-devel package which is for MySQL to work on AWS with django using RDS. This was configured in django.config file. I removed this configuration from it.
2. I removed .elasticbeanstalk folder.
3. Then finally ran commands : python manage.py collectstatic & python manage.py migrate
4. Then used "eb deploy". The site was successfully deployed and running.
5. Then I again put mysql-devel package in django.config file and deploy it.

PostgreSQL psql: could not connect to server: Connection refused

I am making my first Django app and am trying to deploy to Heroku. I am using a postgres database. My app works fine when I run it on localhost. I pushed my project to Heroku and when I attempt to go to the site I get the following error:
"psql: could not connect to server: Connection refused Is the server running on host
host.domain.com and accepting TCP/IP connections on port 5432?"
So I have been searching endlessly to the solution for this problem, and of the few I have found, NONE can explain clearly the steps involved in changing the postgres settings from localhost. Apparently I am supposed to change a setting in a postgres config file that I cannot find any trace of on my computer, and I can't find command line instructions either. Even the postgres docs don't help.
Can anyone help me to solve this?
Since you pushed your project to Heroku, changing files for your local Postgres installation is irrelevant to the problem.
The question is: Does the remote Postgres installation on Heroku allow remote access? And if yes, what are the exact credentials? For starters, I doubt you can use the standard port 5432. And you may need sslmode=require.
Consult Heroku for the actual credentials. This site may help:
https://devcenter.heroku.com/articles/heroku-postgresql#external-connections-ingress

Efficient webapp developing [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Is not efficient :).
I'm trying to learn django by building a simple app. I bought a hosting plan on webfaction, set up github account and a putty on my Windows machine. I'm writing the "code" on my Windows, pushing it to github repo, then connecting via putty to my webfaction account to pull from github.
This is extremely tedious and boring process and I can't help but wonder that I'm doing something wrong. Even fixing a simple typo takes a lot of time. Are developers writing everything server-side using vim? This sound even less encouraging. Can I do something to improve my workflow? How it's done by professionals?
To summarise Kit Sunde's answer: you shouldn't be deploying to the server until you've actually got a site to deploy. Normal development and testing is done locally, using manage.py runserver and a local db. This works fine on Windows.
You need to stop wasting your own time, which you are if you are editing code on the server. There are many reasons why you shouldn't deploy code that way the most important ones is that you'll waste time and also importantly is that you'll break things while users are looking at the site.
Setup a development server locally, this is why the django manage.py runserver exists. If you for some reason can't run it on windows, then install a server in virtualbox, mount the folder in windows where your code is and run it off that (this is what we do for our designers although we have a lot of dependencies).
There are IDE's out there that enables you to run Django via a GUI that you might find more comfortable, I use PyCharm and I hear good things about eclipse.
You'd save time if you learned how fabric worked so you can automate your deploy process. I am unsure how well fabric works on windows, but I'm sure you can use cygwin or similar to get it working.
A fairly basic example would be this one:
from fabric.api import *
env.hosts = ['ubuntu#example.org']
def deploy():
pid_file = "~/myproject/process.pid"
with cd('~/myproject/'):
run('git pull')
run('src/city_nomads/manage.py collectstatic --noinput')
# If the process isn't up we don't want the thing to exit.
with settings(warn_only=True):
run("cat {} | xargs kill -TERM".format(pid_file))
run("src/myproject/manage.py runfcgi "
"method=threaded "
"host=127.0.0.1 "
"port=8000 "
"pidfile={} "
"--settings=myproject.settings_release".format(pid_file))
It'll SSH into my server, pull the source, collectstatic, kill the process if it's there and then run django as fastcgi. I'm assuming you have nginx or apache set up to connect to Django on port 8000.

Configuring port for django development environment, so the site is available from outside

I am experimenting with django and I throw the code on my server like explained in the first chapters of the django book 2.0.
I have apache running on this server, too (port 80). If I stop apache I can start my django site by calling
sudo python manage.py runserver 0.0.0.0:80
If I access it from another machine by
http://myservername:80
it works fine. Now, apache is running an important page, and I don't want to let apache stoped. How do I make mysite available on another port?
Edit: I'll try to explain more:
When apache runs, typing into the adressfield of my browser, shows me the "important wepage".
Starting my django test project with
sudo python manage.py runserver 0.0.0.0:anotherport
and accessing trying to acces it by
http://ipadressofserver:anotherport
does not work.
If apache is tuned off, and I start my django project by
sudo python manage.py runserver 0.0.0.0:80
I can access it by
http://myservername
http://myservername:80 (the browser changes this to http://myservername/
http://myserverIP and http://myservrIP:80 (The latter resolves in the former).
I am not experienced in Serveradministration so please ask me, if there is something specific I can tell you, to help me solve the problem, please ask me, and I'll provide the information - if possible.
Specify a different port when starting the dev server:
$ python manage.py runserver 0.0.0.0:8000
and connect to the site via:
http://myserverip:8000
You should be able to configure your router appropriately to point to any port. This question should more directly relate to how do you expose a specific port to be browsed. Any information you could provide about your router would be more helpful to address this.