installing mod_ssl causes httpd to segmentation fault - apache

I am running apache
$ httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Oct 16 2014 14:48:21
and it runs fine but when I do yum install mod_ssl, apache seg faults. It seg faults right away when I try to list modules using httpd -M.
$ httpd -M
Segmentation fault
If I try to restart apache, it seg faults again
$ sudo service httpd restart
Stopping httpd: [ OK ]
Starting httpd: /bin/bash: line 1: 1627 Segmentation fault /usr/sbin/httpd
[FAILED]

the problem is with CentOS it seems, because I found this resource:
https://chrisjean.com/adding-ssl-support-to-apache-on-centos/
so all I had to do was make sure Apache was loading the SSL module and everything is ok. Hopefully this helps someone else in the future.

Related

uwsgi and apache2 issue

I'm having trouble with setting up uwsgi behind apache2.
Here's my system:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.5 LTS
Release: 12.04
Codename: precise
$ apache2 -v
Server version: Apache/2.4.20 (Ubuntu)
$ uwsgi --version
2.0.14
$ cat /etc/init/uwsgi.conf
description "uWSGI Emperor"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals/ --logto /var/log/uwsgi.log
$ python --version
Python 2.7.3
With
$ cat ~/myapp/wsgi.py
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return ["<h1 style='color:blue'>Hello There!</h1>"]
and
$ cd ~/myapp
$ uwsgi --socket 0.0.0.0:8081 --protocol=http -w wsgi
i can browse to http://example.com:8081 and see the "Hello there!" test page. So, I'm assuming uwsgi is working correctly. However, I want to put uwsgi behind apache2, but whenenver I try
$ a2enmod uwsgi
and restart apache2 I get an error that I can't make sense of:
$ service apache2 restart
* Restarting Apache httpd web server apache2 [fail]
* The apache2 configtest failed.
Output of config test was:
apache2: Syntax error on line 140 of /etc/apache2/apache2.conf:
Syntax error on line 1 of /etc/apache2/mods-enabled/uwsgi.load:
Cannot load /usr/lib/apache2/modules/mod_uwsgi.so into server:
/usr/lib/apache2/modules/mod_uwsgi.so: cannot open shared object file:
No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.
Can anyone help me with this? I have searched for hours but I can't find aynthing that helped me with this..
Thank you very much in advance.
PS: Oh, and I couldn't find any relevant information in the apache error logs.
In case anyone is interested, here's how i got it to work:
Instead of using the uwsgi_mod, i simply proxied everything in my apache configuration:
<VirtualHost *:80>
...
ProxyPreserveHost On
ProxyRequests Off
ProxyVia Off
ProxyPass / http://127.0.0.1:8081/
ProxyPassReverse / http://127.0.0.1:8081/
</VirtualHost>
The uwsgi command would run with uwsgi --ini uwsgi.ini where uwsgi.ini would contain the following lines
[uwsgi]
chdir = path/to/my/project
http-socket = :8081
module = wsgi:application
...
That way i don't need to run the uwsgi_mod and everything works. Hopefully that helps anyone, someday.

Debian/Apache2 doen't start and stays in inactive mode

VPS, Debian
After purging and reinstalling Apache2 through apt-get install apache2, it does not start. After starting service apache2 start, it does not give any message. systemctl status apache2 gives the following:
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2)
Drop-In: /lib/systemd/system/apache2.service.d
└─forking.conf
Active: inactive (dead) since Su 2016-10-16 23:24:07 KRAT; 14min ago
Process: 1953 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 1947 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
there is nothing hanging on port 80. simple http-servers (by Python eg) work ok.
there is nothing in log - all files are empty.
How to make apache work?
I've found the answer. thanx for your attention. For that here is what i did for solving this.
What I have done
I've found that I do not have /usr/sbin/apache2 AT ALL. Have no idea, how it's happend. sudo apachectl configtest told me about it.
Took /usr/sbin/apache2 from backup. surely I could reinstall it from apt-get.
After that, doing sudo apachectl configtest, I've found a message like that:
apache2: Syntax error on line 140 of /etc/apache2/apache2.conf:
Syntax error on line 2 of /etc/apache2/mods-enabled/access_compat.load:
Cannot load /usr/lib/apache2/modules/mod_access_compat.so into server:
/usr/lib/apache2/modules/mod_access_compat.so: cannot open shared object file: No such file or directory
Action 'configtest' failed.
it was cured by sudo apt-get --reinstall install apache2-bin
that's all. thank you
Solved:
$ sudo apt-get update
$ sudo apt-get install apache2
Source: https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-16-04

php fpm error after upgrading

