How do I check the apache config for validity in Red Hat Linux? - apache

My operating system is Red Hat Enterprise Linux 7. This isn't working...
# httpd -t
bash: httpd: command not found
In case it helps, this is the command I run to restart apache on this box...
# systemctl restart httpd24-httpd
But this doesn't work...
# httpd24-httpd -t
bash: httpd24-httpd: command not found
This doesn't work either...
# apachectl -t
bash: apachetl: command not found
Nor does this work...
# apachectl configtest
bash: apachetl: command not found

I know this is a couple months old but ended up here. I ran into the same issue initially, hence why I am here. I found that the location for the new httpd24-httpd wasn't in my env path to execute. While I could added it there, I found the command location and was able to execute.
How I found the command:
sudo find / -name apachectl
The output of the command:
/opt/rh/httpd24/root/usr/sbin/apachectl
Executed the command:
sudo /opt/rh/httpd24/root/usr/sbin/apachectl
Turns out I have to fix my configuration.
httpd: Syntax error on line 56 of /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf: Syntax error on line 40 of /opt/rh/httpd24/root/etc/httpd/conf.modules.d/00-base.conf: Cannot load modules/mod_http2.so into server: libnghttp2-httpd24.so.14: cannot open shared object file: No such file or directory
Interesting that this came up for me, as I've not done anything with the configuration in this regard.
Here's the version I am running.
sudo /opt/rh/httpd24/root/usr/sbin/apachectl -v
Server version: Apache/2.4.34 (Red Hat)
Server built: Mar 17 2020 09:34:59
All the best!
Found something more for this as well from an old bug submitted to Redhat
Bug 1329639
Comment 10
scl enable httpd24 -- /opt/rh/httpd24/root/usr/sbin/apachectl configtest

Related

How can I resolve Homebrew openssl conflicts?

I am on High Sierra 10.13.6 and I recently ran into an issue with my Homebrew environment for local dev work. I can't seem to figure out what is the problem. Any Composer or Drush commands will give this
dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
Abort trap: 6
I restarted my computer and when I try to start apachectl; I get
httpd: Syntax error on line 179 of /usr/local/etc/httpd/httpd.conf: Cannot load /usr/local/Cellar/php71/7.1.12_23/libexec/apache2/libphp7.so into server: dlopen(/usr/local/Cellar/php71/7.1.12_23/libexec/apache2/libphp7.so, 10): Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib\n Referenced from: /usr/local/Cellar/php71/7.1.12_23/libexec/apache2/libphp7.so\n Reason: image not found
I think this is because the path is looking for openssl, but in the Brew list, I don't have openssl anymore, it is now openssl#1.1
Bash profile has the following:
export PATH="/usr/local/opt/openssl#1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl#1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl#1.1/include"
$which openssl returns
/usr/local/opt/openssl#1.1/bin/openssl
What can I do to resolve this? Maybe I'm missing the obvious.
So in case anyone runs into this. I managed to fix this myself.
First I commented out the following line in my usr/local/etc/httpd/httpd.conf file
LoadModule php7_module /usr/local/Cellar/php71/7.1.12_23/libexec/apache2/libphp7.so
Next I ran
$brew install php#7.3
I added the following lines to .bash_profile
export PATH="/usr/local/opt/php#7.3/bin:$PATH"
export PATH="/usr/local/opt/php#7.3/sbin:$PATH"
Then added the following line to usr/local/etc/httpd/httpd.conf file
LoadModule php7_module /usr/local/Cellar/php#7.3/7.3.13/lib/httpd/modules/libphp7.so
Then I restarted my computer then ran
$brew services start php#7.3
$brew services restart httpd
$sudo apachectl -k restart
Then I had some sql connection issues.
$brew upgrade mariadb
$brew services restart mariadb
$brew services restart httpd
$sudo apachectl -k restart
And everything came together. Hope this helps.
If that helps somebody else not willing to reinstall PHP:
ln -s /usr/local/Cellar/openssl/1.0.2s/lib/libcrypto.1.0.0.dylib /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
ln -s /usr/local/Cellar/openssl/1.0.2s/lib/libssl.1.0.0.dylib /usr/local/opt/openssl/lib/libssl.1.0.0.dylib

apachectl command doesn't work from SSH

We have one redhat linux enterprise 7.0 server.
I installed Apache 2.4.6 (last version) on this server.
Once i check the version of apache with apachectl -v command on the server terminal, i am getting below result and it is ok.
But when i tried same command from a different machine by using SSH Secure Shell, i am getting no result from this (apachectl -v) command as shown below.
What is the problem here? Is there any SSH setting regarding this command? We need to run apachectl -v command from SSH-Outside.
Thanks for your help..

