apache2 libapache2-mod-wsgi-py3 django - django

Previously my code was working with apache2, django and libapache2-mod-wsgi. But I had to use python3, hence I removed libapache2-mod-wsgi and installed libapache2-mod-wsgi-py3. Now I am getting an error when I restart apache2.
Below is the error from command systemctl status apache2.service. I don't know why WSGIScriptAlias is not working for libapache2-mod-wsgi-py3.
The apache2 configtest failed.
Output of config test was:
AH00526: Syntax error on line 7 of /etc/apache2/sites-enabled/000-default.conf:
Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not
Action 'configtest' failed.
The Apache error log may have more information.
apache2.service: Control process exited, code=exited status=1
Failed to start LSB: Apache2 web server.
apache2.service: Unit entered failed state.
apache2.service: Failed with result 'exit-code'.

Related

Django runserver on Chromebook (Crostini)

I'm using a Chromebook HP 11 G5 EE and try to develop with Django.
I use Crostini (Linux terminal into Chrome OS with no developper mode).
I've created a virtualenv inside my home directory and installed with pip all my requirements.
When I try to do (with source bin/activate) :
./manage.py runserver
It returns me :
Performing system checks...
System check identified no issues (0 silenced).
May 28, 2019 - 20:02:11
Django version 2.1.5, using settings 'myproject.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
Error: You don't have permission to access that port.
I'd try to set parameters like 0.0.0.0:8000, penguin.linux.test:8000, to change ports, I've got the same error.
Is someone had the same issue and fixed it ?
Thanks !
How about this:
./manage.py runserver 0.0.0.0:8000

django app not being served on digitalocean droplet

I'm following this tutorial online https://simpleisbetterthancomplex.com/tutorial/2016/10/14/how-to-deploy-to-digital-ocean.html
I get to an intermediary step where I want to check if I can access the app on the IP address. I run python manage.py runserver 0.0.0.0:8000 which returns the following:
System check identified no issues (0 silenced).
November 22, 2018 - 17:41:08
Django version 2.1.3, using settings 'mysite.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
So no errors. Then I navigate to my_droplet_ip:8000 and I get a timeout. "took to long to respond."
I am running the runserver command from a user rather than root. Don't know if that matters...
Any idea what's going on here?
I had to expose the port 8000 by running the command sudo ufw allow 8080. Wasn't mentioned anywhere in the tutorial...

Passenger doesn't seem to be running (Capistrano/Rails/Nginx/Ubuntu)

I'm deploying my app in Ubuntu 14.4, Ruby 2.3.3, Nginx and Passenger. When I deploy using capistrano, I get the error:
SSHKit::Command::Failed: passenger-config exit status: 1
passenger-config stdout: Nothing written
passenger-config stderr: *** ERROR: Phusion Passenger doesn't seem to be running. If you are sure that it
is running, then the causes of this problem could be one of:
1. You customized the instance registry directory using Apache's
PassengerInstanceRegistryDir option, Nginx's
passenger_instance_registry_dir option, or Phusion Passenger Standalone's
--instance-registry-dir command line argument. If so, please set the
environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory
and run this command again.
2. The instance directory has been removed by an operating system background
service. Please set a different instance registry directory using Apache's
PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir
option, or Phusion Passenger Standalone's --instance-registry-dir command
line argument.
Tasks: TOP => passenger:restart
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as user#IP-Address: passenger-config exit status: 1
passenger-config stdout: Nothing written
passenger-config stderr: *** ERROR: Phusion Passenger doesn't seem to be running. If you are sure that it
is running, then the causes of this problem could be one of:
1. You customized the instance registry directory using Apache's
PassengerInstanceRegistryDir option, Nginx's
passenger_instance_registry_dir option, or Phusion Passenger Standalone's
--instance-registry-dir command line argument. If so, please set the
environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory
and run this command again.
2. The instance directory has been removed by an operating system background
service. Please set a different instance registry directory using Apache's
PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir
option, or Phusion Passenger Standalone's --instance-registry-dir command
line argument.
I have tried several suggestions such as: https://www.pistolfly.com/weblog/en/2016/01/passenger-config-and-passenger-status-result-in-an-error-on-centos7.html
Passenger doesn't seem to be running (Capistrano/Rails/Apache/Ubuntu)
But nothing helped! I have checked my Nginx default_sites to see if I point to current rails path and everything looks correct.
Any help is appreciated!
This issue was fixed by adding restart.txt in my_app_name/current/tmp:
*It's done in the server:
*touch my_app_name/current/tmp/restart.txt
And add:
set :passenger_restart_with_touch, true in deploy.rb
UPDATE
In the newest version of capistrano, this is taken care of by gem 'capistrano-passenger' and adding adding require 'capistrano/passenger' in your capfile