I decided to do a aptitude safe upgrade today on my debian and it replaced my version of php with the latest.
It asked me if i want to keep my www.conf and i selected yes.
By this time, i see these errors in the error.log:
(13)Permission denied: FastCGI: failed to connect to server "/home/john/domains/test.net/php5-fpm": connect() failed
FastCGI: incomplete headers (0 bytes) received from server "/home/john/domains/test.net/php5-fpm"
And website is not accessible (php versions).
/home/john/domains/test.net/php5-fpm is not a directory at all.
I tried adding these lines to www.conf and restarting the service, with no luck:
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
Please advise.
When you upgrade the Apache, the worker sometimes changes, execute apachectl -V and see what worker do you have installed.
For example in my local server i have MPM worker, and when i update via aptitude, the worker changes to prefork (don't know why), so i need to:
Executes apachectl -V and see what worker i have installed.
Executes sudo apt-get install apache2-mpm-worker if i detect i have prefork installed
In your case you will need to reinstall php5-fpm

Apache not making core dump even though kill -11 makes one

Hope this is something simple, but maybe not.
I have 4 RHEL5 web boxes that are setup behind a load balancer. All serve the majority of their content off of an NFS share.
Occasionally (twice a day or less) I'll see a note in the syslog from the kernel about a segfault from apache:
/var/log/messages.2:Sep 13 14:09:14 20050lpweb01 kernel: httpd[10006]: segfault at 00007fffae2eede8 rip 00002ab21a4045d4 rsp 00007fffae2eedd0 error 6
Sometimes, this is accompanied by a message to the apache error log about it as well, but not always:
# grep -ic seg /var/log/messages* |egrep -v '0$'
/var/log/messages.2:1
/var/log/messages.3:2
/var/log/messages.4:4
# zgrep -ic seg /var/log/httpd/error_log* |egrep -v '0$'
/var/log/httpd/error_log:1
/var/log/httpd/error_log.10.gz:1
/var/log/httpd/error_log.17.gz:1
/var/log/httpd/error_log.19.gz:1
/var/log/httpd/error_log.23.gz:1
/var/log/httpd/error_log.24.gz:2
/var/log/httpd/error_log.25.gz:1
/var/log/httpd/error_log.28.gz:2
/var/log/httpd/error_log.30.gz:1
/var/log/httpd/error_log.31.gz:1
/var/log/httpd/error_log.35.gz:1
/var/log/httpd/error_log.39.gz:4
/var/log/httpd/error_log.42.gz:1
/var/log/httpd/error_log.44.gz:3
/var/log/httpd/error_log.46.gz:1
I've setup core dumping per instructions all over the web:
echo "ulimit -c unlimited >/dev/null 2>&1" >> /etc/profile
echo "DAEMON_COREFILE_LIMIT='unlimited'" >> /etc/sysconfig/init
echo 1 > /proc/sys/fs/suid_dumpable
echo "core.%p" > /proc/sys/kernel/core_pattern
echo "CoreDumpDirectory /home/coredump" > /etc/httpd/conf.d/core_dumps.conf
mkdir /home/coredump
chown apache: /home/coredump
source /etc/profile
service httpd stop
service httpd start
When I "induce" a segfault (kill -11 ), the coredump is generated:
/var/log/httpd/error_log:[Sat Sep 15 20:43:32 2012] [notice] child pid 20746 exit signal Segmentation fault (11), possible coredump in /home/coredumps
But when the segfault occurs on its own, no coredump is made:
/var/log/httpd/error_log:[Sat Sep 15 12:03:44 2012] [notice] child pid 10652 exit signal Segmentation fault (11)
Why is this happening and how can I make sure the core dump happens every time?
We are running PHP 5.2 but other than that, everything is installed from standard RHEL or EPEL repos.

How to determine if OpenSSL and mod_ssl are installed on Apache2

Does anyone know the command to determine if OpenSSL and mod_ssl are installed on Apache2?
If you have PHP installed on your server, you can create a php file, let's called it phpinfo.php and add this <?php echo phpinfo();?>, and open the file in your browser, this shows information about your system environment, to quickly find info about your Apache loaded modules, locate 'Loaded Modules' on the resulting page.
If you have PHP installed on your server, you can chek it in runtime using "extension_loaded" funciontion. Just like this:
<?php
if (!extension_loaded('openssl')) {
// no openssl extension loaded.
}
?>
Usually, when you compile your apache2 server (or install it by packages facility stuff), you can check any directive that're available to be used by tapping this command:
~# $(which httpd) -L | grep SSL # on RHEL/CentOS/Fedora
~# $(which apache2) -L | grep SSL # on Ubuntu/Debian
~# $(which httpd2) -L | grep SSL # on SUSE
If you don't see any SSL* directive, it means that you don't have apache2 with mod_ssl compiled.
The default Apache install is configured to send this information on the Server header line. You can view this for any server using the curl command.
$ curl --head http://localhost/
HTTP/1.1 200 OK
Date: Fri, 04 Sep 2009 08:14:03 GMT
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8a DAV/2 PHP/5.2.6 SVN/1.5.4 proxy_html/3.0.0
Use the following commands.
$ openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013 (or similar output)
For RHEL/CentOS/Fedora:
$ httpd -t -D DUMP_MODULES | grep ssl
ssl_module (shared)
For Ubuntu/Debian
$ apache2 -t -D DUMP_MODULES | grep ssl
ssl_module (shared)
For SUSE
$ httpd2 -t -D DUMP_MODULES 2>&1 | grep ssl
ssl_module (shared)
Using Apache 2, you can see what modules are currently loaded by the HTTP daemon by running the following command:
apache2ctl -M
The -M option is really just a parameter passed to httpd.
apache2ctl is a front end to the Apache HyperText Transfer Protocol
(HTTP) server. It is
designed to help the administrator control the functioning of the Apache apache2 daemon.
NOTE: The default Debian configuration requires the environment variables APACHE_RUN_USER,
APACHE_RUN_GROUP, and APACHE_PID_FILE to be set in /etc/apache2/envvars.
The apache2ctl script returns a 0 exit value on success, and >0 if an error occurs. For
more details, view the comments in the script.
Fortunately, Most flavors of Linux have OpenSSL "out of the box".
To verify installation:
openssl version
Response:
OpenSSL 1.0.1t 3 May 2016
Note: version OpenSSL 1.0.1 through 1.0.1f (inclusive)
are vulnerable to the OpenSSL Heartbleed Bug.
Versions 1.0.1g and greater are fixed.
For additional install info:
Ubuntu/Debian
dpkg -l | grep -i openssl
Response:
ii libcrypt-openssl-random-perl 0.04-2+b1 amd64 module to access the OpenSSL pseudo-random number generator
ii libcurl3:amd64 7.38.0-4+deb8u5 amd64 easy-to-use client-side URL transfer library (OpenSSL flavour)
ii libgnutls-openssl27:amd64 3.3.8-6+deb8u4 amd64 GNU TLS library - OpenSSL wrapper
ii openssl 1.0.1t-1+deb8u6 amd64 Secure Sockets Layer toolkit - cryptographic utility
ii python-ndg-httpsclient 0.3.2-1 all enhanced HTTPS support for httplib and urllib2 using PyOpenSSL
ii python-openssl 0.14-1 all Python 2 wrapper around the OpenSSL library
ii ssl-cert 1.0.35 all simple debconf wrapper for OpenSSL
Yea, OpenSSL is installed!
To install OpenSSL if you don't have it, try:
Debian/Ubuntu:
sudo apt-get install openssl
RedHat/CentOS:
yum install openssl
To determine openssl & ssl_module
# rpm -qa | grep openssl
openssl-libs-1.0.1e-42.el7.9.x86_64
openssl-1.0.1e-42.el7.9.x86_64
openssl098e-0.9.8e-29.el7.centos.2.x86_64
openssl-devel-1.0.1e-42.el7.9.x86_64
mod_ssl
# httpd -M | grep ssl
or
# rpm -qa | grep ssl
You should install this Apache mod, http://httpd.apache.org/docs/2.0/mod/mod_info.html, it basically gives you a run down of the mods you're using and the Apache settings.
I have this enabled on my Apache and it gives me this info for my website,
Server Version: Apache/2.2.3 (Debian) mod_jk/1.2.18 PHP/5.2.0-8+etch13 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_perl/2.0.2 Perl/v5.8.8
If you just run openssl in your terminal it should present the openSSL shell. My first clue to knowing that I didn't have mode_ssl was when I got the following error after adding SSLEngine on in my virtualhost file:
Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration
In centos I just had to install it via yum install mod_ssl
Just look in the ssl_engine.log in your Apache log directory where you should find something like:
[ssl:info] [pid 5963:tid 139718276048640] AH01876: mod_ssl/2.4.9 compiled against Server: Apache/2.4.9, Library: OpenSSL/1.0.1h
Create a test.php file with the following code in a www folder:
<?php echo phpinfo();?>
When you navigate to that page/URL in the browser. You will see something similar if you have openssl enabled:
Enable mod_ssl in httpd.conf and restart the apache. You will see the openssl information in error.log as below
[Fri Mar 23 15:13:38.448268 2018] [mpm_worker:notice] [pid 8891:tid 1] AH00292: Apache/2.4.29 (Unix) OpenSSL/1.0.2n configured -- resuming normal operations
[Fri Mar 23 15:13:38.448502 2018] [core:notice] [pid 8891:tid 1] AH00094: Command line: '/opt/apps/apache64/2.4.29/bin/httpd'
to verify in php command lie
$php -i | grep openssl
In my case this is how I got the information:
find where apache logs are located, and go there, in my case:
cd /var/log/apache2
find in which log openssl information can be found:
grep -i apache.*openssl *_log
e.g. error_log ...
to get fresh information, restart apache, e.g.
rcapache2 restart # or service apache2 restart
check for last entries in the log, e.g.
/var/log/apache2 # tail error_log
[Thu Jun 09 07:42:24 2016] [notice] Apache/... (Linux/...) mod_ssl/2.2.22 OpenSSL/1.0.1t ...
To find the ssl version
Go to Apache bin folder in command prompt
Enter these commands "openssl version"