Apachectl looking into wrong directory

I was trying to make apache mysql php and phpmyadmin running together and following this instructions https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew I made a big mistake.
When I run on the terminal apachectl configtest or apachectl start, etc It looking into /usr/local/etc/apache2/2.2/httpd.conf and I want to restore to the original location.
I have my apache runnning http://localhost and is 2.4 because when I try http://localhost/test.php ( < ? php phpinfo() ?> ) and it says "Apache Version Apache/2.4.16 (Unix) PHP/5.5.29" but when I want to see the version apachectl -v it says is 2.2 and I know that I had per default 2.4 I want to restore all the changes that I made on apache and get rid of what I did with the other tutorial.
I don't mind if I cant use apachectl anymore but I want to know how can I continue control de apache 2.4 that is on the mac start,restart and stop commands.
I found the solution doing apachectl -V go to the root of config placed on /Cellar and paste the httpd.conf with the original.

How to upgrade apache 2.2.15 to apache 2.4.12 on CentOS 6.6?

I tried ,but didn't work for me.
Apache 2.4 on CentOS 6.6:
Step 1:
cd /etc/yum.repos.d/
wget http://repos.fedorapeople.org/repos/jkaluza/httpd24/epel-httpd24.repo
Step 2:
yum install httpd24.x86_64
Step 3:
$ /opt/rh/httpd24/root/usr/sbin/httpd -version
Server version: Apache/2.4.6 (Red Hat)
Server built: Sep 25 2013 05:25:46
NOTE: config files are in: /opt/rh/httpd24/root/etc/httpd
$ ls
conf conf.d conf.modules.d logs modules run
EDIT: in case you want to switch off Apache 2.2
$ chkconfig httpd off
$ chkconfig --list | grep httpd
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
httpd24-httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
EDIT 2: http://wiki.apache.org/httpd/PHP-FPM
yum install php-fpm
/etc/init.d/php-fpm start
Does any body knows the solutions, please let me know.
It would be best if you built it yourself from the Apache source code on a CentOS 6.6 system.
Compiling and Installing Apache 2.4:
http://httpd.apache.org/docs/current/install.html
Make note of the configure line during the build so you can make sure it includes all the modules you want (Like mod_ssl...etc..). Details on what is available for the configure line located here http://httpd.apache.org/docs/current/programs/configure.html
$ CC="pgcc" CFLAGS="-O2" \
./configure --prefix=/sw/pkg/apache \
--enable-ldap=shared \
--enable-lua=shared
If you want your own RPM, create a SPEC file with your own customizations.
The easiest way is to install the SCL version, as described here:
https://unix.stackexchange.com/questions/412122/how-to-update-apache-to-2-4-29-using-scl

httpd does not work (-bash: httpd: command not found)

I am on someone else's linux server (shared hosting). I do not have root access. I have determined that it's a Redhat 4.1.2-46 running as Centos Release 5.9(Final).
I have the database dump for the site and the .php files from public_html as well. What I'm TRYING TO DO is locate the httpd.conf file and get the config for that site.
when I type in
httpd - v
I get -bas: httpd: command not found - even in like the /user/sbin directory - and it's clearly running and there.
Bottom line I can't find the sitedef/conf file for www.thisparticularsite.com - and can't even figure out what version of apache I'm running...
For Apache 2 try apache2ctl -v (or sudo apache2ctl -v if root access is available). I'm on a Raspberry Pi 4B running Debian, just for reference.
The init files of apache are usually located in /etc/init.d the httpd path are found in it. However, You can find out where the httpd.conf file and httpd command directory by doing a ps aux|grep -i http. For example:
ps aux|grep -i http
510 2594 0.0 0.0 77256 1516 ? S Jul02 0:00 **/usr/sbin/httpd-0.0.0.0_80** -k start -f **/etc/httpd/conf/instances/httpd-0.0.0.0_80/httpd.conf**
root 5470 0.0 0.0 77120 872 ? Ss 2013 22:13 **/usr/sbin/httpd-0.0.0.0_80** -k start -f **/etc/httpd/conf/instances/httpd-0.0.0.0_80/httpd.conf**
Conclusion:
httpd.conf file path: **/etc/httpd/conf/instances/httpd-0.0.0.0_80/httpd.conf**
httpd command directory: **/usr/sbin/httpd-0.0.0.0_80**
As mentionned by apache.org, httpd command should not be invoked directly.
see source
If you're trying to find loaded modules, earlier the command was httpd -l. But it'll give you the same error, Command 'httpd' not found,
Nowadays, you can use apache2 -l (tested on Apache/2.4.29).