sudo service httpd restart gives an error or ssl.conf

I want to restart httpd aws ec2 linux. I write following command in terminal.
sudo service httpd restart
But it gives me following error.
Starting httpd: AH00526: Syntax error on line 18 of /etc/httpd/conf.d/ssl.conf:
Invalid command 'SSLPassPhraseDialog', perhaps misspelled or defined by a module not included in the server configuration
[FAILED]
Starting httpd: AH00526: Syntax error on line 23 of /etc/httpd/conf.d/ssl.conf:
Invalid command 'SSLSessionCache', perhaps misspelled or defined by a module not included in the server configuration
[FAILED]
If i comment the line then it will show below error.
Starting httpd: AH00526: Syntax error on line 24 of /etc/httpd/conf.d/ssl.conf:
Invalid command 'SSLSessionCacheTimeout', perhaps misspelled or defined by a module not included in the server configuration
[FAILED]
I dont think so that each time i have to comment the lines.
Currently, i dont need ssl.conf.
So i dont want to call it when i am going to restart httpd.
how can i do it?
Thanks
When a module that provides certain Directives is not loaded Apache config check will complain about not "knowing" about them as you see in the errors you get.
You don't have mod_ssl loaded and that's why HTTPD giving you those config errors. Either load mod_ssl or make sure no mod_ssl directives are present (uncomment, delete, do not include ssl.conf, the choice is yours).
In my Centos 7 system, installing mod_ssl and python2-certbot-apache packages fixed the issue
sudo yum install epel-release
sudo yum install mod_ssl python2-certbot-apache
Reinstall the httpd and php again.
May be your config is broken.
I hope it works.

how to configure WSGISocketPrefix

I am getting a permissions issue when running django in daemon mode. Reading here https://code.google.com/p/modwsgi/wiki/ConfigurationIssues#Location_Of_UNIX_Sockets I think the solution is to configure the WSGISocketPrefix
The problem is that /var/run/wsgi is no where to be found on my centos server.
The closes thing I can find is: /etc/httpd/run/httpd.pid
How can I find where wsgi is installed?
Or what other value can I set the WSGISocketPrefix equal to?
With Ubuntu 14.0.4 LTS, Django11.1, Python 3.6.1, and mod_wsgi-4.5.15 it works for me as follows:
Apache was showing the following error:
503 Service Unavailable
Apache error log showed the following:
[wsgi:error] [pid 5411] (2)No such file or directory: [client 1.2.3.4:12345] mod_wsgi (pid=5411): Unable to connect to WSGI daemon process 'mywsgi' on '/var/run/apache2/wsgi.5403.0.1.sock' as user with uid=123.
Note that I'm running WSGI as a different user than the default www-data. This is changed with 'user' from WSGIDaemonProcess.
Solution:
At the bottom of /etc/apache2/apache2.conf, add:
WSGISocketPrefix /var/run/apache2/wsgi
After restarting Apache, I can ls -la and see the lock files under /var/run/apache2:
apache2.pid
wsgi.5017.0.1.sock
Sources:
http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGISocketPrefix.html?highlight=WSGISocketPrefix%20
https://code.google.com/archive/p/modwsgi/wikis/ConfigurationIssues.wiki#Location_Of_UNIX_Sockets