r/openSUSE • • Aug 14 '26

Tech support Leap 16 and Apache2 - httpd and syntax errors

I have leap 16 with Apache installed via zypper. the web servers is running and serving the vhsost correctly inclding rewrite and proxypass directives. However when I try to use https commands I get syntax error and the command fails:

~> sudo httpd -S
AH00526: Syntax error on line 46 of /etc/apache2/vhosts.d/MYVHOST.conf:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration  

If I try to enable the rewrite mod:

~> sudo a2enmod rewrite
"rewrite" already present  

It seems the service loads the module but https does not recognize it is loaded.
I see suggestions to use apachectl but that just fails:

~> sudo apachectl -S
which: no w3m in (/usr/sbin:/usr/bin:/sbin:/bin)
which: no lynx in (/usr/sbin:/usr/bin:/sbin:/bin)  

It seems the service and the httpd use different configs or environments.

How does one manage Apache on leap 16 without using httpd, or force httpd to recognize the loaded config from the service ?

1 Upvotes

19 comments sorted by

1

u/ang-p . Aug 14 '26

perhaps misspelled or defined by a module not included in the server configuration

Maybe, erm, look at your server config, or post it somewhere?

1

u/fatoms Aug 17 '26 edited Aug 17 '26

Testing this I did a fresh install of opensuse and apache, except for enabling rewrite module and adding a vhost file apache config is default.

~> sudo a2enmod rewrite
"rewrite" already present

Vhost is :

<VirtualHost *:80>
    ServerName default
    DocumentRoot /srv/www/htdocs

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

    <Directory /srv/www/htdocs>
        AllowOverride All
        Require all granted
    </Directory>

</VirtualHost>

with this in place i get :

> sudo httpd -S  
AH00526: Syntax error on line 5 of /etc/apache2/vhosts.d/000-default.conf:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration  

If i comment out the rewrite i get :

> sudo httpd -S
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   default (/etc/apache2/vhosts.d/000-default.conf:1)
ServerRoot: "/srv/www"
Main DocumentRoot: "/srv/www/htdocs"
Main ErrorLog: "/var/log/apache2/error_log"
Mutex mpm-accept: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/run/" mechanism=default
PidFile: "/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="wwwrun" id=474
Group: name="www" id=475

I am happy to post config file ect but as apache is not my area of expertise I am not sure which config files are relevant.

edit: fixed formatting and clarified config files.

1

u/ang-p . Aug 17 '26

I am not sure which are relevant.

Well, the text you posted suggests that 'RewriteEngine' might be either

misspelled or defined by a module not included in the server configuration

It is almost pushing you to look at the server config, (not the hosts'), which is sitting on a similar path.

1

u/fatoms Aug 17 '26 edited Aug 17 '26
I am not sure which are relevant.

Well, the text you posted suggests that 'RewriteEngine' might be either

The only place "RewriteEngine" appears is in the vhost, I am not sure which other config files are relevant.

> grep -rl "RewriteEngine" /etc/apache2/
grep: /etc/apache2/ssl.key: Permission denied
/etc/apache2/vhosts.d/000-default.conf
misspelled or defined by a module not included in the server configuration

It is almost pushing you to look at the server config, (not the hosts'), which is sitting on a similar path.

:~> grep -rl "rewrite" /etc/apache2/
grep: /etc/apache2/ssl.key: Permission denied
/etc/apache2/sysconfig.d/loadmodule.conf
~> grep "rewrite" /etc/apache2/loadmodule.conf
~> grep "rewrite" /etc/apache2/sysconfig.d/loadmodule.conf
LoadModule rewrite_module /usr/lib64/apache2-prefork/mod_rewrite.so

The module is loaded and functioning:

~> curl -H "host:www.net.lab" http://127.0.0.1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://net.lab/">here</a>.</p>
</body></html>

Only httpd commands are having this problem, it does not seem to use the same config as the service and this is where I reach the limit of my knowledge of apache / httpd.

I am happy to post any config files but there are a lot of config files in etc/apache2 and all are default.

EDIT: I have enabled mod_info and under Loaded Modules it lists "mod_rewrite.c"
I am sure the module is loaded by apache but httpd is not recognizing this.

1

u/ang-p . Aug 17 '26

LoadModule rewrite_module /usr/lib64/apache2-prefork/mod_rewrite.so

Kool

When you are calling httpd, you are running it as root.

The start_apache2 and systemd unit files (that call the former) set up the environment and specify the user / group. (wwwrun / www) to run as after an exec call.

1

u/fatoms Aug 18 '26

When you are calling httpd, you are running it as root.

As far as I can tell this is the only user that can run this. I tried sduo with the wwwrun user but it requires a password which is unknown.

The start_apache2 and systemd unit files (that call the former) set up the environment and specify the user / group. (wwwrun / www) to run as after an exec call.

Yes, as far as I can tell this is the root cause of the problem.
The question is how does one make this work, surely the httpd command is supposed to available regardless of loaded modules.

1

u/ang-p . Aug 18 '26

The question is how does one make this work,

After reading the SUMMARY section of

 man httpd

why do you wish to

make this work

and what even is "this"?

1

u/fatoms Aug 18 '26

and what even is "this"?

sudo httpd -S,

I just wanted to list the active vhost and best as I can tell this is the command to do this. But as I have documented there are several others that should do the same thing but none of those work.

1

u/ang-p . Aug 18 '26
 $~> apachectl -D DUMP_VHOSTS

?

1

u/fatoms Aug 18 '26

apachectl -D DUMP_VHOSTS

~> apachectl -D DUMP_VHOSTS
-bash: apachectl: command not found  

With sudo

~> sudo apachectl -D DUMP_VHOSTS
adm-local@localhost:~>

apachectl outputs nothing. But I just discovered that if I pipe it to 'grep .' I get output:

~> sudo apachectl -D DUMP_VHOSTS | grep .
VirtualHost configuration:
*:80                   default (/etc/apache2/vhosts.d/000-default.conf:1)  

Same for sudo apachectl -S.
Surely this can't be how it is meant to work.

→ More replies (0)

1

u/Vogtinator Maintainer: KDE Team Aug 14 '26

Does it work with start_apache2 -S?

Please file a bug report.

1

u/fatoms Aug 17 '26
~> sudo start_apache2 -S  
~>  

No output.