sudo service httpd restart gives an error or ssl.conf - amazon-web-services

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.

Related

502 Bad Gateway, I messed up users and groups permissions on digitalocean ubuntu for django deployment

I have created a droplet, an ubuntu 18.04 server on digitalocen successfully.
Followed the install digitalocean's guide and ran the gunicorn,nginx, django etc. and ran the website successfully on the browser using my ip address i.e. firewalls, gunicorn and nginx and everything were configured correctly.
During the testing while uploading the images to the media folder I got an error "permissions denied" (POST error).
Found somewhere the below code on google and thought it solves the permissions related problem: https://www.semicolonworld.com/question/55551/django-errno-13-permission-denied-39-var-www-media-animals-user-uploads-39
sudo groupadd varwwwusers
sudo adduser www-data varwwwusers
sudo chgrp -R varwwwusers /var/www/
sudo chmod -R 760 /var/www/
But the above code messed up everything and ran into "502 Bad Gateway".
I am not very familiar with Linux deployments. Can someone help me investigating and resolving this issue. I think I have messed up the users, groups permissions.
How can I get this resolved OR how can I revert what I did OR is there any activity logs I can see and investigate.
I have checked the error.log and able to see
' connect() to unix:/run/gunicorn.sock failed (111: Connection refused) while connecting to upstream'
Thanks for the help in advance.
I guess that the problem is that by running sudo chmod -R 760 /var/www/ you have forbidden non-ownesrs of the folder to read, write and execute files form that directory. Then, since uwsgi processes does not belong to the www-data group (usually), uwsgi connection was refused.
The easiest way to solve this problem is to run sudo chmod -R 766 /var/www/ - this will grant writing and readind priveleges to anyone (chmod -R 764 should also work and is safer - it allows only reading files for non-owners). Alternatively, you may find out the name of the user running uwsgi and grant him permissions for reading files form the directory. See chmod manual (or google it) for reference.

apache2 libapache2-mod-wsgi-py3 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'.

connect() to unix:/home/ubuntu/lsb/lsb.sock failed (2: No such file or directory)

First of all I am a 100% newbie, so I'm not really even sure what to ask.
I'm trying to build a production environment on Ubuntu 12.04 for Django. I installed Nginx, uWSGI, Python, Django, etc. I followed this guide here: https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-14-04.
I'm getting a 502 Bad Gateway error, and when I checked the error.log file I found this at the end:
2015/07/22 17:43:18 [crit] 23919#0: *3 connect() to unix:/home/ubuntu/lsb/lsb.sock failed (2: No such file or directory) while connecting to upstream, client: 180.152.149.63, server: 115.159.36.162, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/home/ubuntu/lsb/lsb.sock:", host: "115.159.36.162:8000"
According to the guide, I created all the relevant files but I only have 1 project, and replaced all instance of user with ubuntu, and firstproject with lsb.
For the server block configuration file, I just used the server's IP address and port 8000. The one that's in /etc/nginx/sites-available.
server {
listen 8000;
server_name 115.159.36.162;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/ubuntu/lsb;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/home/ubuntu/lsb/lsb.sock;
}
}
Besides this I pretty much followed the guide to the letter. I found a guy who said it was due to the problem of permissions with uwsgi_params, I used sudo chown ubuntu uwsgi_params but that didn't fix it either (I'm not even sure if that's the right command to use...).
In any case I don't even know what I don't know here. ANY suggestions would be greatly appreciated, thanks!!
UPDATE after Daniel Roseman's suggestions
I indeed never started uwsgi, but when I tried to do sudo service uwsgi start, I get an error saying uwsgi: unrecognized service. I then went back up the guide and saw that they suggested I run a uwsgi command right after I install it to test it:
uwsgi --http :8080 --home /home/user/Env/firstsite --chdir /home/user/firstsite -w firstsite.wsgi
This command returned another error,
Fatal Python error: Py_Initialize: Unable to get the locale encoding ImportError: No module named 'encodings'
Some websites say that this has to do with uwsgi not being able to find Python. I installed Python3.4 before, it's accessible when I type python3.4 anywhere in the shell. Besides that I think there's also 2.7 installed and maybe 3.2 as well. Not really sure if this is relevant, and not sure how to help uwsgi "find" Python, or if that's even the problem.
Looking back, here's a list of things that I did differently from the guide (contradicting my previous "to the letter" claim) that might be relevant to the problem.
I installed python3.4, from this Felix Krull depository, mainly because when I tried to do the normal sudo apt-get install python3 it gives me an error, so after I added the depository I did sudo apt-get install python3.4.
The pip I used isn't the pip3 that all these sites keep saying, since, again, I can't seem to install pip3 at all. So what I ended up doing is I got this get-pip.py from pip's website, and executed it using python3.4.
On top of that, in the guide that says install python-dev, sudo apt-get install python-dev, I did instead sudo apt-get install python3.4-dev. This is something the guide says uwsgi needs, so I'm not sure if this is screwing things up.
Once again thanks for all the help Daniel!

