I need to run a python Django project with Pycharm IDE locally in HTTPS
so that other services can talk with my service without any errors.
I don't manage to run it locally in HTTPS
You can use runserver_plus extension. It depends on Werkzeug, so you have to install it first. Installation:
pip install Werkzeug
pip install django-extensions
pip install pyOpenSSL
Then add django_extensions to your INSTALLED_APPS inside settings.py:
INSTALLED_APPS = (
...
'django_extensions',
)
Now you need to generate self-signed certificate for your local server. Something like this, credits to Diego Woitasen:
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365
And now you can run Django this way:
python manage.py runserver_plus --cert-file /path/to/cert.crt
And some links for sources:
runserver_plus with SSL.
Werkzeug installation.
Related
I went to restart Apache after disabling the banner with
sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1
now Apache won't restart
~$ sudo /opt/bitnami/ctlscript.sh status
php-fpm already running
apache not running
mysql already running
I tried
~$ sudo /opt/bitnami/ctlscript.sh start apache
Syntax OK
/opt/bitnami/apache2/scripts/ctl.sh : httpd could not be started
Monitored apache
for error log - cat /opt/bitnami/apache2/logs/error_log
you can find it here in this link
https://drive.google.com/file/d/1f2Xt0bwcMEhKcXkILLMf_kdBl0JoSZUr/view?usp=sharing
for httpd-app.conf file here copy of it in below link
https://drive.google.com/file/d/1l2zEPzIU0uBHdEyFQEZ22eEPS9fMnBTO/view?usp=sharing
Bitnami Engineer here,
From the log file you shared, I see that Apache fails because there is a mismatch when checking the SSL certificates
Certificate and private key localhost:443:0 from /opt/bitnami/apache2/conf/server.crt and /opt/bitnami/apache2/conf/server.key do not match
Did you modify them? In case you configured a new SSL certificate, you probably forgot to copy any of the files. If you didn't want to configure a SSL certificate, you can generate new self-signed certificates by running these commands
sudo openssl genrsa -out /opt/bitnami/apache2/conf/server.key 2048
sudo openssl req -new -key /opt/bitnami/apache2/conf/server.key -out /opt/bitnami/apache2/conf/cert.csr
sudo openssl x509 -in /opt/bitnami/apache2/conf/cert.csr -out /opt/bitnami/apache2/conf/server.crt -req -signkey /opt/bitnami/apache2/conf/server.key -days 365
https://docs.bitnami.com/aws/components/apache/#how-to-create-an-ssl-certificate
I'm trying to add python packages to my Choregraphe app because some packages that are installed by default with python 2.7 aren't in python embedded in Choregraphe.
I want to add urllib3 and certifi to my app to be able to sen HTTPS requests and verify SSL certificates.
So I added a lib folder to my app with the necessary packages, it works fine for urllib3 but to verify SSL certificates I got a cascade of dependencies so I don't manage to do what I want.
Does anyone know if there is a way to access manually the default python version accessible by my Robot so that I can send my request with these packages ?
Thanks in advance !
If you're running this on a Pepper with NAOqi 2.5, pip is installed on the robot; though you'll need to upgrade it:
pip install --user --upgrade pip
and then you can run
/home/nao/.local/bin/pip install --user urllib3 certifi
Then you don't need to package those files in your choregraphe package.
It won't work on the virtual robot (but then you can just add the real path of those libraries to sys.path), and it means you'll have to do this procedure yourself if you want to install your app on a new robot, which can be a hassle.
Hi I hope someone can point me in the right direction.
I am trying to upload a django project which I have developed locally on my machine and now moved the project files to a server and am trying to install django on the server.
I have Python 2.7.5 installed and accessed the server remotely using ssh (putty) I can confirm Python is installed by running the command python --version
I don't have pip installed as when i run the command pip --version
I get following notification
-bash: pip: command not found
I am new to django and python so not sure what I should do to install both django and pip.
p.s In my requirements file and when working locally I have pip and django installed correctly and all working.
Ok, lets say you are already on your remote server. First thing to do is to install pip for your version of python. You can do this via:
sudo apt-get install python-pip
From now you have pip installed. Next thing to do is to install django globally in your system:
pip install django==1.11
Please note that django 1.11 is the last version that supports
python2
Next thing to do is to create django app:
django-admin startproject test_project
And the last thing is to install virtualenv
To install libraries for each of your django projects and keep them
separate
pip install virtualenv
Also note
If you have requirements.txt file with all libs, you can do something like this on your remote server:
pip install -r requirements.txt
That will automatically install all libraries at once
First you should understand which OS you're running:
uname -a
and:
lsb_release -a
When you find the OS version, you can easily follow this guide:
https://packaging.python.org/guides/installing-using-linux-tools/#installing-pip-setuptools-wheel-with-linux-package-managers
As in the title, when running the appserver I get a DistributionNotFound exception for google-cloud-storage:
File "/home/[me]/Desktop/apollo/lib/pkg_resources/init.py", line 867, in resolve
raise DistributionNotFound(req, requirers)
DistributionNotFound: The 'google-cloud-storage' distribution was not found and is required by the application
Running pip show google-cloud-storage finds it just fine, in the site packages dir of my venv. Everything seems to be in order with python -c "import sys; print('\n'.join(sys.path))" too; the cloud SDK dir is in there too, if that matters.
Not sure what to do next.
The solution for me was that both google-cloud-storage and pkg_resources need to be in the same directory.
It sounds like your google-cloud-storage is in venv and your pkg_resources is in the lib folder
You can try installing google-cloud-storage to the user site using the --user flag.
pip install google-cloud-storage --user
I've been using stunnel for local Django development on SSL-enabled pages for a while, but since upgrading to Yosemite it seems to have stopped working:
$ sudo stunnel stunnel/dev_https
dyld: Library not loaded: /opt/local/lib/libssl.1.0.0.dylib
Referenced from: /usr/bin/stunnel
Reason: image not found
I tried building libssl from source using this gist and symlinking libssl.1.0.0.dylib to /opt/local/lib/libssl.1.0.0.dylib. That then failed, looking for /opt/local/lib/libcrypto.1.0.0.dylib. So I symlinked the version I'd just built to that expected path, and got this:
$ sudo stunnel stunnel/dev_https
dyld: Library not loaded: /usr/local/ssl/lib/libcrypto.1.0.0.dylib
Referenced from: /opt/local/lib/libssl.1.0.0.dylib
Reason: image not found
What's going on here? stunnel is at /usr/bin/stunnel and I've checked it's not installed via homebrew. Has anyone else managed to work this out?
I just got stunnel working for Django on Yosemite. If I remember correctly, I also had to previously fix my libssl as explained in this other answer for psycopg2.
Then, I use homebrew for everything:
$ brew install stunnel
$ openssl req -new -x509 -days 9999 -nodes -out stunnel.pem -keyout stunnel.pem
I put this in stunnel.conf (derived from here):
pid=/tmp/stunnel.pid
setuid=nobody
setgid=nobody
foreground=yes
client=no
[https]
cert = ./stunnel.pem
accept=443
connect=5000
I run stunnel with:
$ sudo stunnel stunnel.conf
And run Django with:
$ python manage.py runserver 0.0.0.0:5000
Hope that helps.