Trouble installing cPanel

I am trying to install the latest version of cPanel on a server running Centos 6.6 and it is failing here:
[20150129.112152] Testing if it's possible to install a simple RPM
[20150129.112152] Retrieving http://httpupdate.cpanel.net/RPM/rpm_is_working-1.0-0.noarch.rpm
[20150129.112152] Preparing... ##################################################
[20150129.112152] rpm_is_working ##################################################
[20150129.112152] Now removing the RPM
info [updatenow] upcp Notification => root#server.serveraddress.com via EMAIL [level => 1]
Cpanel::iContact: icontact /usr/sbin/sendmail is not executable by 0
[20150129.112152] W An attempt to up/downgrade to 11.46.2.4 was blocked. Please review blockers.
Can't exec "/usr/local/cpanel/scripts/cpanel_initial_install": No such file or directory at
/home/cPanelInstall/selfgz11290/install line 146.
2015-01-29 11:21:52 148 (FATAL): Failure to exec /usr/local/cpanel/scripts/cpanel_initial_install
Removing /root/installer.lock
Does anyone have any ideas? I am trying to install this on an AWS EC2 instance that is running Centos 6.6. I tried opening my security group so that all traffic is allowed and this did not help.
It may be resulted from the failure of downloading essential files. I solved this problem on my server simply by clear /etc/sysconfig/iptables and stop the iptables service by service iptables stop.
What's more, I also delete ~/.cpan/, ~/.cpanm/, ~/.cpcpan/ and ~/cPanelInstall.

Fab Deploy Error: '"Error log: [emerg] 8780#0: invalid server name or wildcard "mydomain*.mydomain.com" on 0.0.0.0:80"'

I've been stuck on this deployment error for days, help! Our project is in the last step of deployment cd to the /home/django/django_project directory and run "fab deploy". Our project errors out on the supervisorctl start my_app: gunicorn command within our "fabfile.py" with the follow error code.:
"[555.555.55.555] out: my_app:gunicorn_my_app: ERROR (abnormal termination) "
Below are error logs.
/home/django/django_project/deploy
:: Important configuration files in this directory **nginx.conf**
/etc/supervisor/conf.d
:: Important configuration files in this directory **my_app.conf**
/var/log/supervisor
:: Important error log files in this directory **supervisord.log**
"INFO spawned: 'gunicorn_my_app' with pid 11575
INFO exited: gunicorn_my_app (exit status 1; not expected)
INFO gave up: gunicorn_my_app entered FATAL state, too many start retries too quickly"
/var/log/nginx
:: Important error log files in this directory **error.log.1**
Error log: 2015/01/02 18:21:42 [emerg] 8780#0: invalid server name or wildcard "mydomain*.mydomain.com" on 0.0.0.0:80
I changed the server name variable in our nginx.conf file but for some reason it hasn't been updated when this command runs.
I probably can't help, but I'll throw some things out there.
You haven't provided any of your configs for nginx or gunicorn, which would be helpful. Perhaps you could provide those so others can take a look at them?
Gunicorn:
From the logs it seems like gunicorn is taking a poop somewhere in the process of attempting to launch. Perhaps a configuration error may be preventing the server from starting. If you haven't done so yet it's worth checking that your configs are kosher.
From the gunicorn configuration documentation:
To check your configuration when using the command line or the configuration file you can run the following command:
$ gunicorn my_app:gunicorn_my_app --check-config
It will also allow you to know if your application can be launched.
If everything comes back fine, then you can probably rule that out and take a deeper look. Gunicorn has a debug option that should let you see in great detail what exactly is going wrong. The docs say it can be done with the --debug option, like so:
$ gunicorn my_app:gunicorn_my_app --debug
Hopefully that should get you a little closer to understanding what's up.
Nginx:
I don't know if you're getting that nginx error every time you're trying to start the server, but I'll take a stab at what I can see in that error log.
Nginx only supports wildcard server names at beginning or the end of the name.
From the nginx documentation on server names:
A wildcard name may contain an asterisk only on the name’s start or end, and only on a dot border. The names “www..example.org” and “w.example.org” are invalid. However, these names can be specified using regular expressions, for example, “~^www..+.example.org$” and “~^w..example.org$”. An asterisk can match several name parts. The name “.example.org” matches not only www.example.org but www.sub.example.org as well.
To listen on mydomain*.mydomain.com, you would use a regular expression in the server_name directive in the server block of your nginx.conf file.
The following regular expression would achieve this:
^mydomain(\S*)\.mydomain\.com$
and you would put it in your nginx.conf like so:
server {
server_name ~^mydomain(\S*)\.mydomain\.com$;
}
And after saving any changes to your nginx.conf, always running this command is good practice:
$ sudo nginx -t
Just like gunicorn's --check-config, it parses your configuration files to check that there are no errors, and it will tell you if there are any that need fixing.
Apologies if this answer isn't ultimately useful.